ostbuild: In chroot build, reuse source directory basename

This ensures that the output artifacts are named correctly, and not
"source".
This commit is contained in:
Colin Walters 2011-12-20 18:45:20 -05:00
parent acca018e57
commit 835e0eae59
1 changed files with 7 additions and 2 deletions

View File

@ -45,6 +45,8 @@ def log(m):
sys.stdout.write('\n') sys.stdout.write('\n')
sys.stdout.flush() sys.stdout.flush()
basename = os.path.basename(os.getcwd())
tmpdir = tempfile.mkdtemp(prefix='ostree-chroot-compile-') tmpdir = tempfile.mkdtemp(prefix='ostree-chroot-compile-')
log("Using temporary directory: %s" % (tmpdir, )) log("Using temporary directory: %s" % (tmpdir, ))
@ -61,8 +63,11 @@ log("Checked out root: %s" % (rootdir, ))
builddir = os.path.join(rootdir, 'ostbuild'); builddir = os.path.join(rootdir, 'ostbuild');
os.mkdir(builddir) os.mkdir(builddir)
os.mkdir(os.path.join(builddir, 'source')) os.mkdir(os.path.join(builddir, 'source'))
os.mkdir(os.path.join(builddir, 'source', basename))
os.mkdir(os.path.join(builddir, 'results')) os.mkdir(os.path.join(builddir, 'results'))
chroot_sourcedir = os.path.join('/ostbuild', 'source', basename)
# We need to search PATH here manually so we correctly pick up an # We need to search PATH here manually so we correctly pick up an
# ostree install in e.g. ~/bin even though we're going to set PATH # ostree install in e.g. ~/bin even though we're going to set PATH
# below for our children inside the chroot. # below for our children inside the chroot.
@ -80,13 +85,13 @@ child_args = [ostbuild_user_chroot_path, '--unshare-pid', '--unshare-net', '--un
'--mount-proc', '/proc', '--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev', '--mount-bind', '/dev', '/dev',
'--mount-bind', child_tmpdir, '/tmp', '--mount-bind', child_tmpdir, '/tmp',
'--mount-bind', os.getcwd(), '/ostbuild/source', '--mount-bind', os.getcwd(), chroot_sourcedir,
'--mount-bind', args.resultdir, '/ostbuild/results', '--mount-bind', args.resultdir, '/ostbuild/results',
rootdir, rootdir,
'/bin/sh'] '/bin/sh']
if not args.debug_shell: if not args.debug_shell:
child_args += ['-c', child_args += ['-c',
'cd /ostbuild/source && ostbuild-compile-one-impl OSTBUILD_RESULTDIR=/ostbuild/results' 'cd "%s" && ostbuild-compile-one-impl OSTBUILD_RESULTDIR=/ostbuild/results' % (chroot_sourcedir, )
] ]
log("Running: %r" % (child_args, )) log("Running: %r" % (child_args, ))
subprocess.check_call(child_args, env=get_build_env()) subprocess.check_call(child_args, env=get_build_env())