From d8eebaa2d1935aa19d6d683cac5f7c5868876769 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 28 Feb 2012 06:40:35 -0500 Subject: [PATCH] ostbuild: Pull patches from specified patches git repository We need to be more formal about where we get patches from, and more specifically what version. Let's assume they're also stored in a git repository that we fetch, instead of copying them from "wherever the manifest is". This meshes nicely with splitting between manifest.json and snapshot.json. --- gnomeos/3.4/manifest.json | 3 ++- src/ostbuild/pyostbuild/builtin_build.py | 14 +++++++++++++- src/ostbuild/pyostbuild/builtin_resolve.py | 15 +-------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gnomeos/3.4/manifest.json b/gnomeos/3.4/manifest.json index 2deb3e92..5a4b4ab9 100644 --- a/gnomeos/3.4/manifest.json +++ b/gnomeos/3.4/manifest.json @@ -23,7 +23,8 @@ "netfilter": "git:git://git.netfilter.org/", "cgwalters": "git:git://github.com/cgwalters/"}, - "patches": {"src": "gnome:ostree"}, + "patches": {"src": "gnome:ostree", + "prefix": "gnomeos/3.4"}, "components": [ {"src": "cgwalters:ginitscripts"}, diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py index de045fdb..40aad797 100755 --- a/src/ostbuild/pyostbuild/builtin_build.py +++ b/src/ostbuild/pyostbuild/builtin_build.py @@ -140,8 +140,20 @@ class OstbuildBuild(builtins.Builtin): 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(self.patchdir, patch) + patch_path = os.path.join(patchdir, patch) run_sync(['git', 'am', '--ignore-date', '-3', patch_path], cwd=component_src) logdir = os.path.join(self.workdir, 'logs', 'compile', name) diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py index 224f1a27..0faa1fd5 100755 --- a/src/ostbuild/pyostbuild/builtin_resolve.py +++ b/src/ostbuild/pyostbuild/builtin_resolve.py @@ -210,23 +210,10 @@ class OstbuildResolve(builtins.Builtin): self.manifest['components'] = self.resolved_components out_snapshot = os.path.join(self.workdir, 'snapshot.json') - patchdir = os.path.join(self.workdir, 'patches') - if not os.path.isdir(patchdir): - os.mkdir(patchdir) - all_patches = {} - for component in self.resolved_components: - patches = component.get('patches', []) - for patch in patches: - all_patches[patch] = True - for patch in all_patches: - src = os.path.join(os.path.dirname(manifest_path), - patch) - dest = os.path.join(patchdir, patch) - shutil.copy(src, dest) f = open(out_snapshot, 'w') json.dump(self.manifest, f, indent=4, sort_keys=True) f.close() - print "Created: %s, %d patches" % (out_snapshot, len(all_patches.keys())) + print "Created: %s" % (out_snapshot, ) builtins.register(OstbuildResolve)