Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Created January 29, 2021 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboldt/31136137a040ecb9082f19ef0f79e495 to your computer and use it in GitHub Desktop.
Save nickboldt/31136137a040ecb9082f19ef0f79e495 to your computer and use it in GitHub Desktop.
check rpms installed in a container (or diff two containers)
# copied from a jenkins job last used in Dec 2019 for CRW 2.0
alias dr='docker run --rm --entrypoint /bin/bash'
if [[ ${CONTAINER1} ]]; then
dr ${CONTAINER1} -c "rpm -qa | sort" | tee CONTAINER1.installed.rpms.txt &
fi
if [[ ${CONTAINER2} ]]; then
dr ${CONTAINER2} -c "rpm -qa | sort" | tee CONTAINER2.installed.rpms.txt &
fi
wait
if [[ ${CONTAINER1} ]] && [[ ${CONTAINER2} ]]; then
diff --unified=1 --suppress-common-lines --ignore-all-space \
CONTAINER1.installed.rpms.txt CONTAINER2.installed.rpms.txt | tee CONTAINERs.diff.rpms.txt
fi
set +x
if [[ $(cat CONTAINERs.diff.rpms.txt) ]]; then
echo "STATUS='RPM CHANGE in ${CONTAINER1} vs. ${CONTAINER2}'"
else
echo "STATUS='NO RPM CHANGE in ${CONTAINER1} vs. ${CONTAINER2}'"
fi
docker rmi ${CONTAINER1} ${CONTAINER2}
cat CONTAINERs.diff.rpms.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment