#!/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 os = `uname if (~ $os 'Linux') { execarg = (-executable) } else if (~ $os 'OpenBSD') { execarg = (-perm 0755) } else { echo unsupported os: $os >[1=2] exit 1 } scripts = `$nl{find . $execarg -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