ostbuild: 'checkout' command now also applies patches
This commit is contained in:
parent
d8eebaa2d1
commit
c3debe0fb6
|
|
@ -137,24 +137,8 @@ class OstbuildBuild(builtins.Builtin):
|
||||||
f = open(metadata_path, 'w')
|
f = open(metadata_path, 'w')
|
||||||
json.dump(artifact_meta, f)
|
json.dump(artifact_meta, f)
|
||||||
f.close()
|
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)
|
run_sync(['ostbuild', 'checkout', name], cwd=checkoutdir)
|
||||||
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)
|
|
||||||
|
|
||||||
logdir = os.path.join(self.workdir, 'logs', 'compile', name)
|
logdir = os.path.join(self.workdir, 'logs', 'compile', name)
|
||||||
old_logdir = os.path.join(self.workdir, 'old-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')
|
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
||||||
self.manifest = json.load(open(build_manifest_path))
|
self.manifest = json.load(open(build_manifest_path))
|
||||||
|
|
||||||
self.patchdir = os.path.join(self.workdir, 'patches')
|
|
||||||
|
|
||||||
components = self.manifest['components']
|
components = self.manifest['components']
|
||||||
if args.recompose:
|
if args.recompose:
|
||||||
build_components = []
|
build_components = []
|
||||||
|
|
|
||||||
|
|
@ -48,19 +48,42 @@ class OstbuildCheckout(builtins.Builtin):
|
||||||
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
build_manifest_path = os.path.join(self.workdir, 'snapshot.json')
|
||||||
self.manifest = json.load(open(build_manifest_path))
|
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
|
found = False
|
||||||
for component in self.manifest['components']:
|
component = buildutil.find_component_in_manifest(self.manifest,
|
||||||
if component['name'] == component_name:
|
component_name)
|
||||||
found = True
|
if component is None:
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
fatal("Unknown component %r" % (component_name, ))
|
fatal("Unknown component %r" % (component_name, ))
|
||||||
(keytype, uri) = buildutil.parse_src_key(component['src'])
|
(keytype, uri) = buildutil.parse_src_key(component['src'])
|
||||||
checkoutdir = os.path.join(os.getcwd(), component['name'])
|
checkoutdir = os.path.join(os.getcwd(), component['name'])
|
||||||
|
|
||||||
component_src = vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
|
component_src = vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
|
||||||
component['revision'],
|
component['revision'],
|
||||||
overwrite=False)
|
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, )
|
print "Checked out: %r" % (component_src, )
|
||||||
|
|
||||||
builtins.register(OstbuildCheckout)
|
builtins.register(OstbuildCheckout)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class Builtin(object):
|
||||||
self.workdir = ostbuildrc.get_key('workdir')
|
self.workdir = ostbuildrc.get_key('workdir')
|
||||||
if not os.path.isdir(self.workdir):
|
if not os.path.isdir(self.workdir):
|
||||||
fatal("Specified workdir '%s' is not a directory" % (self.workdir, ))
|
fatal("Specified workdir '%s' is not a directory" % (self.workdir, ))
|
||||||
|
self.patchdir = os.path.join(self.workdir, 'patches')
|
||||||
|
|
||||||
def execute(self, args):
|
def execute(self, args):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -55,16 +55,17 @@ def get_vcs_checkout(mirrordir, keytype, uri, dest, branch, overwrite=True):
|
||||||
if overwrite:
|
if overwrite:
|
||||||
shutil.rmtree(dest)
|
shutil.rmtree(dest)
|
||||||
else:
|
else:
|
||||||
return dest
|
tmp_dest = dest
|
||||||
if not os.path.isdir(tmp_dest):
|
if not os.path.isdir(tmp_dest):
|
||||||
run_sync(['git', 'clone', '-q',
|
run_sync(['git', 'clone', '-q',
|
||||||
'--no-checkout', module_mirror, tmp_dest])
|
'--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', 'checkout', '-q', branch], cwd=tmp_dest)
|
||||||
run_sync(['git', 'submodule', 'init'], cwd=tmp_dest)
|
run_sync(['git', 'submodule', 'init'], cwd=tmp_dest)
|
||||||
have_submodules = _fixup_submodule_references(mirrordir, tmp_dest)
|
have_submodules = _fixup_submodule_references(mirrordir, tmp_dest)
|
||||||
if have_submodules:
|
if have_submodules:
|
||||||
run_sync(['git', 'submodule', 'update'], cwd=tmp_dest)
|
run_sync(['git', 'submodule', 'update'], cwd=tmp_dest)
|
||||||
os.rename(tmp_dest, dest)
|
if tmp_dest != dest:
|
||||||
|
os.rename(tmp_dest, dest)
|
||||||
return dest
|
return dest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue