-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy path3-install.sh
More file actions
executable file
·94 lines (70 loc) · 2.54 KB
/
Copy path3-install.sh
File metadata and controls
executable file
·94 lines (70 loc) · 2.54 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
function exit_with_help() {
echo 'Installs the application from the selected build output into this system.'
echo ''
echo 'Usage: 3-install.sh <install_method> <path>'
echo ' install_method - how and from which source the package is installed'
echo ' from_build - the package will be installed from the build output, <path> is the path of the build directory'
echo ' from_deb - the package will be installed from a Debian package, <path> is the path of the package file'
exit $1
}
set -o errexit -o nounset -o pipefail
pushd "$(dirname "$0")/.." 1>/dev/null
trap "popd 1>/dev/null; echo" EXIT
SOURCE_DIR="$(pwd)"
SCRIPT_DIR="$SOURCE_DIR/Scripts"
SHORTEN_PATHS="python3 '$SCRIPT_DIR/replace.py' '$SOURCE_DIR' '\$SOURCE_DIR' | python3 '$SCRIPT_DIR/replace.py' '$HOME' '\$HOME'"
PROJECT_NAME="$(basename "$SOURCE_DIR")"
function echo_and_eval() {
COMMAND="$1"
echo "$COMMAND" | eval $SHORTEN_PATHS
COMMAND=$(echo "$COMMAND" | tr -d '\n') # remove newlines from the command
eval "$COMMAND"
return $?
}
function copy() { echo "cp \"\$SOURCE_DIR/$1\" \"$2\""; sudo cp "$SOURCE_DIR/$1" "$2"; }
# detect the operating system
if [[ -d "/Applications" && -d "/Library" ]]; then
OS_TYPE=MacOS
elif [[ -d "/usr/bin" ]]; then
OS_TYPE=Linux
else
echo "Unrecognized operating system."
exit 1
fi
if [[ $# -lt 2 ]]; then
exit_with_help 1
elif [[ $1 == "-h" || $1 == "--help" ]]; then
exit_with_help 0
fi
INSTALL_METHOD="$1"
if [ $INSTALL_METHOD == from_build ]; then
BUILD_DIR="$2"
echo "Installing the application from the build output in \"$BUILD_DIR\" into this system" | eval $SHORTEN_PATHS
echo
if [ $OS_TYPE == Linux ]; then
echo "Installing binaries"
pushd "$BUILD_DIR" 1>/dev/null
sudo make install
popd 1>/dev/null
echo
echo "Installing desktop files"
copy "Install/XDG/$PROJECT_NAME.desktop" "/usr/share/applications/$PROJECT_NAME.desktop"
for SIZE in 16 24 32 48 64 128; do
copy "Install/XDG/$PROJECT_NAME.${SIZE}x${SIZE}.png" "/usr/share/icons/hicolor/${SIZE}x${SIZE}/apps/$PROJECT_NAME.png"
done
elif [ $OS_TYPE == MacOS ]; then
echo "Installing $PROJECT_NAME.app"
copy "$BUILD_DIR/$PROJECT_NAME.app" "/Applications"
fi
elif [ $INSTALL_METHOD == from_deb ]; then
PACKAGE_PATH="$2"
echo "Installing the application from the package at \"$PACKAGE_PATH\" into this system" | eval $SHORTEN_PATHS
echo
echo_and_eval "sudo apt install \"$PACKAGE_PATH\""
else
echo "Invalid install_method \"$INSTALL_METHOD\", possible values: from_build, from_deb"
exit 1
fi
echo
echo "Done"