ostree/src/ostbuild/ostbuild-commit-artifacts

52 lines
1.9 KiB
Python

#!/usr/bin/python
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
# http://people.gnome.org/~walters/docs/build-api.txt
import os,sys,subprocess,tempfile,re
i=1
repo=sys.argv[i]
artifact_re = re.compile(r'^artifact-([^,]+),([^,]+),([^,]+),([^,]+),([^.]+)\.tar\.gz$')
def call_ostree_sync(*args):
subprocess.check_call(['ostree', '--repo=' + repo] + list(args))
for arg in sys.argv[2:]:
basename = os.path.basename(arg)
match = artifact_re.match(basename)
if match is None:
print "Invalid artifact name: %s" % (arg, )
sys.exit(1)
buildroot = match.group(1)
buildroot_version = match.group(2)
name = match.group(3)
branch = match.group(4)
version = match.group(5)
branch_name = 'artifacts/%s/%s/%s' % (buildroot, name, branch)
call_ostree_sync('commit', '-b', branch_name, '-s', 'Build ' + version,
'--add-metadata-string=ostree-buildroot-version=' + buildroot_version,
'--add-metadata-string=ostree-artifact-version=' + version,
'--skip-if-unchanged', '--tar-autocreate-parents', '--tree=tar=' + arg)