Skip to content

Commit

Permalink
Simplified method for picking out shared libraries from system packag…
Browse files Browse the repository at this point in the history
…e query result (awslabs#136)
  • Loading branch information
specious committed Aug 29, 2022
1 parent 9dd0bdf commit 5fb60b9
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packaging/packager
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,36 @@ if ! type zip > /dev/null 2>&1; then
exit 1
fi

function pluck_so_files() {
function find_so_files() {
sed -E '/\.so$|\.so\.[0-9]+$/!d'
}

function package_libc_alpine() {
# -F matches a fixed string rather than a regex (grep that comes with busybox doesn't know --fixed-strings)
if grep -F "Alpine Linux" < /etc/os-release > /dev/null; then
if type apk > /dev/null 2>&1; then
apk info --contents musl 2>/dev/null | pluck_so_files | sed 's/^/\//'
apk info --contents musl 2>/dev/null | find_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 | pluck_so_files
pacman --query --list --quiet glibc | find_so_files
fi
fi
}

function package_libc_dpkg() {
if type dpkg-query > /dev/null 2>&1; then
architecture=$(dpkg --print-architecture)
if [[ $(dpkg-query --listfiles libc6:$architecture | wc -l) -gt 0 ]]; then
dpkg-query --listfiles libc6:$architecture | pluck_so_files
fi
dpkg-query --listfiles libc6:$(dpkg --print-architecture) | find_so_files
fi
}

function package_libc_rpm() {
arch=$(uname -m)

if type rpm > /dev/null 2>&1; then
if [[ $(rpm --query --list glibc.$arch | wc -l) -gt 1 ]]; then
rpm --query --list glibc.$arch | pluck_so_files
fi
rpm --query --list glibc.$(uname -m) | find_so_files
fi
}

Expand Down

0 comments on commit 5fb60b9

Please sign in to comment.