]> gitweb.factorcode.org Git - factor.git/commitdiff
shell.nix: make wrapFactor helper idempotent
authortimor <timor.dd@googlemail.com>
Sat, 21 Nov 2020 16:48:36 +0000 (17:48 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Feb 2021 16:58:30 +0000 (08:58 -0800)
Detects if it was already wrapped, so it re-wraps correctly now.

shell.nix

index 6f729fd156c87ad9e01b5ab095253dbd20bc7a3f..83c3743c9c95f1a3ad57b26cf4e3ff31a535c9b0 100644 (file)
--- a/shell.nix
+++ b/shell.nix
@@ -35,6 +35,11 @@ in
     [ -n "$1" ] || { printf "Usage: wrapFactor <factor-root>" ; return; }
     local root="$(realpath $1)"
     local binary="''${root}/factor"
+    local wrapped="''${root}/.factor-wrapped"
+    # Remove the wrapped binary if a new VM has been compiled
+    ${lib.getBin file}/bin/file $binary |grep ELF >/dev/null && rm -f "$wrapped"
+    # Restore the factor binary if it was already wrapped
+    [ -e "$wrapped" ] && { mv "$wrapped" "$binary" ; }
     wrapProgram "$binary" --prefix LD_LIBRARY_PATH : ${runtimeLibPath} \
       --argv0 factor
     ln -sf "''${root}/factor.image" "''${root}/.factor-wrapped.image"