From d4b49cd622779b1a478658d5046df281e16fd754 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 29 Aug 2019 02:02:05 -0400 Subject: [PATCH] Windows fixes for jpm. --- auxbin/jpm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/auxbin/jpm b/auxbin/jpm index 27c00536..a1668195 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -203,6 +203,15 @@ (unless (zero? res) (error (string "command exited with status " res)))) +(defn- shell2 + "Do a shell command, but don't assum 0 is the (only) passing exit code." + [pred & args] + (if (dyn :verbose) + (print ;(interpose " " args))) + (def res (os/execute args :p)) + (unless (pred res) + (error (string "command exited with status " res)))) + (defn rm "Remove a directory and all sub directories." [path] @@ -218,7 +227,11 @@ [src dest] (print "copying " src " to " dest "...") (if is-win - (shell "xcopy" src dest "/y" "/e") + (if (= (os/stat src :mode) :directory) + (let [dname (last (filter |(pos? (length $)) (string/split "/" src)))] + (shell2 |(< $ 9) "robocopy" "/MIR" "/COPY:DAT" "/NS" "/NS" "/NFL" "/NDL" "/NP" "/NJH" "/NJS" + src (string dest sep dname))) + (shell "xcopy" src dest "/y" "/e")) (shell "cp" "-rf" src dest))) # @@ -532,6 +545,7 @@ int main(int argc, const char **argv) { (unless f (print manifest " does not exist") (break)) (loop [line :iterate (:read f :line)] (def path ((string/split "\n" line) 0)) + (def path ((string/split "\r" path) 0)) (print "removing " path) (try (rm path) ([err] (unless (= err "No such file or directory") @@ -825,7 +839,7 @@ Flags are: [] (local-rule "test")) -(defn- uninstall +(defn- uninstall-cmd [&opt what] (if what (uninstall what) @@ -843,7 +857,7 @@ Flags are: "help" help "deps" deps "clear-cache" clear-cache - "uninstall" uninstall}) + "uninstall" uninstall-cmd}) (def- args (tuple/slice (dyn :args) 1)) (def- len (length args))