From c1ec4602e6a3f7e101f30dc0c40e614fcc27495c Mon Sep 17 00:00:00 2001 From: Ildar Sagdejev Date: Thu, 18 Nov 2021 11:09:20 -0500 Subject: [PATCH 1/3] Packaging support on Alpine Linux --- packaging/packager | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/packaging/packager b/packaging/packager index ab27526..9e42c81 100755 --- a/packaging/packager +++ b/packaging/packager @@ -56,26 +56,39 @@ if ! type zip > /dev/null 2>&1; then echo "zip utility is not found. Please install it and re-run this script" exit 1 fi -function package_libc_via_pacman { + +function pluck_so_files() { + sed -E '/\.so$|\.so\.[0-9]+$/!d' +} + +function package_libc_alpine() { + if grep -F "Alpine Linux" < /etc/os-release > /dev/null; then + if type apk > /dev/null 2>&1; then + apk info -L musl 2>/dev/null | pluck_so_files | sed 's/^/\//' + fi + fi +} + +function package_libc_pacman() { if grep --extended-regexp "Arch Linux|Manjaro Linux" < /etc/os-release > /dev/null 2>&1; then if type pacman > /dev/null 2>&1; then - pacman --query --list --quiet glibc | sed -E '/\.so$|\.so\.[0-9]+$/!d' + pacman --query --list --quiet glibc | pluck_so_files fi fi } -function package_libc_via_dpkg() { +function package_libc_dpkg() { if type dpkg-query > /dev/null 2>&1; then if [[ $(dpkg-query --listfiles libc6 | wc -l) -gt 0 ]]; then - dpkg-query --listfiles libc6 | sed -E '/\.so$|\.so\.[0-9]+$/!d' + dpkg-query --listfiles libc6 | pluck_so_files fi fi } -function package_libc_via_rpm() { +function package_libc_rpm() { if type rpm > /dev/null 2>&1; then if [[ $(rpm --query --list glibc.$architecture | wc -l) -gt 1 ]]; then - rpm --query --list glibc.$architecture | sed -E '/\.so$|\.so\.[0-9]+$/!d' + rpm --query --list glibc.$architecture | pluck_so_files fi fi } @@ -99,9 +112,10 @@ PKG_LD="" list=$(ldd "$PKG_BIN_PATH" | awk '{print $(NF-1)}') libc_libs=() -libc_libs+=($(package_libc_via_dpkg)) -libc_libs+=($(package_libc_via_rpm)) -libc_libs+=($(package_libc_via_pacman)) +libc_libs+=($(package_libc_dpkg)) +libc_libs+=($(package_libc_rpm)) +libc_libs+=($(package_libc_pacman)) +libc_libs+=($(package_libc_alpine)) mkdir -p "$PKG_DIR/bin" "$PKG_DIR/lib" From 482e8e8ca2c65b0717d7536cc59fdef81defad07 Mon Sep 17 00:00:00 2001 From: Ildar Sagdejev Date: Fri, 19 Nov 2021 10:39:37 -0500 Subject: [PATCH 2/3] Check system architecture using a standard utility and only where needed Fixes #122 --- packaging/packager | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packaging/packager b/packaging/packager index 9e42c81..8113478 100755 --- a/packaging/packager +++ b/packaging/packager @@ -45,7 +45,6 @@ done set -- "${POSITIONAL[@]}" # restore positional parameters PKG_BIN_PATH=$1 -architecture=$(arch) if [ ! -f "$PKG_BIN_PATH" ]; then echo "$PKG_BIN_PATH" - No such file.; @@ -86,9 +85,11 @@ function package_libc_dpkg() { } function package_libc_rpm() { + arch=$(uname -m) + if type rpm > /dev/null 2>&1; then - if [[ $(rpm --query --list glibc.$architecture | wc -l) -gt 1 ]]; then - rpm --query --list glibc.$architecture | pluck_so_files + if [[ $(rpm --query --list glibc.$arch | wc -l) -gt 1 ]]; then + rpm --query --list glibc.$arch | pluck_so_files fi fi } From 4cdb75b0bfad5f76b0b23b5356921b8ef2c48598 Mon Sep 17 00:00:00 2001 From: Ildar Sagdejev Date: Mon, 22 Nov 2021 14:21:13 -0500 Subject: [PATCH 3/3] Use long-form flags in packager script --- packaging/packager | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/packager b/packaging/packager index 8113478..795d330 100755 --- a/packaging/packager +++ b/packaging/packager @@ -61,9 +61,9 @@ function pluck_so_files() { } function package_libc_alpine() { - if grep -F "Alpine Linux" < /etc/os-release > /dev/null; then + if grep --fixed-strings "Alpine Linux" < /etc/os-release > /dev/null; then if type apk > /dev/null 2>&1; then - apk info -L musl 2>/dev/null | pluck_so_files | sed 's/^/\//' + apk info --contents musl 2>/dev/null | pluck_so_files | sed 's/^/\//' fi fi }