Catch exception if buildconf specified in gbs conf doesn't exist
authorGuan Junchun <junchunx.guan@intel.com>
Fri, 11 Oct 2013 02:54:20 +0000 (10:54 +0800)
committerGuan Junchun <junchunx.guan@intel.com>
Fri, 11 Oct 2013 03:40:35 +0000 (11:40 +0800)
Fixes: #1339

Change-Id: I0a6d326753815703423de95e1c49490cded12e8c

gitbuildsys/cmd_build.py

index d6bd6de..b0edc6d 100644 (file)
@@ -133,20 +133,22 @@ def prepare_repos_and_build_conf(args, arch, profile):
     distconf = os.path.join(TMPDIR, '%s.conf' % profile_name)
 
     if args.dist:
-        if not os.path.exists(args.dist):
-            raise GbsError('specified build conf %s does not exist' % args.dist)
-        shutil.copy(args.dist, distconf)
+        buildconf = args.dist
     elif profile.buildconf:
-        shutil.copy(profile.buildconf, distconf)
+        buildconf = profile.buildconf
     else:
         if repoparser.buildconf is None:
             raise GbsError('failed to get build conf from repos, please '
                            'use snapshot repo or specify build config using '
                            '-D option')
         else:
-            shutil.copy(repoparser.buildconf, distconf)
+            buildconf = repoparser.buildconf
             log.info('build conf has been downloaded at:\n      %s' \
                        % distconf)
+    try:
+        shutil.copy(buildconf, distconf)
+    except IOError, err:
+        raise GbsError("Failed to copy build conf: %s" % (str(err)))
 
     if not os.path.exists(distconf):
         raise GbsError('No build config file specified, please specify in '\