Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 1 | #! /bin/sh |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 2 | # |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 3 | # Copyright 2018 Gavin D. Howard |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 4 | # |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 5 | # Permission to use, copy, modify, and/or distribute this software for any |
| 6 | # purpose with or without fee is hereby granted. |
| 7 | # |
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 9 | # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 10 | # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 11 | # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 12 | # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 13 | # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 14 | # PERFORMANCE OF THIS SOFTWARE. |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 15 | # |
| 16 | |
| 17 | usage() { |
Gavin Howard | dbbe325 | 2019-02-18 11:07:22 -0700 | [diff] [blame] | 18 | printf "usage: %s install_dir exec_suffix\n" "$0" 1>&2 |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 19 | exit 1 |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 20 | } |
| 21 | |
Gavin Howard | dbbe325 | 2019-02-18 11:07:22 -0700 | [diff] [blame] | 22 | script="$0" |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 23 | scriptdir=$(dirname "$script") |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 24 | |
Gavin Howard | 6e70f55 | 2019-04-01 14:09:39 -0600 | [diff] [blame^] | 25 | . "$scriptdir/functions.sh" |
Gavin Howard | 5008025 | 2019-02-20 15:27:43 -0700 | [diff] [blame] | 26 | |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 27 | INSTALL="$scriptdir/safe-install.sh" |
| 28 | |
Gavin Howard | dbbe325 | 2019-02-18 11:07:22 -0700 | [diff] [blame] | 29 | test "$#" -ge 2 || usage |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 30 | |
| 31 | installdir="$1" |
| 32 | shift |
| 33 | |
Gavin Howard | 5d05715 | 2019-01-29 10:31:40 -0700 | [diff] [blame] | 34 | exec_suffix="$1" |
| 35 | shift |
| 36 | |
Gavin Howard | dbbe325 | 2019-02-18 11:07:22 -0700 | [diff] [blame] | 37 | bindir="$scriptdir/bin" |
Gavin Howard | c494b57 | 2018-09-27 13:34:45 -0600 | [diff] [blame] | 38 | |
Gavin Howard | dbbe325 | 2019-02-18 11:07:22 -0700 | [diff] [blame] | 39 | for exe in $bindir/*; do |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 40 | |
Gavin Howard | 2bc50a9 | 2018-10-12 16:59:44 -0600 | [diff] [blame] | 41 | base=$(basename "$exe") |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 42 | |
Gavin Howard | 2bc50a9 | 2018-10-12 16:59:44 -0600 | [diff] [blame] | 43 | if [ -L "$exe" ]; then |
Gavin Howard | e26c6f9 | 2019-02-18 12:50:23 -0700 | [diff] [blame] | 44 | link=$(readlink "$exe") |
Gavin Howard | 5d05715 | 2019-01-29 10:31:40 -0700 | [diff] [blame] | 45 | "$INSTALL" -Dlm 755 "$link$exec_suffix" "$installdir/$base$exec_suffix" |
Gavin Howard | 2bc50a9 | 2018-10-12 16:59:44 -0600 | [diff] [blame] | 46 | else |
Gavin Howard | 5d05715 | 2019-01-29 10:31:40 -0700 | [diff] [blame] | 47 | "$INSTALL" -Dm 755 "$exe" "$installdir/$base$exec_suffix" |
Gavin Howard | 2bc50a9 | 2018-10-12 16:59:44 -0600 | [diff] [blame] | 48 | fi |
Gavin Howard | 4ffe5a9 | 2018-09-26 20:58:31 -0600 | [diff] [blame] | 49 | |
rofl0r | 8f19ed9 | 2018-04-01 20:54:56 +0100 | [diff] [blame] | 50 | done |