Clenup code of fetching dist conf from obs
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 14 May 2012 10:25:01 +0000 (18:25 +0800)
committerEd Bartosh <eduard.bartosh@intel.com>
Wed, 16 May 2012 15:52:53 +0000 (18:52 +0300)
Change-Id: I855049823f247f99067a5ce3fe79391c65f5968a

gitbuildsys/cmd_build.py

index 45dc453372f81ed679fe3a7ef6a96c47d1a5505e..e15a5988c04b407446c5f60576c23e057061b148 100644 (file)
@@ -20,7 +20,6 @@
 """
 
 import os
-import tempfile
 import glob
 import subprocess
 import urlparse
@@ -67,27 +66,10 @@ supportedarchs = [
             'armv7l',
           ]
 
-OSCRC_TEMPLATE = """[general]
-apiurl = %(apiurl)s
-plaintext_passwd=0
-use_keyring=0
-http_debug = %(http_debug)s
-debug = %(debug)s
-gnome_keyring=0
-[%(apiurl)s]
-user=%(user)s
-passx=%(passwdx)s
-"""
-
-APISERVER   = configmgr.get('build_server', 'build')
-USER        = configmgr.get('user', 'build')
-PASSWDX     = configmgr.get('passwdx', 'build')
-TMPDIR      = configmgr.get('tmpdir')
-
 def do(opts, args):
 
     if os.geteuid() != 0:
-        msger.error('Root permission is required, please use sudo and try again')
+        msger.error('Root permission is required, please try again with sudo')
 
     workdir = os.getcwd()
     if len(args) > 1:
@@ -115,57 +97,10 @@ def do(opts, args):
         msger.warning('multiple specfiles found.')
 
 
-    tmpdir = '%s/%s' % (TMPDIR, USER)
-    if not os.path.exists(tmpdir):
-        os.makedirs(tmpdir)
-
-    oscrc = OSCRC_TEMPLATE % {
-                "http_debug": 1 if msger.get_loglevel() == 'debug' else 0,
-                "debug": 1 if msger.get_loglevel() == 'verbose' else 0,
-                "apiurl": APISERVER,
-                "user": USER,
-                "passwdx": PASSWDX,
-            }
-    (fd, oscrcpath) = tempfile.mkstemp(dir=tmpdir,prefix='.oscrc')
-    os.close(fd)
-    f = file(oscrcpath, 'w+')
-    f.write(oscrc)
-    f.close()
-
     distconf = configmgr.get('distconf', 'localbuild')
     if opts.dist:
         distconf = opts.dist
 
-    # get dist build config info from OBS prject.
-    bc_filename = None
-    if distconf is None:
-        msger.error('no dist config specified, see: gbs localbuild -h.')
-        """
-        msger.info('get build config file from OBS server')
-        bc_filename = '%s/%s.conf' % (tmpdir, name)
-        bs = buildservice.BuildService(apiurl=APISERVER, oscrc=oscrcpath)
-        prj = 'Trunk'
-        arch = None
-        for repo in bs.get_repos(prj):
-            archs = bs.get_ArchitectureList(prj, repo.name)
-            if buildarch in obsarchmap and obsarchmap[buildarch] in archs:
-                arch = obsarchmap[buildarch]
-                break
-            for a in archs:
-                if msger.ask('Get build conf from %s/%s, OK? '\
-                             % (repo.name, a)):
-                    arch = a
-        if arch is None:
-            msger.error('target arch is not correct, please check.')
-
-        bc = bs.get_buildconfig('Trunk', arch)
-        bc_file = open(bc_filename, 'w')
-        bc_file.write(bc)
-        bc_file.flush()
-        bc_file.close()
-        distconf = bc_filename
-        """
-
     build_cmd  = configmgr.get('build_cmd', 'localbuild')
     build_root = configmgr.get('build_root', 'localbuild')
     if opts.buildroot:
@@ -195,13 +130,13 @@ def do(opts, args):
     cmd += [specfile]
 
     if hostarch != buildarch and buildarch in change_personality:
-        cmd = [ change_personality[buildarch] ] + cmd;
+        cmd = [ change_personality[buildarch] ] + cmd
 
     if buildarch.startswith('arm'):
         try:
             utils.setup_qemu_emulator()
-        except errors.QemuError, e:
-            msger.error('%s' % e)
+        except errors.QemuError, exc:
+            msger.error('%s' % exc)
 
     spec = rpm.parse_spec(specfile)
     if not spec.name or not spec.version:
@@ -218,15 +153,16 @@ def do(opts, args):
 
     try:
         comp_type = guess_comp_type(spec)
-        if not git_archive(repo, spec, "%s/packaging" % workdir, 'HEAD', comp_type,
-                           comp_level=9, with_submodules=True):
+        if not git_archive(repo, spec, "%s/packaging" % workdir, 'HEAD',
+                           comp_type, comp_level=9, with_submodules=True):
             msger.error("Cannot create source tarball %s" % tarball)
     except GbpError, exc:
         msger.error(str(exc))
  
     if opts.incremental:
         cmd += ['--rsync-src=%s' % os.path.abspath(workdir)]
-        cmd += ['--rsync-dest=/home/abuild/rpmbuild/BUILD/%s-%s' % (name, version)]
+        cmd += ['--rsync-dest=/home/abuild/rpmbuild/BUILD/%s-%s' % \
+                (spec.name, spec.version)]
 
     msger.info(' '.join(cmd))
 
@@ -244,6 +180,3 @@ def do(opts, args):
         msger.error('interrrupt from keyboard')
     finally:
         os.unlink("%s/%s" % (workdir, tarball))
-        os.unlink(oscrcpath)
-        if bc_filename:
-            os.unlink(bc_filename)