Configurable temp dir.
[cdist.git] / cdist
diff --git a/cdist b/cdist
index c9f15a0c79637afe9942ab79ad40a8d3009b2f82..68ff4172da7f51efe6ea37046076d7eef4f796d4 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -35,8 +35,6 @@ import sys
 import tempfile
 import time
 
-TEMPORARY_DIRECTORY = '/var/tmp'
-
 class Error(Exception):
     def __init__(self, value):
         self.value = value
@@ -122,7 +120,8 @@ class Config:
                          BoolOption('docker_no_user'),
                          Option('docker_hub_repository'),
                          Option('flatpak_state_dir'),
-                         Option('parallel', multiprocessing.cpu_count()) ]
+                         Option('parallel', multiprocessing.cpu_count()),
+                         Option('temp', '/var/tmp')]
 
         config_dir = '%s/.config' % os.path.expanduser('~')
         if not os.path.exists(config_dir):
@@ -257,11 +256,11 @@ def rmtree(a):
 def command(c):
     log_normal(c)
     try:
-        r = subprocess.run(shlex.split(c))
+        r = subprocess.run(c, shell=True)
         if r.returncode != 0:
-            raise Error(f'command {c} failed ({r.returncode})')
+            raise Error('command %s failed (%d)' % (c, r.returncode))
     except Exception as e:
-        raise Error(f'command {c} failed ({e})')
+        raise Error('command %s failed (%s)' % (c, e))
 
 def command_and_read(c):
     log_normal(c)
@@ -414,7 +413,7 @@ class Target(object):
         self.build_dependencies = True
 
         if directory is None:
-            self.directory = tempfile.mkdtemp('', 'tmp', TEMPORARY_DIRECTORY)
+            self.directory = tempfile.mkdtemp('', 'tmp', config.get('temp'))
             self.rmdir = True
             self.set('CCACHE_BASEDIR', os.path.realpath(self.directory))
             self.set('CCACHE_NOHASHDIR', '')
@@ -755,6 +754,9 @@ def notarize(dmg, bundle_id):
         elif status == 'success':
             subprocess.run(['xcrun', 'stapler', 'staple', dmg])
             return
+        elif status != "in progress":
+            print("Could not understand xcrun response")
+            print(p)
         time.sleep(30)
 
     raise Error("Notarization timed out")