vasabi: samba-build: use ensure_dir_exists for bld_dir_bin
authorMichael Adam <obnox@samba.org>
Mon, 20 Apr 2015 09:39:19 +0000 (11:39 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 20 Apr 2015 09:42:02 +0000 (11:42 +0200)
and systematize copy_bindir case

Signed-off-by: Michael Adam <obnox@samba.org>
script/samba-build.py

index edd6362c7d99af3e5f30589a90a039a46a0e99b5..35d2ecf8da1c0597a5b69878aff3834cd63ee09d 100755 (executable)
@@ -289,11 +289,6 @@ def setup_env():
         print "cmd: '%s'" % ' '.join(cmd)
     subprocess.check_call(cmd)
 
-    # Only keep the old bindir copy in the bld dir if we
-    # are to copy (not symlink) the contents and reuse it.
-    if not options.do_reuse_bindir or not options.do_copy_bindir:
-        rm_rf(bld_dir_bin)
-
     print "Symlinking contents of src dir '%s' into bld dir '%s'." % (
             options.srcdir, options.blddir)
 
@@ -313,6 +308,9 @@ def setup_env():
     subprocess.check_call(cmd)
 
     if options.do_copy_bindir:
+        ensure_dir_exists(bld_dir_bin, keep=options.do_reuse_bindir,
+                          backup=False)
+
         print "Copying '%s' into '%s'." % (src_dir_bin, options.blddir)
         cmd = [ "rsync",
                 "-aSH",
@@ -321,12 +319,19 @@ def setup_env():
                 src_dir_bin, options.blddir ]
         if options.verbose:
             print "cmd: '%s'" % ' '.join(cmd)
+        subprocess.check_call(cmd)
 
     else:
+        # symlinking would remove the need to copy results back and forth.
+        # but this is not yet usable right now.
+        rm_rf(bld_dir_bin)
+
         print "Symlinking '%s' into '%s'." % (src_dir_bin, options.blddir)
         cmd = [ "ln", "-sf", src_dir_bin, options.blddir ]
+        if options.verbose:
+            print "cmd: '%s'" % ' '.join(cmd)
+        subprocess.check_call(cmd)
 
-    subprocess.check_call(cmd)
     rm_rf("%s/bin" % options.blddir)
 
     cmd = [ "ln", "-sf", options.bindir, "%s/bin" % options.blddir ]