Skip to content

Instantly share code, notes, and snippets.

@pjbgf
Last active June 25, 2024 08:47
Show Gist options
  • Save pjbgf/ca686b7be1b7ebc67eeb90c543375ac5 to your computer and use it in GitHub Desktop.
Save pjbgf/ca686b7be1b7ebc67eeb90c543375ac5 to your computer and use it in GitHub Desktop.
Compare missing commands on new container image
#!/bin/bash
set -eo pipefail
BEFORE=$(mktemp)
AFTER=$(mktemp)
cleanup() {
rm -f "${BEFORE}" "${AFTER}"
}
trap cleanup EXIT
function compare(){
IMG=$1
BEFORE_TAG=$2
AFTER_TAG=$3
DIRS="${DIRS:-/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}"
echo "" > "${BEFORE}"
echo "" > "${AFTER}"
for dir in $DIRS; do
docker run --rm --entrypoint ls "${IMG}:${BEFORE_TAG}" "${dir}" >> "${BEFORE}"
docker run --rm --entrypoint ls "${IMG}:${AFTER_TAG}" "${dir}" >> "${AFTER}"
done
echo "Missing files on new ${IMG}:${AFTER_TAG}:"
diff -y "${BEFORE}" "${AFTER}" | grep "<" | awk '{ print $1 }' | sort -u
}
if [ $# -lt 3 ]; then
echo "usage: $0 <IMAGE> <TAG1> <TAG2>" >&2
exit 1
fi
compare $1 $2 $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment