Last active
May 25, 2022 16:18
-
-
Save azubieta/059ffe794b815b75e331efef0e0025ce to your computer and use it in GitHub Desktop.
test-runtime-libs-version-checks.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -ex | |
TARGET_SYSTEMS=" | |
archlinux:latest | |
centos:6 centos:7 centos:8 | |
fedora:33 fedora:34 fedora:35 fedora:37 | |
ubuntu:16.04 ubuntu:18.04 ubuntu:20.04 ubuntu:21.04 ubuntu:22.04 | |
debian:stable-slim debian:unstable-slim debian:testing-slim | |
opensuse/leap:latest opensuse/tumbleweed:latest | |
" | |
LIBSTDCPP_BINS_PATH="$PWD/libstd++.so.6" | |
LIBC6_BINS_PATH="$PWD/libc.so.6" | |
LD_BINS_PATH="$PWD/ld.so" | |
function extract_libc() { | |
echo "Extracting 'libc.so.6' binaries" | |
mkdir -p "$LIBC6_BINS_PATH" | |
for TARGET in $TARGET_SYSTEMS; do | |
TARGET_FILE="$LIBC6_BINS_PATH/$(echo -n $TARGET | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md)" | |
if [ ! -f "$TARGET_FILE" ]; then | |
echo $TARGET | |
libfile="$(docker run --rm $TARGET cat '/etc/ld.so.cache' | grep -azm1 '/libc.so.6$' | tr -d '\0')" | |
container_id=$(docker create "$TARGET") | |
echo " -- extracting $libfile" | |
docker cp -L "$container_id:$libfile" "$TARGET_FILE" | |
docker rm "$container_id" | |
fi | |
done | |
} | |
function extract_libstdcpp() { | |
echo "Extracting 'libstdc++.so.6' binaries" | |
mkdir -p "$LIBSTDCPP_BINS_PATH" | |
for TARGET in $TARGET_SYSTEMS; do | |
TARGET_FILE="$LIBSTDCPP_BINS_PATH/$(echo -n $TARGET | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md)" | |
if [ ! -f "$TARGET_FILE" ]; then | |
echo $TARGET | |
libfile="$(docker run --rm $TARGET cat '/etc/ld.so.cache' | grep -azm1 '/libstdc++.so.6$' | tr -d '\0')" | |
container_id=$(docker create "$TARGET") | |
echo " -- extracting $libfile" | |
docker cp -L "$container_id:$libfile" "$TARGET_FILE" | |
docker rm "$container_id" | |
fi | |
done | |
} | |
function read_libc_version_string() { | |
echo "--- reading libc version string ---" | |
for libc in "$LIBC6_BINS_PATH"/*; do | |
STR_VERSION=$(grep -aoP 'GNU C Library [^\n]* release version \K[0-9]*.[0-9]*' "$libc") | |
LIC_BASENAME=$(basename $libc) | |
echo "$LIC_BASENAME => $STR_VERSION" | |
done | |
echo "" | |
} | |
extract_libc | |
read_libc_version_string | |
extract_libstdcpp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment