[ostree] ostbuild: In chroot build, reuse source directory basename



commit 835e0eae59494c1a1bb9c9ee4c0bec536561696f
Author: Colin Walters <walters verbum org>
Date:   Tue Dec 20 18:45:20 2011 -0500

    ostbuild: In chroot build, reuse source directory basename
    
    This ensures that the output artifacts are named correctly, and not
    "source".

 src/ostbuild/ostbuild-chroot-compile-one-impl |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/ostbuild/ostbuild-chroot-compile-one-impl b/src/ostbuild/ostbuild-chroot-compile-one-impl
index 5e25c34..b26c700 100755
--- a/src/ostbuild/ostbuild-chroot-compile-one-impl
+++ b/src/ostbuild/ostbuild-chroot-compile-one-impl
@@ -45,6 +45,8 @@ def log(m):
     sys.stdout.write('\n')
     sys.stdout.flush()
 
+basename = os.path.basename(os.getcwd())
+
 tmpdir = tempfile.mkdtemp(prefix='ostree-chroot-compile-')
 log("Using temporary directory: %s" % (tmpdir, ))
 
@@ -61,8 +63,11 @@ log("Checked out root: %s" % (rootdir, ))
 builddir = os.path.join(rootdir, 'ostbuild');
 os.mkdir(builddir)
 os.mkdir(os.path.join(builddir, 'source'))
+os.mkdir(os.path.join(builddir, 'source', basename))
 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
 # ostree install in e.g. ~/bin even though we're going to set PATH
 # 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-bind', '/dev', '/dev',
               '--mount-bind', child_tmpdir, '/tmp',
-              '--mount-bind', os.getcwd(), '/ostbuild/source',
+              '--mount-bind', os.getcwd(), chroot_sourcedir,
               '--mount-bind', args.resultdir, '/ostbuild/results',
               rootdir,
               '/bin/sh']
 if not args.debug_shell:
     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, ))
 subprocess.check_call(child_args, env=get_build_env())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]