Only check permission if outdir exists
authorZhang Qiang <qiang.z.zhang@intel.com>
Wed, 16 Jan 2013 06:53:18 +0000 (14:53 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Thu, 17 Jan 2013 05:37:56 +0000 (13:37 +0800)
- raise error if make dir fails
- only check permission of outdir if outdir exists

Change-Id: Id86dee7093d38bf8861d88bcf299cb902fac6da2

gitbuildsys/cmd_export.py

index b2721b3..dc3bf12 100644 (file)
@@ -46,7 +46,7 @@ def mkdir_p(path):
         if exc.errno == errno.EEXIST:
             pass
         else:
-            raise
+            raise GbsError('failed to create %s: %s' % (path, exc.strerror))
 
 def is_native_pkg(repo, args):
     """
@@ -248,10 +248,12 @@ def main(args):
     else:
         outdir = os.path.join(workdir, packaging_dir)
     outdir = os.path.abspath(outdir)
-    if not os.access(outdir, os.W_OK|os.X_OK):
-        raise GbsError('no write permission to outdir: %s' % outdir)
+    if os.path.exists(outdir):
+        if not os.access(outdir, os.W_OK|os.X_OK):
+            raise GbsError('no write permission to outdir: %s' % outdir)
+    else:
+        mkdir_p(outdir)
 
-    mkdir_p(outdir)
     tmpdir     = configmgr.get('tmpdir', 'general')
     tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), \
                        directory=True)