Skip to content

Commit f0f427f

Browse files
authored
Packaging support on Alpine Linux (#131)
* Packaging support on Alpine Linux * Check system architecture using a standard utility and only where needed Fixes #122 * Use long-form flags in packager script
1 parent 8c45069 commit f0f427f

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

packaging/packager

+26-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ done
4545
set -- "${POSITIONAL[@]}" # restore positional parameters
4646

4747
PKG_BIN_PATH=$1
48-
architecture=$(arch)
4948

5049
if [ ! -f "$PKG_BIN_PATH" ]; then
5150
echo "$PKG_BIN_PATH" - No such file.;
@@ -56,26 +55,41 @@ if ! type zip > /dev/null 2>&1; then
5655
echo "zip utility is not found. Please install it and re-run this script"
5756
exit 1
5857
fi
59-
function package_libc_via_pacman {
58+
59+
function pluck_so_files() {
60+
sed -E '/\.so$|\.so\.[0-9]+$/!d'
61+
}
62+
63+
function package_libc_alpine() {
64+
if grep --fixed-strings "Alpine Linux" < /etc/os-release > /dev/null; then
65+
if type apk > /dev/null 2>&1; then
66+
apk info --contents musl 2>/dev/null | pluck_so_files | sed 's/^/\//'
67+
fi
68+
fi
69+
}
70+
71+
function package_libc_pacman() {
6072
if grep --extended-regexp "Arch Linux|Manjaro Linux" < /etc/os-release > /dev/null 2>&1; then
6173
if type pacman > /dev/null 2>&1; then
62-
pacman --query --list --quiet glibc | sed -E '/\.so$|\.so\.[0-9]+$/!d'
74+
pacman --query --list --quiet glibc | pluck_so_files
6375
fi
6476
fi
6577
}
6678

67-
function package_libc_via_dpkg() {
79+
function package_libc_dpkg() {
6880
if type dpkg-query > /dev/null 2>&1; then
6981
if [[ $(dpkg-query --listfiles libc6 | wc -l) -gt 0 ]]; then
70-
dpkg-query --listfiles libc6 | sed -E '/\.so$|\.so\.[0-9]+$/!d'
82+
dpkg-query --listfiles libc6 | pluck_so_files
7183
fi
7284
fi
7385
}
7486

75-
function package_libc_via_rpm() {
87+
function package_libc_rpm() {
88+
arch=$(uname -m)
89+
7690
if type rpm > /dev/null 2>&1; then
77-
if [[ $(rpm --query --list glibc.$architecture | wc -l) -gt 1 ]]; then
78-
rpm --query --list glibc.$architecture | sed -E '/\.so$|\.so\.[0-9]+$/!d'
91+
if [[ $(rpm --query --list glibc.$arch | wc -l) -gt 1 ]]; then
92+
rpm --query --list glibc.$arch | pluck_so_files
7993
fi
8094
fi
8195
}
@@ -99,9 +113,10 @@ PKG_LD=""
99113

100114
list=$(ldd "$PKG_BIN_PATH" | awk '{print $(NF-1)}')
101115
libc_libs=()
102-
libc_libs+=($(package_libc_via_dpkg))
103-
libc_libs+=($(package_libc_via_rpm))
104-
libc_libs+=($(package_libc_via_pacman))
116+
libc_libs+=($(package_libc_dpkg))
117+
libc_libs+=($(package_libc_rpm))
118+
libc_libs+=($(package_libc_pacman))
119+
libc_libs+=($(package_libc_alpine))
105120

106121
mkdir -p "$PKG_DIR/bin" "$PKG_DIR/lib"
107122

0 commit comments

Comments
 (0)