diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2023-08-31 12:46:32 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2023-08-31 14:00:59 -0500 |
commit | 00efd0abc49d1e3e6ae490a41c3504921735f425 (patch) | |
tree | 767900de32344f3ac854680614736e4ffb40c870 /install.sh | |
parent | fa739abd3d3344532b1790899d9bdff874d341dc (diff) |
build: use chkstow and further simplify install
Diffstat (limited to 'install.sh')
-rwxr-xr-x | install.sh | 64 |
1 files changed, 7 insertions, 57 deletions
@@ -1,64 +1,14 @@ #!/bin/sh +# shellcheck disable=SC2035 -SCRIPT="$(basename "$0")" -SCRIPT_DIR="$(dirname -- "$(readlink -f -- "$0")")" -INSTALL_DIR="$(dirname "$SCRIPT_DIR")" +CDPATH='' cd -- "$(dirname -- "$0")" || exit -long='clean-only,help' -short='ch' +printf "%s: Removing bad links\n" "$0" +chkstow -t .. -b | cut -c13- | xargs -r rm -v -if ! opts="$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"; then - exit 1 -fi +printf "%s: Stowing packages\n" "$0" +stow "$@" */ -eval set -- "$opts" - -help() { - cat <<-EOF - $SCRIPT - Toby Vincent <tobyv@tobyvin.dev> - - $SCRIPT - Installer script that is a simple wrapper around GNU stow that removes broken symlinks - found in $INSTALL_DIR, stows all packages, and runs all ./*/install.sh scripts. - - USAGE: - $SCRIPT [OPTION ...] - - OPTIONS: - -h, --help Show this help. - EOF -} - -clean_only=false -while true; do - case "$1" in - -h | --help) - help - exit 0 - ;; - -c | --clean-only) - clean_only=true - shift - ;; - --) - shift - break - ;; - *) - exit 1 - ;; - esac -done - -find . -type l -exec sh -c 'for x; do [ -e "$x" ] || rm -v "$x"; done' _ {} + - -if $clean_only; then - exit 0 -fi - -stow "$@" -- */ - -for f in "$SCRIPT_DIR"/*/install.sh; do +for f in */install.sh; do $f done |