blob: 47f5b5ec25af5a1131ab956770a4c1cf555abb55 (
plain) (
blame)
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
|
#!/bin/bash
# author: nasr
#
# builds a release binary and installs it with a desktop entry and an icon.
#
# ./install.sh install into ~/.local (no root needed)
# PREFIX=/usr/local sudo ./install.sh
# DESTDIR=pkg PREFIX=/usr ./install.sh staged install for packaging
# ./install.sh --uninstall remove it again (keeps downloaded audio)
set -e
cd "$(dirname "$0")"
PREFIX=${PREFIX:-$HOME/.local}
DESTDIR=${DESTDIR:-}
NAME=mp3_player
BIN_DIR="${DESTDIR}${PREFIX}/bin"
APP_DIR="${DESTDIR}${PREFIX}/share/applications"
ICON_ROOT="${DESTDIR}${PREFIX}/share/icons/hicolor"
ICON_DIR="${ICON_ROOT}/scalable/apps"
refresh_caches() {
# NOTE: only for real installs, a staged DESTDIR install leaves this to the package manager
[ -n "$DESTDIR" ] && return 0
command -v update-desktop-database >/dev/null && update-desktop-database -q "$APP_DIR" || true
command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -q -t "$ICON_ROOT" 2>/dev/null || true
}
if [ "$1" = "--uninstall" ]; then
rm -f "${BIN_DIR}/${NAME}" "${APP_DIR}/${NAME}.desktop" "${ICON_DIR}/${NAME}.svg"
refresh_caches
echo "uninstalled ${NAME} from ${PREFIX}"
echo "downloaded audio and settings are kept in \${XDG_DATA_HOME:-~/.local/share}/${NAME}"
exit 0
fi
if [ -n "$1" ]; then
sed -n '4,9p' "$0" | sed 's/^# \{0,1\}//'
exit 1
fi
#- build
# NOTE: separate build dir, so installing never clobbers the debug build in build/
BUILD_DIR=build/release DEBUG=0 ./compile.sh
#- install
install -Dm755 "build/release/${NAME}" "${BIN_DIR}/${NAME}"
install -Dm644 "data/${NAME}.svg" "${ICON_DIR}/${NAME}.svg"
install -d "$APP_DIR"
# NOTE: absolute Exec path, so the launcher works even when PREFIX/bin isn't on the
# launcher's PATH (dwl started from a tty, dmenu-like launchers, ...)
sed "s|^Exec=${NAME}|Exec=${PREFIX}/bin/${NAME}|" "data/${NAME}.desktop" > "${APP_DIR}/${NAME}.desktop"
chmod 644 "${APP_DIR}/${NAME}.desktop"
refresh_caches
echo
echo "installed:"
echo " ${BIN_DIR}/${NAME}"
echo " ${APP_DIR}/${NAME}.desktop"
echo " ${ICON_DIR}/${NAME}.svg"
case ":$PATH:" in
*":${PREFIX}/bin:"*) ;;
*) echo "note: ${PREFIX}/bin is not on your PATH" ;;
esac
|