Update chroot module
authorZhang Qiang <qiang.z.zhang@intel.com>
Wed, 19 Sep 2012 09:03:53 +0000 (17:03 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 19 Sep 2012 09:17:33 +0000 (17:17 +0800)
As depanneur is used to create build, and multiple build root will
be created if --threads=<> specified, so we remove -A option.
The build root should be specified while using gbs chroot, just as
chroot command.

Change-Id: I014e441f2ff206002595bd3acf54ff749ffcf353

gitbuildsys/cmd_chroot.py
tools/gbs

index 894fb59..e69dd90 100644 (file)
 """
 import os
 import subprocess
-import pwd
-
-from gitbuildsys import msger
-from gitbuildsys.conf import configmgr
-
-def do(opts, _args):
-
-    if opts.arch in ['ia32', 'i686', 'i586', 'i386']:
-        arch = 'i686'
-    else:
-        arch = opts.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)
+
+from gitbuildsys import msger, errors
+
+def do(opts, args):
+
+    if len(args) != 1:
+        raise errors.Usage('no build root directory specified')
+
+    build_root = os.path.abspath(args[0])
     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)
@@ -47,6 +38,7 @@ def do(opts, _args):
     if opts.root:
         user = 'root'
     cmd = ['sudo', 'chroot', build_root, 'su', user]
+
     try:
         subprocess.call(['sudo', 'cp', '/etc/resolv.conf', build_root + \
                          '/etc/resolv.conf'])
index b7b3db9..d97c6cb 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -198,7 +198,10 @@ class Gbs(cmdln.Cmdln):
     @cmdln.option('-B', '--buildroot',
                   default=None,
                   dest='buildroot',
-                  help='specify build root to setup chroot environment')
+                  help='specify build root to setup chroot environment. '\
+                       'By default, ~/GBS-ROOT/ will be used, and if no ' \
+                       '-B option, but TIZEN_BUILD_ROOT env exists, then '\
+                       '${TIZEN_BUILD_ROOT} will used as build root')
     @cmdln.option('-A', '--arch',
                   default=None,
                   dest='arch',
@@ -353,19 +356,15 @@ class Gbs(cmdln.Cmdln):
                   default=False,
                   dest='root',
                   help='chroot as root instead of abuild by default')
-    @cmdln.option('-A', '--arch',
-                  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
 
         Usage:
-            gbs chroot [options]
+            gbs chroot [options] <build root dir>
+
+        Note: The default location of build root located at:
+        ~/GBS-ROOT/local/scratch.{arch}.*, which will be different
+        if -B option specified while running gbs build
 
         ${cmd_option_list}
         """