summaryrefslogtreecommitdiff
path: root/Makeinstall.rc
diff options
context:
space:
mode:
authorHayden Hamilton <hayden@hhvn.uk>2026-05-24 13:48:38 +0100
committerHayden Hamilton <hayden@hhvn.uk>2026-05-24 13:48:38 +0100
commit216202e2cdff9623f815ac998c1b865168ff1583 (patch)
tree6cda9109acde91e328348743b76fe816e185cdd4 /Makeinstall.rc
Tracked install/uninstall/clean of scripts
Diffstat (limited to 'Makeinstall.rc')
-rwxr-xr-xMakeinstall.rc52
1 files changed, 52 insertions, 0 deletions
diff --git a/Makeinstall.rc b/Makeinstall.rc
new file mode 100755
index 0000000..33c1cf9
--- /dev/null
+++ b/Makeinstall.rc
@@ -0,0 +1,52 @@
+#!/bin/rc
+
+# This script will install all executables in the current directory to $1
+# Directory structure is preserved
+# It stores a list of everything it has transferred / created
+
+bin = $1
+
+scripts = `$nl{find . -perm 0755 -type f ! -name 'Make*' | grep -v '/\.' | sed 's/^\.\///'}
+
+touch .installed .dirsmade
+installed = `$nl{cat .installed}
+dirsmade = `$nl{cat .dirsmade}
+
+# Stores lists before exiting.
+# This is the last step regardless of success
+fn sigexit {
+ {for (s in $installed) { echo $s }} > .installed
+ {for (d in $dirsmade) { echo $d }} > .dirsmade
+}
+
+for (s in $scripts) {
+ d = `$nl{dirname $s}
+ if (!~ $d '.') {
+ # could use mkdir -p here, however in order to actually keep a
+ # list of what's been made, use a for loop
+
+ p = $bin
+ for (e in `($nl '/'){echo $d}) {
+ p = $p/$e
+ if (!test -d $p) {
+ echo MKDIR $p
+ mkdir $p || exit 1
+
+ # add to list if not already present
+ if (!~ $d $dirsmade) {
+ dirsmade = ($dirsmade $d)
+ }
+ }
+ }
+ }
+
+ if (!cmp -s $s $bin/$s) {
+ echo CP $s $bin/$s
+ cp $s $bin/$s
+ if (!~ $s $installed) {
+ installed = ($installed $s)
+ }
+ }
+}
+
+echo everything up to date