Add --buildroot option for chroot to chroot specified dir
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 17 Sep 2012 02:15:16 +0000 (10:15 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 17 Sep 2012 03:57:27 +0000 (11:57 +0800)
Change-Id: I0d52fdec52a0e2e7f20207bd672d7f18400d0576

gitbuildsys/cmd_chroot.py
tools/gbs

index ad867e6eb2c0c7b9dc60d683705df22954a3a054..894fb591a1a44b2543cc65326904ec49a779ffd1 100644 (file)
@@ -20,6 +20,7 @@
 """
 import os
 import subprocess
+import pwd
 
 from gitbuildsys import msger
 from gitbuildsys.conf import configmgr
@@ -30,9 +31,13 @@ def do(opts, _args):
         arch = 'i686'
     else:
         arch = opts.arch
-    userid     = configmgr.get('user', 'remotebuild')
-    tmpdir     = configmgr.get('tmpdir', 'general')
-    build_root = os.path.join(tmpdir, userid, 'gbs-buildroot.%s' % arch)
+    if opts.buildroot:
+        build_root = opts.buildroot
+    else:
+        userid     = pwd.getpwuid(os.getuid())[0]
+        tmpdir = os.path.join(configmgr.get('tmpdir', 'general'), "%s-gbs" %\
+                              userid)
+        build_root = os.path.join(tmpdir, 'gbs-buildroot.%s' % arch)
     running_lock = '%s/not-ready' % build_root
     if os.path.exists(running_lock) or not os.path.exists(build_root):
         msger.error('build root %s is not ready' % build_root)
index f4da7e3da726ce3ae94d89fc3a1febe49d90c7ec..3e3a1e19666e34e06fa4c759876500c67f2a2eea 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -442,6 +442,10 @@ class Gbs(cmdln.Cmdln):
                   default='i586',
                   dest='arch',
                   help='specify the build root arch')
+    @cmdln.option('-B', '--buildroot',
+                  default=None,
+                  dest='buildroot',
+                  help='specify build root directory to chroot')
     def do_chroot(self, subcmd, opts, *args):
         """${cmd_name}: chroot to build root