[ostree] ostbuild: Port commit-artifacts to ostbuild executor
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] ostbuild: Port commit-artifacts to ostbuild executor
- Date: Fri, 23 Dec 2011 17:11:27 +0000 (UTC)
commit be117edee49d43f9832bba9406792ab6deacf349
Author: Colin Walters <walters verbum org>
Date: Fri Dec 23 10:57:54 2011 -0500
ostbuild: Port commit-artifacts to ostbuild executor
Makefile-ostbuild.am | 4 +-
src/ostbuild/ostbuild-commit-artifacts | 51 ---------------
.../pyostbuild/builtin_commit_artifacts.py | 65 ++++++++++++++++++++
src/ostbuild/pyostbuild/main.py | 3 +-
4 files changed, 69 insertions(+), 54 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index 96b2e37..c23cea8 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -20,7 +20,6 @@ ostbuild: src/ostbuild/ostbuild.in Makefile
bin_SCRIPTS += ostbuild
bin_SCRIPTS += \
- src/ostbuild/ostbuild-commit-artifacts \
src/ostbuild/ostbuild-chroot-compile-one-impl \
src/ostbuild/ostbuild-nice-and-log-output \
$(NULL)
@@ -32,8 +31,9 @@ pyostbuild_PYTHON = \
src/ostbuild/pyostbuild/main.py \
src/ostbuild/pyostbuild/ostbuildlog.py \
src/ostbuild/pyostbuild/subprocess_helpers.py \
- src/ostbuild/pyostbuild/builtin_compile_one.py \
src/ostbuild/pyostbuild/builtin_autodiscover_meta.py \
+ src/ostbuild/pyostbuild/builtin_commit_artifacts.py \
+ src/ostbuild/pyostbuild/builtin_compile_one.py \
$(NULL)
bin_PROGRAMS += src/ostbuild/ostbuild-user-chroot
diff --git a/src/ostbuild/pyostbuild/builtin_commit_artifacts.py b/src/ostbuild/pyostbuild/builtin_commit_artifacts.py
new file mode 100644
index 0000000..af78e71
--- /dev/null
+++ b/src/ostbuild/pyostbuild/builtin_commit_artifacts.py
@@ -0,0 +1,65 @@
+#!/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
+import argparse
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync
+
+class OstbuildCommitArtifacts(builtins.Builtin):
+ name = "commit-artifacts"
+ short_description = "Commit artifacts to their corresponding repository branches"
+
+ def execute(self, argv):
+ artifact_re = re.compile(r'^artifact-([^,]+),([^,]+),([^,]+),([^,]+),([^.]+)\.tar\.gz$')
+
+ parser = argparse.ArgumentParser(self.short_description)
+ parser.add_argument('--repo')
+ parser.add_argument('artifacts', nargs='+')
+
+ args = parser.parse_args(argv)
+
+ if args.repo is None:
+ fatal("--repo must be specified")
+
+ for arg in args.artifacts:
+ basename = os.path.basename(arg)
+ match = artifact_re.match(basename)
+ if match is None:
+ fatal("Invalid artifact name: %s" % (arg, ))
+ 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)
+
+ run_sync(['ostree', '--repo=' + args.repo,
+ '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])
+
+builtins.register(OstbuildCommitArtifacts)
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 5cd5587..84f8e11 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -22,8 +22,9 @@ import sys
import argparse
from . import builtins
-from . import builtin_compile_one
from . import builtin_autodiscover_meta
+from . import builtin_commit_artifacts
+from . import builtin_compile_one
def usage(ecode):
print "Builtins:"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]