ostbuild: chdir into source directory when launching debug shell

This commit is contained in:
Colin Walters 2012-01-20 17:52:08 -05:00
parent 9d645495ba
commit 1ca517f36f
2 changed files with 32 additions and 29 deletions

View File

@ -60,13 +60,15 @@ class OstbuildBuild(builtins.Builtin):
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, overwrite=True):
checkoutdir = os.path.join(self.workdir, 'src')
if not os.path.isdir(checkoutdir):
os.makedirs(checkoutdir)
dest = os.path.join(checkoutdir, name)
tmp_dest = dest + '.tmp'
if os.path.isdir(dest):
if not overwrite:
return dest
shutil.rmtree(dest)
if os.path.isdir(tmp_dest):
shutil.rmtree(tmp_dest)
@ -183,6 +185,14 @@ class OstbuildBuild(builtins.Builtin):
(keytype, uri) = self._parse_src_key(meta['src'])
mirror = self._mirror_for_url(uri)
component_src = self._get_vcs_checkout(name, keytype, mirror, branch,
overwrite=not self.args.debug_shell)
if self.args.debug_shell:
buildroot_version = self._compose_buildroot(buildroot_name, meta, dependencies, architecture)
self._launch_debug_shell(architecture, buildroot_name, cwd=component_src)
current_vcs_version = meta['revision']
previous_build_version = run_sync_get_output(['ostree', '--repo=' + self.repo,
@ -208,17 +218,13 @@ class OstbuildBuild(builtins.Builtin):
else:
log("No previous build for '%s' found" % (buildname, ))
mirror = self._mirror_for_url(uri)
component_src = self._get_vcs_checkout(name, keytype, mirror, branch)
buildroot_version = self._compose_buildroot(buildroot_name, meta, dependencies, architecture)
if meta.get('rm-configure', False):
configure_path = os.path.join(component_src, 'configure')
if os.path.exists(configure_path):
os.unlink(configure_path)
buildroot_version = self._compose_buildroot(buildroot_name, meta, dependencies, architecture)
artifact_meta = {'buildroot': buildroot_name,
'buildroot-version': buildroot_version,
'name': name,
@ -257,9 +263,6 @@ class OstbuildBuild(builtins.Builtin):
saved_name = '%s-%d.log' % (name, int(time.time()),)
os.rename(log_path, os.path.join(old_logdir, saved_name))
if self.args.debug_shell:
self._launch_debug_shell(architecture, buildroot_name, cwd=component_src)
else:
log("Logging to %s" % (log_path, ))
f = open(log_path, 'w')
chroot_args = self._get_ostbuild_chroot_args(architecture)

View File

@ -113,7 +113,8 @@ class OstbuildChrootCompileOne(builtins.Builtin):
'--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev',
'--mount-bind', child_tmpdir, '/tmp',
'--mount-bind', os.getcwd(), chroot_sourcedir]
'--mount-bind', os.getcwd(), chroot_sourcedir,
'--chdir', chroot_sourcedir]
if args.resultdir:
child_args.extend(['--mount-bind', args.resultdir, '/ostbuild/results'])
if args.debug_shell:
@ -121,7 +122,6 @@ class OstbuildChrootCompileOne(builtins.Builtin):
else:
child_args.extend([rootdir, '/usr/bin/ostbuild',
'compile-one',
'--chdir=' + chroot_sourcedir,
'--ostbuild-resultdir=/ostbuild/results',
'--ostbuild-meta=_ostbuild-meta'])
child_args.extend(rest_args)