diff options
| author | 2020-06-14 14:04:23 -0500 | |
|---|---|---|
| committer | 2020-06-14 14:04:23 -0500 | |
| commit | 853b33b67caca3607d40e301a054d8bbecd26c1d (patch) | |
| tree | 7016618a95e3219b0294fa1afed47b47af6ba1ce /tools | |
| parent | Update for 1.10.0. (diff) | |
On nix platforms, patch jpm with path information.
This means we no longer need to guess paths after install.
Custom directory layouts can now be better supported at install
time without need for environment variables.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/patch-jpm.janet | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/patch-jpm.janet b/tools/patch-jpm.janet new file mode 100644 index 00000000..741280fd --- /dev/null +++ b/tools/patch-jpm.janet @@ -0,0 +1,33 @@ +# Patch jpm to have the correct paths for the current install. +# usage: janet patch-jpm.janet output --libdir=/usr/local/lib/x64-linux/ --binpath + +(def- argpeg + (peg/compile + '(* "--" '(to "=") "=" '(any 1)))) + +(def- args (tuple/slice (dyn :args) 3)) +(def- len (length args)) +(var i :private 0) + +(def install-paths @{}) + +# Get flags +(each a args + (if-let [m (peg/match argpeg a)] + (let [[key value] m] + (put install-paths (keyword key) value)))) + +(def- replace-peg + (peg/compile + ~(% (* '(to "###START###") + (constant ,(string/format "# Inserted by tools/patch-jpm.janet\n(def install-paths %j)" install-paths)) + (thru "###END###") + '(any 1))))) + +(def source (slurp ((dyn :args) 1))) +(def newsource (0 (peg/match replace-peg source))) + +(spit ((dyn :args) 2) newsource) + +(unless (= :windows (os/which)) + (os/shell (string `chmod +x "` ((dyn :args) 2) `"`))) |
