Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit fb93ec7

Browse files
committed
Add installation script
1 parent 868c2d2 commit fb93ec7

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

static/install

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env bash
2+
# The installation script for makedeb. This is the script that's shown and gets ran from https://makedeb.org.
3+
set -e
4+
5+
# Handy env vars.
6+
MAKEDEB_RELEASE="${MAKEDEB_RELEASE:-}"
7+
makedeb_url='makedeb.org'
8+
color_normal="$(tput sgr0)"
9+
color_bold="$(tput bold)"
10+
color_green="$(tput setaf 77)"
11+
color_orange="$(tput setaf 214)"
12+
color_blue="$(tput setaf 14)"
13+
color_red="$(tput setaf 202)"
14+
color_purple="$(tput setaf 135)"
15+
noninteractive_mode=0
16+
apt_args=()
17+
18+
# Handy functions.
19+
msg() {
20+
echo "${color_blue}[>]${color_normal} ${1}"
21+
}
22+
23+
error() {
24+
echo "${color_red}[!]${color_normal} ${1}"
25+
}
26+
27+
question() {
28+
echo "${color_purple}[?]${color_normal} ${1}"
29+
}
30+
31+
die_cmd() {
32+
error "${1}"
33+
exit 1
34+
}
35+
36+
answered_yes() {
37+
if [[ "${1}" == "" || "${1,,}" == "y" ]]; then
38+
return 0
39+
else
40+
return 1
41+
fi
42+
}
43+
44+
# Pre-checks.
45+
if [[ "${UID}" == "0" ]]; then
46+
die_cmd "This script is not allowed to be run under the root user. Please run as a normal user and try again."
47+
fi
48+
49+
# Program start.
50+
echo "-------------------------"
51+
echo "${color_green}[#]${color_normal} ${color_orange}makedeb Installer${color_normal} ${color_green}[#]${color_normal}"
52+
echo "-------------------------"
53+
echo
54+
55+
if ! echo "${-}" | grep -q i; then
56+
msg "Running in noninteractive mode."
57+
noninteractive_mode=1
58+
export DEBIAN_FRONTEND=noninteractive
59+
apt_args+=('-y')
60+
fi
61+
62+
msg "Ensuring needed packages are installed..."
63+
if ! sudo apt-get update "${apt_args[@]}"; then
64+
die_cmd "Failed to update APT cache."
65+
fi
66+
67+
missing_dependencies=()
68+
dpkg-query -W 'wget' > /dev/null 2>&1 || missing_dependencies+=('wget')
69+
dpkg-query -W 'gpg' > /dev/null 2>&1 || missing_dependencies+=('gpg')
70+
71+
if ! ( test -z "${missing_dependencies[*]}" || sudo apt-get install "${apt_args[@]}" --mark-auto "${missing_dependencies[@]}" ); then
72+
die_cmd "Failed to install needed packages."
73+
fi
74+
75+
echo
76+
77+
if (( "${noninteractive_mode}" )) && [[ "${MAKEDEB_RELEASE:+x}" == '' ]]; then
78+
error "The script was ran in noninteractive mode, but no makedeb package was specified to install."
79+
error "Please specify a package to install via the 'MAKEDEB_RELEASE' environment variable."
80+
die_cmd "Available packages are 'makedeb', 'makedeb-beta', and 'makedeb-alpha'."
81+
elif [[ "${MAKEDEB_RELEASE:+x}" == '' ]]; then
82+
msg "Multiple releases of makedeb are available for installation."
83+
msg "Currently, you can install one of 'makedeb', 'makedeb-beta', or"
84+
msg "'makedeb-alpha'."
85+
86+
while true; do
87+
read -p "$(question "Which release would you like? ")" MAKEDEB_RELEASE
88+
89+
if ! echo "${MAKEDEB_RELEASE}" | grep -qE '^makedeb$|^makedeb-beta$|^makedeb-alpha$'; then
90+
error "Invalid response: ${MAKEDEB_RELEASE}"
91+
continue
92+
fi
93+
94+
break
95+
done
96+
97+
echo
98+
fi
99+
100+
case "${MAKEDEB_RELEASE}" in
101+
makedeb|makedeb-alpha|makedeb-beta)
102+
;;
103+
*)
104+
echo
105+
error "Invalid \$MAKEDEB_RELEASE: '${MAKEDEB_RELEASE}'"
106+
exit 1 ;;
107+
esac
108+
109+
msg "Setting up makedeb APT repository..."
110+
if ! wget -qO - "https://proget.${makedeb_url}/debian-feeds/makedeb.pub" | gpg --dearmor | sudo tee /usr/share/keyrings/makedeb-archive-keyring.gpg 1> /dev/null; then
111+
die_cmd "Failed to set up makedeb APT repository."
112+
fi
113+
echo "deb [signed-by=/usr/share/keyrings/makedeb-archive-keyring.gpg arch=all] https://proget.${makedeb_url} makedeb main" | sudo tee /etc/apt/sources.list.d/makedeb.list 1> /dev/null
114+
115+
msg "Updating APT cache..."
116+
if ! sudo apt-get update "${apt_args[@]}"; then
117+
die_cmd "Failed to update APT cache."
118+
fi
119+
120+
echo
121+
msg "Installing '${MAKEDEB_RELEASE}'..."
122+
if ! sudo apt-get install "${apt_args[@]}" -- "${MAKEDEB_RELEASE}"; then
123+
die_cmd "Failed to install package."
124+
fi
125+
126+
msg "Finished! If you need help of any kind, feel free to reach out:"
127+
echo
128+
msg "${color_bold}makedeb Homepage:${color_normal} https://${makedeb_url}"
129+
msg "${color_bold}makedeb Package Repository:${color_normal} https://mpr.${makedeb_url}"
130+
msg "${color_bold}makedeb Documentation:${color_normal} https://docs.${makedeb_url}"
131+
msg "${color_bold}makedeb Support:${color_normal} https://docs.${makedeb_url}/support/obtaining-support"
132+
echo
133+
msg "Enjoy makedeb!"
134+
135+
# vim: set sw=4 expandtab:

0 commit comments

Comments
 (0)