blob: bc976a57ba5611aa31d19a5c925148f386c975ae [file] [log] [blame]
Gavin Howard4ffe5a92018-09-26 20:58:31 -06001#! /bin/sh
rofl0r8f19ed92018-04-01 20:54:56 +01002#
Gavin Howard4ffe5a92018-09-26 20:58:31 -06003# Copyright 2018 Gavin D. Howard
rofl0r8f19ed92018-04-01 20:54:56 +01004#
Gavin Howard4ffe5a92018-09-26 20:58:31 -06005# 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.
rofl0r8f19ed92018-04-01 20:54:56 +010015#
16
17usage() {
Gavin Howarddbbe3252019-02-18 11:07:22 -070018 printf "usage: %s install_dir exec_suffix\n" "$0" 1>&2
Gavin Howard4ffe5a92018-09-26 20:58:31 -060019 exit 1
rofl0r8f19ed92018-04-01 20:54:56 +010020}
21
Gavin Howarddbbe3252019-02-18 11:07:22 -070022script="$0"
Gavin Howard4ffe5a92018-09-26 20:58:31 -060023scriptdir=$(dirname "$script")
rofl0r8f19ed92018-04-01 20:54:56 +010024
Gavin Howard6e70f552019-04-01 14:09:39 -060025. "$scriptdir/functions.sh"
Gavin Howard50080252019-02-20 15:27:43 -070026
Gavin Howard4ffe5a92018-09-26 20:58:31 -060027INSTALL="$scriptdir/safe-install.sh"
28
Gavin Howarddbbe3252019-02-18 11:07:22 -070029test "$#" -ge 2 || usage
Gavin Howard4ffe5a92018-09-26 20:58:31 -060030
31installdir="$1"
32shift
33
Gavin Howard5d057152019-01-29 10:31:40 -070034exec_suffix="$1"
35shift
36
Gavin Howarddbbe3252019-02-18 11:07:22 -070037bindir="$scriptdir/bin"
Gavin Howardc494b572018-09-27 13:34:45 -060038
Gavin Howarddbbe3252019-02-18 11:07:22 -070039for exe in $bindir/*; do
Gavin Howard4ffe5a92018-09-26 20:58:31 -060040
Gavin Howard2bc50a92018-10-12 16:59:44 -060041 base=$(basename "$exe")
Gavin Howard4ffe5a92018-09-26 20:58:31 -060042
Gavin Howard2bc50a92018-10-12 16:59:44 -060043 if [ -L "$exe" ]; then
Gavin Howarde26c6f92019-02-18 12:50:23 -070044 link=$(readlink "$exe")
Gavin Howard5d057152019-01-29 10:31:40 -070045 "$INSTALL" -Dlm 755 "$link$exec_suffix" "$installdir/$base$exec_suffix"
Gavin Howard2bc50a92018-10-12 16:59:44 -060046 else
Gavin Howard5d057152019-01-29 10:31:40 -070047 "$INSTALL" -Dm 755 "$exe" "$installdir/$base$exec_suffix"
Gavin Howard2bc50a92018-10-12 16:59:44 -060048 fi
Gavin Howard4ffe5a92018-09-26 20:58:31 -060049
rofl0r8f19ed92018-04-01 20:54:56 +010050done