diff options
author | Rob Landley <rob@landley.net> | 2016-03-23 03:25:37 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-03-23 03:25:37 -0500 |
commit | a8d0d13376251e1ff35a557dddea1d2e3c81a149 (patch) | |
tree | 91ac62baa71572bbd900222ad99338778557e167 /scripts/install.sh | |
parent | c23186d3ee6001b78c843fc3609575306c687ba2 (diff) | |
download | toybox-a8d0d13376251e1ff35a557dddea1d2e3c81a149.tar.gz |
Redo build stuff in response to Andy Chu's suggestions.
Toybox single binaries are now made directly with the new name instead of
stomping toybox and getting renamed.
Unstripped files now live in generated/unstripped.
Target to run all tests is now "make tests" to avoid conflict with "make test".
.singleconfig now has .PHONY: entries for all test_$NAME targets.
Default install location changed to /usr/toybox, code.html now says how
to change it (set $PREFIX).
scripts/install.sh --uninstall works now. (And you get to keep the pieces!)
Diffstat (limited to 'scripts/install.sh')
-rwxr-xr-x | scripts/install.sh | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/scripts/install.sh b/scripts/install.sh index 8891a314..961341e6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,31 +4,24 @@ source ./configure -# Parse command line arguments. +[ -z "$PREFIX" ] && PREFIX="/usr/toybox" -[ -z "$PREFIX" ] && PREFIX="." +# Parse command line arguments. LONG_PATH="" while [ ! -z "$1" ] do # Create symlinks instead of hardlinks? - [ "$1" == "--symlink" ] && LINK_TYPE="-s" # Uninstall? - - [ "$1" == "--uninstall" ] && UNINSTALL=1 + [ "$1" == "--uninstall" ] && UNINSTALL=Uninstall # Delete destination command if it exists? - [ "$1" == "--force" ] && DO_FORCE="-f" # Use {,usr}/{bin,sbin} paths instead of all files in one directory? - - if [ "$1" == "--long" ] - then - LONG_PATH="bin/" - fi + [ "$1" == "--long" ] && LONG_PATH="bin/" shift done @@ -38,22 +31,24 @@ echo "Compile instlist..." $DEBUG $HOSTCC -I . scripts/install.c -o generated/instlist || exit 1 COMMANDS="$(generated/instlist $LONG_PATH)" -echo "Install commands..." +echo "${UNINSTALL:-Install} commands..." # Copy toybox itself if [ -z "$UNINSTALL" ] then - mkdir -p ${PREFIX}/${LONG_PATH} || exit 1 + mkdir -p "${PREFIX}/${LONG_PATH}" && + rm -f "${PREFIX}/${LONG_PATH}/toybox" && cp toybox ${PREFIX}/${LONG_PATH} || exit 1 else - rm "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null - rmdir "${PREFIX}/${LONG_PATH}" 2>/dev/null + rm -f "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null fi -cd "${PREFIX}" +cd "$PREFIX" || exit 1 # Make links to toybox +EXIT=0 + for i in $COMMANDS do # Figure out target of link @@ -64,20 +59,19 @@ do else # Create subdirectory for command to go in (if necessary) - DOTPATH="$(echo $i | sed 's@\(.*/\).*@\1@')" + DOTPATH="$(dirname "$i")"/ if [ -z "$UNINSTALL" ] then mkdir -p "$DOTPATH" || exit 1 - else - rmdir "$DOTPATH" 2>/dev/null fi if [ -z "$LINK_TYPE" ] then - dotpath="bin/" + DOTPATH="bin/" else if [ "$DOTPATH" != "$LONG_PATH" ] then + # For symlinks we need ../../bin style relative paths DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH else DOTPATH="" @@ -86,7 +80,12 @@ do fi # Create link - [ -z "$UNINSTALL" ] && - ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i || - rm $i 2>/dev/null + if [ -z "$UNINSTALL" ] + then + ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i || EXIT=1 + else + rm -f $i || EXIT=1 + fi done + +exit $EXIT |