-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-alsa-tools.sh
201 lines (175 loc) · 5 KB
/
install-alsa-tools.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env bash
# Script: install-alsa-tools.sh
# Author: [email protected]
# Upstream link: https://www.alsa-project.org
# Description: Alsa tools for Rocky Linux 9
# Revision: 1.1
set -euo pipefail
IFS=$'\n\t'
# Color codes
INFO_COLOR="\033[1;34m" # Blue
WARN_COLOR="\033[1;33m" # Yellow
ERROR_COLOR="\033[1;31m" # Red
RESET_COLOR="\033[0m" # Reset to default
# Function to print INFO messages
info() {
echo -e "${INFO_COLOR}[INFO] $1${RESET_COLOR}"
}
# Function to print WARN messages
warn() {
echo -e "${WARN_COLOR}[WARN] $1${RESET_COLOR}"
}
# Function to print ERROR messages
error() {
echo -e "${ERROR_COLOR}[ERROR] $1${RESET_COLOR}"
}
# Function to check Linux distro
check_distro() {
if [[ -f /etc/os-release ]]; then
. /etc/os-release
OS=${ID}
VERS_ID=${VERSION_ID}
OS_ID="${VERS_ID:0:1}"
elif command -v lsb_release &>/dev/null; then
OS=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
elif [[ -f /etc/lsb-release ]]; then
. /etc/lsb-release
OS=$(echo "${DISTRIB_ID}" | tr '[:upper:]' '[:lower:]')
elif [[ -f /etc/debian_version ]]; then
OS=debian
else
error "Unknown Linux distro. Exiting!"
exit 1
fi
if [[ "$OS" == "rocky" && "$OS_ID" == "9" ]]; then
info "Detected 'Rocky Linux 9'. Continuing."
else
error "Could not detect 'Rocky Linux 9'. Exiting."
exit 1
fi
}
# Function to prompt user
prompt_user() {
while true; do
read -r -p "$1 (y/n) " yesno
case "$yesno" in
[nN]) exit 0 ;;
[yY]) break ;;
*) warn "Please answer 'y/n'." ;;
esac
done
}
# Function to prepare working directory
prepare_workdir() {
if [[ -d "${PKGDIR}" ]]; then
while true; do
warn "Source directory '${PKGDIR}' already exists."
read -r -p "Delete it and reinstall? (y/n) " yesno
case "$yesno" in
[nN]) exit 0 ;;
[yY]) break ;;
*) warn "Please answer 'y/n'." ;;
esac
done
rm -rf "${PKGDIR}"
fi
mkdir -p "${PKGDIR}"
cd "${PKGDIR}"
}
# Function to install prerequisites
install_prerequisites() {
info "Enabling Extra Packages for Enterprise Linux 9 and Development Tools."
sudo dnf install -y epel-release
sudo /usr/bin/crb enable
sudo dnf groupinstall -y "Development Tools"
sudo dnf makecache
info "Installing necessary packages for building alsa-tools."
sudo dnf install -y alsa-lib-devel hicolor-icon-theme fltk-devel gtk2-devel gtk3-devel
}
# Function to download and verify source
download_and_verify() {
info "Downloading latest upstream source."
curl -fSL -o "${PKGNAME}-${PKGVER}.tar.bz2" "${ATOOLS_PKG}"
echo "${ATOOLS_MD5} ${PKGNAME}-${PKGVER}.tar.bz2" | md5sum -c || {
error "Checksum verification failed. Exiting."
exit 1
}
info "Downloaded files have successfully passed MD5 checksum test. Continuing."
tar -xf "${PKGNAME}-${PKGVER}.tar.bz2"
}
# Function to prepare and build tools
prepare_and_build() {
cd "${PKGNAME}-${PKGVER}"
# Uncomment to install more tools
TOOLS=(
#as10k1
#echomixer
#envy24control
#hda-verb
# hdajackretask # fails to build
#hdajacksensetest
#hdspconf
#hdsploader
hdspmixer
#hwmixvolume
#ld10k1
#mixartloader
#pcxhrloader
# qlo10k1 # disabled, because build is broken
rmedigicontrol
#sb16_csp
#seq/sbiload
#sscape_ctl
#vxloader
#us428control
#usx2yloader
)
info "Preparing package."
for tool in "${TOOLS[@]}"; do
(
cd "${PKGDIR}/${PKGNAME}-${PKGVER}/$tool"
autoreconf -vfi
)
done
info "Building package."
for tool in "${TOOLS[@]}"; do
(
cd "${PKGDIR}/${PKGNAME}-${PKGVER}/$tool"
./configure --prefix=/usr --sbindir=/usr/bin
make
)
done
}
# Function to install tools
install_tools() {
info "Installing package."
for tool in "${TOOLS[@]}"; do
sudo make install -C "${PKGDIR}/${PKGNAME}-${PKGVER}/$tool"
done
}
# Function to display final steps
display_final_steps() {
info "Successfully installed alsa tools: ${TOOLS[*]}"
info "For more information please check: https://www.alsa-project.org"
}
# Main function
main() {
info "Script execution started."
# Variables
PKGDIR="$HOME/src/alsa-tools"
PKGNAME="alsa-tools"
PKGVER="1.2.11"
ATOOLS_PKG="http://www.alsa-project.org/files/pub/tools/${PKGNAME}-${PKGVER}.tar.bz2"
ATOOLS_MD5="bc5f5e5689f46a9d4a0b85dc6661732c"
check_distro
prompt_user "Welcome to alsa-tools installation script. Proceed with installation?"
prepare_workdir
install_prerequisites
download_and_verify
prepare_and_build
install_tools
display_final_steps
info "Script execution finished."
}
# Run the main function
main