Created
September 24, 2024 19:55
-
-
Save carlwgeorge/8eaade20b212efbe580b8e0df7501973 to your computer and use it in GitHub Desktop.
script to count the number of packages in a yum repo
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
#!/usr/bin/bash | |
set -eou pipefail | |
# TODO: loop multiple | |
if [[ $# -ne 1 ]]; then | |
echo "usage: $(basename $0) <baseurl>" | |
exit 1 | |
fi | |
repo="$1" | |
repomd="${repo}repodata/repomd.xml" | |
primary_href=$(curl -s $repomd | xq -x '/repomd/data[@type="primary"]/location/@href') | |
case $primary_href in | |
*.xml.gz) compcat=zcat;; | |
*.xml.xz) compcat=xzcat;; | |
esac | |
primary="$repo/$primary_href" | |
packages=$(curl -s $primary | $compcat | xq -x '/metadata/@packages') | |
echo "$packages packages in $repo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment