[ostree/wip/ostbuild-chroot-dev: 9/10] ostbuild: 'checkout' command now also applies patches
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree/wip/ostbuild-chroot-dev: 9/10] ostbuild: 'checkout' command now also applies patches
- Date: Sat, 3 Mar 2012 17:42:41 +0000 (UTC)
commit 2d0900f84c45bd9f79641655a394403114e2d13f
Author: Colin Walters <walters verbum org>
Date: Fri Mar 2 06:51:53 2012 -0500
ostbuild: 'checkout' command now also applies patches
src/ostbuild/pyostbuild/builtin_build.py | 22 +---------------
src/ostbuild/pyostbuild/builtin_checkout.py | 35 ++++++++++++++++++++++----
src/ostbuild/pyostbuild/builtins.py | 1 +
src/ostbuild/pyostbuild/vcs.py | 9 ++++---
4 files changed, 37 insertions(+), 30 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index 40aad79..07bea39 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -137,24 +137,8 @@ class OstbuildBuild(builtins.Builtin):
f = open(metadata_path, 'w')
json.dump(artifact_meta, f)
f.close()
-
- patches = meta.get('patches')
- if patches is not None:
- patches_meta = self.manifest['patches']
- (patches_keytype, patches_uri) = buildutil.parse_src_key(patches_meta['src'])
- patches_mirror = buildutil.get_mirrordir(self.mirrordir, patches_keytype, patches_uri)
- vcs.get_vcs_checkout(self.mirrordir, patches_keytype, patches_uri,
- self.patchdir, patches_meta['branch'],
- overwrite=True)
-
- patch_prefix = patches_meta.get('prefix', None)
- if patch_prefix is not None:
- patchdir = os.path.join(self.patchdir, patch_prefix)
- else:
- patchdir = self.patchdir
- for patch in patches:
- patch_path = os.path.join(patchdir, patch)
- run_sync(['git', 'am', '--ignore-date', '-3', patch_path], cwd=component_src)
+
+ run_sync(['ostbuild', 'checkout', name], cwd=checkoutdir)
logdir = os.path.join(self.workdir, 'logs', 'compile', name)
old_logdir = os.path.join(self.workdir, 'old-logs', 'compile', name)
@@ -243,8 +227,6 @@ class OstbuildBuild(builtins.Builtin):
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
self.manifest = json.load(open(build_manifest_path))
- self.patchdir = os.path.join(self.workdir, 'patches')
-
components = self.manifest['components']
if args.recompose:
build_components = []
diff --git a/src/ostbuild/pyostbuild/builtin_checkout.py b/src/ostbuild/pyostbuild/builtin_checkout.py
index 3aa4c50..9600abb 100755
--- a/src/ostbuild/pyostbuild/builtin_checkout.py
+++ b/src/ostbuild/pyostbuild/builtin_checkout.py
@@ -48,19 +48,42 @@ class OstbuildCheckout(builtins.Builtin):
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
self.manifest = json.load(open(build_manifest_path))
- for component_name in args.components:
+ if len(args.components) > 0:
+ checkout_components = args.components
+ else:
+ checkout_components = [os.path.basename(os.getcwd())]
+
+ for component_name in checkout_components:
found = False
- for component in self.manifest['components']:
- if component['name'] == component_name:
- found = True
- break
- if not found:
+ component = buildutil.find_component_in_manifest(self.manifest,
+ component_name)
+ if component is None:
fatal("Unknown component %r" % (component_name, ))
(keytype, uri) = buildutil.parse_src_key(component['src'])
checkoutdir = os.path.join(os.getcwd(), component['name'])
+
component_src = vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
component['revision'],
overwrite=False)
+
+ patches = component.get('patches')
+ if patches is not None:
+ patches_meta = self.manifest['patches']
+ (patches_keytype, patches_uri) = buildutil.parse_src_key(patches_meta['src'])
+ patches_mirror = buildutil.get_mirrordir(self.mirrordir, patches_keytype, patches_uri)
+ vcs.get_vcs_checkout(self.mirrordir, patches_keytype, patches_uri,
+ self.patchdir, patches_meta['branch'],
+ overwrite=True)
+
+ patch_prefix = patches_meta.get('prefix', None)
+ if patch_prefix is not None:
+ patchdir = os.path.join(self.patchdir, patch_prefix)
+ else:
+ patchdir = self.patchdir
+ for patch in patches:
+ patch_path = os.path.join(patchdir, patch)
+ run_sync(['git', 'am', '--ignore-date', '-3', patch_path], cwd=checkoutdir)
+
print "Checked out: %r" % (component_src, )
builtins.register(OstbuildCheckout)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index 4b5abe7..4a2baee 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -39,6 +39,7 @@ class Builtin(object):
self.workdir = ostbuildrc.get_key('workdir')
if not os.path.isdir(self.workdir):
fatal("Specified workdir '%s' is not a directory" % (self.workdir, ))
+ self.patchdir = os.path.join(self.workdir, 'patches')
def execute(self, args):
raise NotImplementedError()
diff --git a/src/ostbuild/pyostbuild/vcs.py b/src/ostbuild/pyostbuild/vcs.py
index 00d936d..2479d62 100755
--- a/src/ostbuild/pyostbuild/vcs.py
+++ b/src/ostbuild/pyostbuild/vcs.py
@@ -55,16 +55,17 @@ def get_vcs_checkout(mirrordir, keytype, uri, dest, branch, overwrite=True):
if overwrite:
shutil.rmtree(dest)
else:
- return dest
+ tmp_dest = dest
if not os.path.isdir(tmp_dest):
run_sync(['git', 'clone', '-q',
'--no-checkout', module_mirror, tmp_dest])
+ else:
+ run_sync(['git', 'fetch'], cwd=tmp_dest)
run_sync(['git', 'checkout', '-q', branch], cwd=tmp_dest)
run_sync(['git', 'submodule', 'init'], cwd=tmp_dest)
have_submodules = _fixup_submodule_references(mirrordir, tmp_dest)
if have_submodules:
run_sync(['git', 'submodule', 'update'], cwd=tmp_dest)
- os.rename(tmp_dest, dest)
+ if tmp_dest != dest:
+ os.rename(tmp_dest, dest)
return dest
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]