forked from AdaCore/gnat_community_install_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_package.sh
executable file
·67 lines (56 loc) · 1.42 KB
/
install_package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env sh
script_dir=$(dirname $0)
# Validate the number of arguments
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ] ; then
echo "Usage: $0 <package_file> <target_directory> [<components>]" >&2
exit 1
fi
package_file=$1
target=$2
components=$3
install_darwin() {
# Create a mountpoint
mountpoint=`mktemp -d`
hdiutil attach $package_file -mountpoint $mountpoint
if [ "$?" -ne 0 ] ; then
echo "Could not mount the archive..." >&2
exit 1
fi
base=` basename $package_file | cut -d'.' -f1 `
$mountpoint/$base.app/Contents/MacOS/$base \
--script $script_dir/install_script.qs \
InstallPrefix="$target" \
Components="$components"
umount $mountpoint
rm -rf $mountpoint
}
install_linux() {
chmod +x "$package_file"
"$package_file" \
--script $script_dir/install_script.qs \
--platform minimal \
InstallPrefix="$target" \
Components="$components"
}
# Make sure the target is nonexistent or empty
if [ -f "$target" ]; then
echo "Target cannot be an existing file" >&2
exit 1
fi
if [ -d "$target" ]; then
ls=` ls -A "$target" `
if [ ! -z "$ls" ]; then
echo "Target cannot be a non-empty directory" >&2
exit 1
fi
fi
# Ensure "make" is installed
if ! command -v make >/dev/null 2>&1 ; then
echo "Unable to find the 'make' command" >&2
exit 1
fi
case `uname` in
Darwin) install_darwin;;
Linux) install_linux;;
*) echo "Platform not supported" >&2 ; exit 1 ;;
esac