ostbuild: Various cleanups

This commit is contained in:
Colin Walters 2012-01-18 17:38:31 -05:00
parent e83a7fa46b
commit 660ff7422f
2 changed files with 10 additions and 8 deletions

View File

@ -48,14 +48,17 @@ class OstbuildBuild(builtins.Builtin):
def _fixup_submodule_references(self, cwd): def _fixup_submodule_references(self, cwd):
submodules_status_text = run_sync_get_output(['git', 'submodule', 'status'], cwd=cwd) submodules_status_text = run_sync_get_output(['git', 'submodule', 'status'], cwd=cwd)
submodule_status_lines = submodules_status_text.split('\n') submodule_status_lines = submodules_status_text.split('\n')
have_submodules = False
for line in submodule_status_lines: for line in submodule_status_lines:
if line == '': continue if line == '': continue
have_submodules = True
line = line[1:] line = line[1:]
(sub_checksum, sub_name) = line.split(' ', 1) (sub_checksum, sub_name) = line.split(' ', 1)
sub_url = run_sync_get_output(['git', 'config', '-f', '.gitmodules', sub_url = run_sync_get_output(['git', 'config', '-f', '.gitmodules',
'submodule.%s.url' % (sub_name, )], cwd=cwd) 'submodule.%s.url' % (sub_name, )], cwd=cwd)
mirrordir = self._mirror_for_url(sub_url) mirrordir = self._mirror_for_url(sub_url)
run_sync(['git', 'config', 'submodule.%s.url' % (sub_name, ), 'file://' + mirrordir], cwd=cwd) run_sync(['git', 'config', 'submodule.%s.url' % (sub_name, ), 'file://' + mirrordir], cwd=cwd)
return have_submodules
def _get_vcs_checkout(self, name, keytype, mirrordir, branch): def _get_vcs_checkout(self, name, keytype, mirrordir, branch):
checkoutdir = os.path.join(self.workdir, 'src') checkoutdir = os.path.join(self.workdir, 'src')
@ -75,10 +78,11 @@ class OstbuildBuild(builtins.Builtin):
'--no-checkout', mirrordir, tmp_dest]) '--no-checkout', mirrordir, 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)
self._fixup_submodule_references(tmp_dest) have_submodules = self._fixup_submodule_references(tmp_dest)
run_sync(['linux-user-chroot', if have_submodules:
'--unshare-net', '--chdir', tmp_dest, '/', run_sync(['linux-user-chroot',
'/usr/bin/git', 'submodule', 'update']) '--unshare-net', '--chdir', tmp_dest, '/',
'/usr/bin/git', 'submodule', 'update'])
os.rename(tmp_dest, dest) os.rename(tmp_dest, dest)
return dest return dest

View File

@ -65,7 +65,7 @@ class OstbuildResolve(builtins.Builtin):
parent = os.path.dirname(tmp_checkout) parent = os.path.dirname(tmp_checkout)
if not os.path.isdir(parent): if not os.path.isdir(parent):
os.makedirs(parent) os.makedirs(parent)
run_sync(['git', 'clone', '-b', branch, mirror, tmp_checkout]) run_sync(['git', 'clone', '-q', '--no-checkout', mirror, tmp_checkout])
run_sync(['git', 'checkout', '-q', '-f', current_vcs_version], cwd=tmp_checkout) run_sync(['git', 'checkout', '-q', '-f', current_vcs_version], cwd=tmp_checkout)
submodules = [] submodules = []
submodules_status_text = run_sync_get_output(['git', 'submodule', 'status'], cwd=tmp_checkout) submodules_status_text = run_sync_get_output(['git', 'submodule', 'status'], cwd=tmp_checkout)
@ -164,10 +164,8 @@ class OstbuildResolve(builtins.Builtin):
(keytype, uri) = self._parse_src_key(component['src']) (keytype, uri) = self._parse_src_key(component['src'])
try: try:
fetch_components.index(component['name']) fetch_components.index(component['name'])
continue
except ValueError, e: except ValueError, e:
pass mirrordir = self._ensure_vcs_mirror(keytype, uri, component['branch'])
mirrordir = self._ensure_vcs_mirror(keytype, uri, component['branch'])
revision = buildutil.get_git_version_describe(mirrordir, revision = buildutil.get_git_version_describe(mirrordir,
component['branch']) component['branch'])
component['revision'] = revision component['revision'] = revision