Created
September 4, 2025 17:37
-
-
Save ThinGuy/a147da52c9e013c3afc851b3b309a879 to your computer and use it in GitHub Desktop.
Pull all repo sizes from Canonical - WIP
This file contains hidden or 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 | |
| export PAPI_DIR=~/papi | |
| [[ -d ${PAPI_DIR} ]] && { find ${PAPI_DIR} -type f -delete; } || { mkdir -p $PAPI_DIR; } | |
| export OK=$(printf '\e[0;1;38;2;0;255;0m✓\e[0m') | |
| export ORA=$(printf '\e[0;1;38;2;233;84;20m▸\e[0m') | |
| export WRA=$(printf '\e[0;1;38;2;255;255;255m▸\e[0m') | |
| printf "\n\e[2G\e[0;38;2;255;255;255mCanonical \e[0;38;2;233;84;20mPAPI\e[0m: Project and Package Information\e[0m\n" | |
| LINE="$(printf '\u2500%0.0s' {1..47})" | |
| printf "\e[2G${LINE}\n" | |
| # LTS Repo (Intel) | |
| printf "\n\e[2GGathering package & project information from the \e[0;38;2;233;84;20mUbuntu™ \e[0;38;2;255;255;255mLTS\e[0m (Intel/AMD) Archive, aka \x22\e[0;38;2;233;84;20mLTS\e[0m\x22\e[0m\n" | |
| export LTS_REPO_URL=https://us.archive.ubuntu.com/ubuntu/dists | |
| export LTS_SITE=$(echo ${LTS_REPO_URL//https:\/\/}|sed -r 's/\/.*$//g') | |
| declare -ag LTS_RELEASES=($(curl -sSlL ${LTS_REPO_URL}|awk -v U="${LTS_REPO_URL}" -F">|<" '/folder.gif/&&!/devel/{sub(/\/$|-.*/,"",$13);print $13}'|sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\e[3G - Found ${#LTS_RELEASES[@]} \e[0;38;2;233;84;20mUbuntu™\e[0m releases for \e[0;38;2;233;84;20mLTS\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${LTS_RELEASES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag LTS_SUITES=($(for i in ${!LTS_RELEASES[@]};do printf '%s\n' ${LTS_RELEASES[$i]} ${LTS_RELEASES[$i]}{-updates,-security,-backports,-proposed};done)) | |
| printf "\e[3G - Found ${#LTS_SUITES[@]} suites for \e[0;38;2;233;84;20mLTS\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${LTS_SUITES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag LTS_ARCHES=($((eval printf '%s\\n' ${LTS_REPO_URL}/{$(printf "%s\n" ${LTS_SUITES[@]}|paste -sd,)}/{main,universe,multiverse,restricted}/|xargs -rn1 -P0 curl -sSlL |awk -F">|<" '/folder.gif/&&/binary|source/&&!/devel/{gsub(/\/$/,"",$13);print $13}')|sort -uV)) | |
| printf "\e[3G - Found ${#LTS_ARCHES[@]} architectures for \e[0;38;2;233;84;20mLTS\e[0m (including source)\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${LTS_ARCHES[@]//binary-/})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag LTS_IDX_URLS=(); | |
| while IFS= read -r I;do | |
| LTS_IDX_URLS+=("${I}"); | |
| done < <(eval printf '%s\\n' ${LTS_REPO_URL}/{$(printf "%s\n" ${LTS_SUITES[@]}|paste -sd,)}/{main,universe,multiverse,restricted}/{$(printf "%s\n" ${LTS_ARCHES[@]}|sed -r 's/binary-.*/&\/Packages.gz/g;s/source/&\/Sources.gz/g'|paste -sd,)}) | |
| printf "\e[3G - Testing ${#LTS_IDX_URLS[@]} URLs and downloading index files for \e[0;38;2;233;84;20mLTS\e[0m\n"; | |
| (printf '%s\n' ${LTS_IDX_URLS[@]}| awk -v D=${PAPI_DIR} -F/ '{A=$8;sub(/binary-/,"",A);print $0}')| \ | |
| xargs -rn1 -P0 bash -c 'export U=$0;export F=$(echo ${U//\//_}|sed "s/^.*__//");[[ $(curl -sSlL -o /dev/null -w "%{http_code}" ${U}) -eq 200 ]] && { printf "\r\e[K\r\e[8G - Fetching LTS index ${U//${LTS_REPO_URL}\//}\e[K\x20";wget2 -qO ${PAPI_DIR}/$F $U; }' | |
| declare -ag LTS_INDEXES=($(find 2>/dev/null ${PAPI_DIR} -maxdepth 1 -type f -iname "${LTS_SITE}*Packages.gz" -o -type f -iname "${LTS_SITE}*Sources.gz" |sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\r\e[K\r\e[3G - \e[0mDownloaded\e[0m ${#LTS_INDEXES[@]} \e[0;38;2;233;84;20mLTS \e[0mpackage and source index files ${OK}\n" | |
| # Ports Repo | |
| printf "\n\e[2GGathering package & project information from the \e[0;38;2;233;84;20mUbuntu™ \e[0;38;2;255;255;255mLTS\e[0m (Ports) Archive, aka \x22\e[0;38;2;233;84;20mPorts\e[0m\x22\e[0m\n" | |
| export PORTS_REPO_URL=https://ports.ubuntu.com/ubuntu-ports/dists | |
| export PORTS_SITE=$(echo ${PORTS_REPO_URL//https:\/\/}|sed -r 's/\/.*$//g') | |
| declare -ag PORTS_RELEASES=($(curl -sSlL ${PORTS_REPO_URL}|awk -v U="${PORTS_REPO_URL}" -F">|<" '/folder.gif/&&!/devel/{sub(/\/$|-.*/,"",$13);print $13}'|sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\e[3G - Found ${#PORTS_RELEASES[@]} \e[0;38;2;233;84;20mUbuntu™\e[0m releases for \e[0;38;2;233;84;20mPorts\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${PORTS_RELEASES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag PORTS_SUITES=($(for i in ${!PORTS_RELEASES[@]};do printf '%s\n' ${PORTS_RELEASES[$i]} ${PORTS_RELEASES[$i]}{-updates,-security,-backports,-proposed};done)) | |
| printf "\e[3G - Found ${#PORTS_SUITES[@]} suites for \e[0;38;2;233;84;20mPorts\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${PORTS_SUITES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag PORTS_ARCHES=($((eval printf '%s\\n' ${PORTS_REPO_URL}/{$(printf "%s\n" ${PORTS_SUITES[@]}|paste -sd,)}/{main,universe,multiverse,restricted}/|xargs -rn1 -P0 curl -sSlL |awk -F">|<" '/folder.gif/&&/binary|source/&&!/devel/{gsub(/\/$/,"",$13);print $13}')|sort -uV)) | |
| printf "\e[3G - Found ${#PORTS_ARCHES[@]} architectures for \e[0;38;2;233;84;20mPorts\e[0m (including source)\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${PORTS_ARCHES[@]//binary-/})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag PORTS_IDX_URLS=(); | |
| while IFS= read -r I;do | |
| PORTS_IDX_URLS+=("${I}"); | |
| done < <(eval printf '%s\\n' ${PORTS_REPO_URL}/{$(printf "%s\n" ${PORTS_SUITES[@]}|paste -sd,)}/{main,universe,multiverse,restricted}/{$(printf "%s\n" ${PORTS_ARCHES[@]}|sed -r 's/binary-.*/&\/Packages.gz/g;s/source/&\/Sources.gz/g'|paste -sd,)}) | |
| printf "\e[3G - Testing ${#PORTS_IDX_URLS[@]} URLs and downloading index files for \e[0;38;2;233;84;20mPorts\e[0m\n"; | |
| (printf '%s\n' ${PORTS_IDX_URLS[@]}|awk -v D=${PAPI_DIR} -F/ '{A=$8;sub(/binary-/,"",A);print $0}')| \ | |
| xargs -rn1 -P0 bash -c 'export U=$0;export F=$(echo ${U//\//_}|sed "s/^.*__//");[[ $(curl -sSlL -o /dev/null -w "%{http_code}" ${U}) -eq 200 ]] && { printf "\r\e[K\r\e[8G - Fetching Ports index ${U//${PORTS_REPO_URL}\//}\e[K\x20";wget2 -qO ${PAPI_DIR}/$F $U; }' | |
| declare -ag PORTS_INDEXES=($(find ${PAPI_DIR} -maxdepth 1 -type f -iname "${PORTS_SITE}*Packages.gz" -o -type f -iname "${PORTS_SITE}*Sources.gz" |sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\r\e[K\r\e[3G - \e[0mDownloaded\e[0m ${#PORTS_INDEXES[@]} \e[0;38;2;233;84;20mPorts \e[0mpackage and source index files ${OK}\n" | |
| # ESM Repo | |
| printf "\n\e[2GGathering package & project information from the \e[0;38;2;233;84;20mUbuntu™ \e[0;38;2;255;255;255mESM\e[0m Archive, aka \x22\e[0;38;2;233;84;20mESM\e[0m\x22\n" | |
| export ESM_REPO_URL=https://esm.ubuntu.com | |
| export ESM_SITE=$(echo ${ESM_REPO_URL//https:\/\/}|sed -r 's/\/.*$//g') | |
| declare -ag ESM_ENTITLEMENTS=($(curl -sSlL ${ESM_REPO_URL}|awk -F'>|<' '/^<a/&&!/"esm\//{gsub(/\/$/,"",$3);print $3}')) | |
| printf "\e[3G - Found ${#ESM_ENTITLEMENTS[@]} \e[0;38;2;233;84;20mUbuntu \e[0;38;2;255;255;255mPro\e[0;38;2;233;84;20m™\e[0m entitlements for \e[0;38;2;233;84;20mESM\e[0m\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${ESM_ENTITLEMENTS[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| printf "\e[3G - Fetching all architectures and releases for ${#ESM_ENTITLEMENTS[@]} \e[0;38;2;233;84;20mESM\e[0m entitlements\e[0m. Please wait...\n"; | |
| declare -ag ESM_RELEASES=($(for E in ${ESM_ENTITLEMENTS[@]};do ERURL=${ESM_REPO_URL}/${E}/ubuntu/dists;curl -sSlL $(curl -sSlL ${ERURL}|awk -v U=${ERURL} -F">|<" '/^<a /{gsub(/\/$/,"",$3);print U"/"$3"/main/"}')|awk -F '>|<' '/^<h|^<a/{gsub(/binary-|\/$/,"",$3);print $3}'|paste -sd,|sed -r 's/,,Index of \/|\/ubuntu\/dists\/|\/main/\|/g';done|sed -r 's/\r\|/\n\n/g;s/,$//g'|sed -r 's/,$//g;s/\|,/\|/g'|awk -F\| '!/^$/{OFS="+";print $1,$2,$3}')); | |
| printf "\e[3G - Found ${#ESM_RELEASES[@]} \e[0;38;2;233;84;20mUbuntu™\e[0m releases for \e[0;38;2;233;84;20mESM\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${ESM_RELEASES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag ESM_IDX_URLS=($(printf '%s\n' ${ESM_RELEASES[@]}|awk -v D=${PAPI_DIR} -v U="${ESM_REPO_URL}" -F"+" '{gsub(/esm-/,"",$1);n = split($3, a, ",");for (i = 0; ++i <= n;) print U"/"$1"/ubuntu/dists/"$2"/main/binary-"a[i]"/Packages.gz"}'|sed -r 's/binary-source\/Packages/source\/Sources/g;s/source_Packages.gz/source_Sources.gz/g')) | |
| declare -ag ESM_SUITES=($(printf '%s\n' "${ESM_IDX_URLS[@]}"|awk -F"/" '/Packages|Source/{print $(NF-3)}'|sort -uV)) | |
| printf "\e[3G - Found ${#ESM_SUITES[@]} suites for \e[0;38;2;233;84;20mESM\e[0m\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${ESM_SUITES[@]})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag ESM_ARCHES=($(printf '%s\n' "${ESM_IDX_URLS[@]}"|awk -F"/" '/Packages|Source/{print $(NF-1)}'|sort -uV)) | |
| printf "\e[3G - Found ${#ESM_ARCHES[@]} architectures for \e[0;38;2;233;84;20mESM\e[0m (including source)\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${ESM_ARCHES[@]//binary-/})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| printf "\e[3G - Testing ${#ESM_IDX_URLS[@]} URLs and downloading index files for \e[0;38;2;233;84;20mESM\e[0m\n"; | |
| printf '%s\n' "${ESM_IDX_URLS[@]}"| \ | |
| xargs -rn1 -P0 bash -c 'export U=$0;export F=$(echo ${U//\//_}|sed "s/^.*__//");[[ $(curl -sSlL -o /dev/null -w "%{http_code}" ${U}) -eq 200 ]] && { printf "\r\e[K\r\e[8G - Fetching ESM index ${U//${ESM_REPO_URL}\//}\e[K\x20";wget2 -qO ${PAPI_DIR}/$F $U; }' | |
| declare -ag ESM_INDEXES=($(find 2>/dev/null ${PAPI_DIR} -maxdepth 1 -type f -iname "${ESM_SITE}*Packages.gz" -o -type f -iname "${ESM_SITE}*Sources.gz"|sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\r\e[K\r\e[3G - \e[0mDownloaded\e[0m ${#ESM_INDEXES[@]} \e[0;38;2;233;84;20mESM\e[0m package and source index files ${OK}\n" | |
| # Ubuntu Cloud Archive "UCA" | |
| printf "\n\e[2GGathering package & project information from the \e[0;38;2;233;84;20mUbuntu™ \e[0;38;2;255;255;255mCloud Archive\e[0m, aka \x22\e[0;38;2;233;84;20mUCA\e[0m\x22\e[0m\n" | |
| export UCA_REPO_URL=https://ubuntu-cloud.archive.canonical.com/ubuntu/dists | |
| export UCA_SITE=$(echo ${UCA_REPO_URL//https:\/\/}|sed -r 's/\/.*$//g') | |
| declare -ag UCA_RELEASES=($(curl -sSlL ${UCA_REPO_URL}|awk -v U="${UCA_REPO_URL}" -F">|<" '/folder.gif/&&!/devel/{sub(/\/$|-.*/,"",$13);print $13}'|sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\e[3G - Found ${#UCA_RELEASES[@]} \e[0;38;2;233;84;20mUbuntu™\e[0m releases for \e[0;38;2;233;84;20mUCA\e[0m\n" | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${UCA_RELEASES[@]})|sed -r 's/[a-z0-9-+]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag UCA_SUITES=($(for i in ${!UCA_RELEASES[@]};do printf '%s\n' ${UCA_RELEASES[$i]}{-updates,-proposed};done)) | |
| declare -ag UCA_SUITES=($(eval printf '%s\\n' ${UCA_REPO_URL}/{$(printf "%s\n" ${UCA_SUITES[@]}|paste -sd,)}/|xargs -rn1 -P0 bash -c 'curl -sSlL $0|awk -v C=${0//http*dists\//} -F">|<" '"'"'/folder.gif/{gsub(/\/$/,"",$13);print C$13}'"'"''|sort -uV|sed -r '/.*-u.*|.*-p.*/!H;//p;$!d;g;s/\n//'|sed -r '/precise-up.*|precise-pr.*|trusty-up.*|trusty-pr.*|xenial-up.*|xenial-pr.*/!H;//p;$!d;g;s/\n//')) | |
| export OSR=$(printf '%s\n' ${UCA_SUITES[@]}|awk -F/ '!/ovn-|cloud-tools/{print $2}'|sort -uV|wc -l) RSUITES=$(printf '%s\n' ${UCA_SUITES[@]}|awk -F/ '!/ovn-|cloud-tools/{print $1}'|sort -uV|wc -l) | |
| printf "\e[3G - Found ${OSR} OpenStack releases across ${RSUITES} suites for \e[0;38;2;233;84;20mUCA\e[0m\n" | |
| declare -ag UCA_ARCHES=($((eval printf '%s\\n' ${UCA_REPO_URL}/{$(printf "%s\n" ${UCA_SUITES[@]}|paste -sd,)}/{main}/|xargs -rn1 -P0 curl -sSlL |awk -F">|<" '/folder.gif/&&/binary|source/&&!/devel/{gsub(/\/$/,"",$13);print $13}')|sort -uV)) | |
| printf "\e[3G - Found ${#UCA_ARCHES[@]} architectures for \e[0;38;2;233;84;20mUCA\e[0m (including source)\n"; | |
| [[ $DTAILS ]] && { pr -4t -s" " -W76 -o5 <(printf "▸\uFEFF%s\n" ${UCA_ARCHES[@]//binary-/})|sed -r 's/[a-z0-9-]+/'$(printf "\e[38;2;233;84;20m&\e[0m")'/g'; } | |
| declare -ag UCA_IDX_URLS=(); | |
| while IFS= read -r I;do | |
| UCA_IDX_URLS+=("${I}"); | |
| done < <(eval printf '%s\\n' ${UCA_REPO_URL}/{$(printf "%s\n" ${UCA_SUITES[@]}|paste -sd,)}/main/{$(printf "%s\n" ${UCA_ARCHES[@]}|sed -r 's/binary-.*/&\/Packages.gz/g;s/source/&\/Sources.gz/g'|paste -sd,)}) | |
| printf "\e[3G - Testing ${#UCA_IDX_URLS[@]} URLs and downloading index files for \e[0;38;2;233;84;20mUCA\e[0m\n"; | |
| (printf '%s\n' ${UCA_IDX_URLS[@]}| awk -v D=${PAPI_DIR} -F"/" '{A=$9;sub(/binary-/,"",A);print $0}')| \ | |
| xargs -rn1 -P0 bash -c 'export U=$0;export F=$(echo ${U//\//_}|sed "s/^.*__//");[[ $(curl -sSlL -o /dev/null -w "%{http_code}" ${U}) -eq 200 ]] && { printf "\r\e[K\r\e[8G - Fetching UCA index ${U//${UCA_REPO_URL}\//}\e[K\x20";wget2 -qO ${PAPI_DIR}/$F $U; }' | |
| declare -ag UCA_INDEXES=($(find ${PAPI_DIR} -maxdepth 1 -type f -iname "${UCA_SITE}*Packages.gz" -o -type f -iname "${UCA_SITE}*Sources.gz" |sort -uV|sed -r '/precise.*|trusty.*|xenial.*/!H;//p;$!d;g;s/\n//')) | |
| printf "\r\e[K\r\e[3G - \e[0mDownloaded\e[0m ${#UCA_INDEXES[@]} \e[0;38;2;233;84;20mUCA \e[0mpackage and source index files ${OK}\n" | |
| # Process the index files | |
| printf "\n\n\e[2G\e[0mAnalyzing \e[0;38;2;233;84;20mCanonical\e[0m \e[0;38;2;255;255;255mRepositories\e[0m\n" | |
| LINE="$(printf '\u2500%0.0s' {1..32})" | |
| printf "\e[2G${LINE}\n" | |
| printf "\n\e[2G\e[0;38;2;233;84;20mUbuntu™ \e[0;38;2;255;255;255mPackage & project information\e[0m stats:\n" | |
| printf "\e[3G - Total number of index files: $(ls -1 ${PAPI_DIR}/*.gz|wc -l)\n" | |
| printf "\e[3G - Total size of index files: $(du -sb ${PAPI_DIR}|awk '{print ($1/2**30),"GiB"}')\n" | |
| printf "\n\e[2GProcess \e[0;38;2;233;84;20m$(ls -1 ${PAPI_DIR}/*.gz|wc -l)\e[0m index files\n" | |
| # Process LTS Indexes | |
| printf "\e[3G - Processing ${#LTS_INDEXES[@]} \e[0;38;2;233;84;20mLTS\e[0m index files\e[K\n" | |
| declare -ag LTS_SIZES=( | |
| $(for Y in ${LTS_INDEXES[@]};do | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null $Y|awk 2>/dev/null -v F="${Y%_*}" '/^Size: /{PSZE+=$2;PCNT++}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",PCNT,PSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null $Y|awk 2>/dev/null -v F="${Y%_*}" '/^Files:/{flag=1; next} /^Checksums-Sha1:|^Uploaders|^Python-Version|^Vcs-Svn|^Package-List| deb/{flag=0} flag && NF>0 { SCNT++;SSZE+=$2}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",SCNT,SSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| done;) | |
| ) | |
| for Y in ${LTS_INDEXES[@]};do | |
| F=${Y##*/};F=${F//${LTS_SITE}/};F=${F//ubuntu_dists_/}; | |
| printf 1>&2 "\r\e[K\r\e[3G\e[0;3m - Parsing ${F}\e[0m\e[K\r" | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Version:") {V=$2;W=$2};if ($1 == "Source:") S=$2;if ($1 == "Filename:") F=$2;OFS="|";gsub(/~.*|^[0-9]:|\+.*/,"",W);if ($1 == "Size:") print P,V,C"/"gensub(/(.*)\/[^/]+$/,"\\1","g",F)"/"P"_"V"/copyright",$2;next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Binary:") B=$0;gsub(/Binary: /,"",B);if ($1 == "Version:") {V=$2;W=$2};OFS="|";gsub(/~.*|^[0-9]:/,"",W);if ($1 == "Directory:") print P,B,V,C"/"$2"/"P"_"W"/copyright";next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| done; | |
| printf "\r\e[K\e[1A\r\e[K\r\e[3G - Processed ${#LTS_INDEXES[@]} \e[0;38;2;233;84;20mLTS\e[0m index files ${OK}\e[K\e[0m\n" | |
| # Process PORTS Indexes | |
| printf "\e[3G - Processing ${#PORTS_INDEXES[@]} \e[0;38;2;233;84;20mPorts\e[0m index files\e[K\n" | |
| declare -ag PORTS_SIZES=( | |
| $(for Y in ${PORTS_INDEXES[@]};do | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat $Y|awk -v F="${Y%_*}" '/^Size: /{PSZE+=$2;PCNT++}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",PCNT,PSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat $Y|awk -v F="${Y%_*}" '/^Files:/{flag=1; next} /^Checksums-Sha1:|^Uploaders|^Python-Version|^Vcs-Svn|^Package-List| deb/{flag=0} flag && NF>0 { SCNT++;SSZE+=$2}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",SCNT,SSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| done;) | |
| ) | |
| for Y in ${PORTS_INDEXES[@]};do | |
| F=${Y##*/};F=${F//${PORTS_SITE}/};F=${F//ubuntu_dists_/}; | |
| printf 1>&2 "\r\e[K\r\e[3G\e[0;3m - Parsing ${F}\e[0m\e[K\r" | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Version:") {V=$2;W=$2};if ($1 == "Source:") S=$2;if ($1 == "Filename:") F=$2;OFS="|";gsub(/~.*|^[0-9]:|\+.*/,"",W);if ($1 == "Size:") print P,V,C"/"gensub(/(.*)\/[^/]+$/,"\\1","g",F)"/"S"_"W"/copyright",$2;next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Binary:") B=$0;gsub(/Binary: /,"",B);if ($1 == "Version:") {V=$2;W=$2};OFS="|";gsub(/~.*|^[0-9]:/,"",W);if ($1 == "Directory:") print P,B,V,C"/"$2"/"P"_"W"/copyright";next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| done; | |
| printf "\r\e[K\e[1A\r\e[K\r\e[3G - Processed ${#PORTS_INDEXES[@]} \e[0;38;2;233;84;20mPorts\e[0m index files ${OK}\e[K\e[0m\n" | |
| # Process ESM Indexes | |
| printf "\e[3G - Processing ${#ESM_INDEXES[@]} \e[0;38;2;233;84;20mESM\e[0m index files\e[0m\n" | |
| declare -ag ESM_SIZES=( | |
| $(for Y in ${ESM_INDEXES[@]};do | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v F="${Y%_*}" '/^Size: /{PSZE+=$2;PCNT++}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",PCNT,PSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v F="${Y%_*}" '/^Files:/,/^Checksums-Sha1/{if(/^Files:/) SCNT++;SSZE+=$2}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",SCNT,SSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| done) | |
| ); | |
| for Y in ${ESM_INDEXES[@]};do | |
| F=${Y##*/};F=${F//${ESM_SITE}/};F=${F//ubuntu_dists_/}; | |
| printf 1>&2 "\r\e[K\r\e[3G\e[0;3m - Parsing ${F}\e[0m\e[K\r" | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Version:") {V=$2;W=$2};if ($1 == "Source:") S=$2;if ($1 == "Filename:") F=$2;OFS="|";gsub(/~.*|^[0-9]:|\+.*/,"",W);if ($1 == "Size:") print P,V,C"/"gensub(/(.*)\/[^/]+$/,"\\1","g",F)"/"S"_"W"/copyright",$2;next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") {P=$2;Q=$2};if ($1 == "Binary:") B=$0;gsub(/Binary: /,"",B);if ($1 == "Version:") {V=$2;W=$2};OFS="|";gsub(/~.*|^[0-9]:|\+.*/,"",W);if ($1 == "Directory:") print P,B,V,C"/"$2"/"Q"_"W"/copyright";next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| done; | |
| printf "\r\e[K\e[1A\r\e[K\r\e[3G - Processed ${#ESM_INDEXES[@]} \e[0;38;2;233;84;20mESM\e[0m index files ${OK}\e[K\e[0m\n" | |
| printf "\e[3G - Processing ${#UCA_INDEXES[@]} \e[0;38;2;233;84;20mUCA\e[0m index files\e[0m\n" | |
| # Process UCA Indexes | |
| declare -ag UCA_SIZES=( | |
| $(for Y in ${UCA_INDEXES[@]};do | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null $Y|awk 2>/dev/null -v F="${Y%_*}" '/^Size: /{PSZE+=$2;PCNT++}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",PCNT,PSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null $Y|awk 2>/dev/null -v F="${Y%_*}" '/^Files:/{flag=1; next} /^Checksums-Sha1:|^Uploaders|^Python-Version|^Vcs-Svn|^Package-List| deb/{flag=0} flag && NF>0 { SCNT++;SSZE+=$2}END { printf F"|";printf "%'"'"'d|%'"'"'s\n",SCNT,SSZE}'|sed -r 's/0\|$/0\|0/g'; }; | |
| done;) | |
| ) | |
| for Y in ${UCA_INDEXES[@]};do | |
| F=${Y##*/};F=${F//${UCA_SITE}/};F=${F//ubuntu_dists_/}; | |
| printf 1>&2 "\r\e[K\r\e[3G\e[0;3m - Parsing ${F}\e[0m\e[K\r" | |
| [[ ${Y##*_} = Packages.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Version:") {V=$2;W=$2};if ($1 == "Source:") S=$2;if ($1 == "Filename:") F=$2;OFS="|";gsub(/~.*|^[0-9]:|\+.*/,"",W);if ($1 == "Size:") print P,V,C"/"gensub(/(.*)\/[^/]+$/,"\\1","g",F)"/"S"_"W"/copyright",$2;next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| [[ ${Y##*_} = Sources.gz ]] && { zcat 2>/dev/null ${Y}|awk 2>/dev/null -v C="https://changelogs.ubuntu.com/changelogs" '{if ($1 == "Package:") P=$2;if ($1 == "Binary:") B=$0;gsub(/Binary: /,"",B);if ($1 == "Version:") {V=$2;W=$2};OFS="|";gsub(/~.*|^[0-9]:/,"",W);if ($1 == "Directory:") print P,B,V,C"/"$2"/"P"_"W"/copyright";next}'|tee ${Y%_*}.psv 1>/dev/null; } | |
| done; | |
| printf "\r\e[K\e[1A\r\e[K\r\e[3G - Processed ${#UCA_INDEXES[@]} \e[0;38;2;233;84;20mUCA\e[0m index files ${OK}\e[K\e[0m\n" | |
| # Show full Repo sizes (All releases, all architectures) | |
| printf "\n\e[2G\e[0m\e[0;38;2;233;84;20mCanonical \e[0;38;2;255;255;255mRepositories \e[0m(All releases and architectures)\e[0m\n" | |
| LINE="$(printf '\u2500%0.0s' {1..96})" | |
| printf "\e[2G${LINE}\n" | |
| LTS_TOTALS=0;for S in $(printf '%s\n' ${LTS_SIZES[@]##*|});do LTS_TOTALS=$(($LTS_TOTALS+$S));done;unset S; | |
| PORTS_TOTALS=0;for S in $(printf '%s\n' ${PORTS_SIZES[@]##*|});do PORTS_TOTALS=$(($PORTS_TOTALS+$S));done;unset S; | |
| ESM_TOTALS=0;for S in $(printf '%s\n' ${ESM_SIZES[@]##*|});do ESM_TOTALS=$(($ESM_TOTALS+$S));done;unset S; | |
| UCA_TOTALS=0;for S in $(printf '%s\n' ${UCA_SIZES[@]##*|});do UCA_TOTALS=$(($UCA_TOTALS+$S));done;unset S; | |
| ALL_TOTALS=$((${LTS_TOTALS}+${PORTS_TOTALS}+${ESM_TOTALS}+${UCA_TOTALS})) | |
| (printf "\n\n|B|KiB|MiB|GiB|TiB\n"; | |
| printf "Ubuntu™ LTS (Intel/AMD) Repository:|$LTS_TOTALS|$(($LTS_TOTALS/2**10))|$(($LTS_TOTALS/2**20))|$(($LTS_TOTALS/2**30))|$(($LTS_TOTALS/2**40))\n"; | |
| printf "Ubuntu™ LTS (Ports) Repository:|$PORTS_TOTALS|$(($PORTS_TOTALS/2**10))|$(($PORTS_TOTALS/2**20))|$(($PORTS_TOTALS/2**30))|$(($PORTS_TOTALS/2**40))\n"; | |
| printf "Ubuntu™ ESM Repository:|$ESM_TOTALS|$(($ESM_TOTALS/2**10))|$(($ESM_TOTALS/2**20))|$(($ESM_TOTALS/2**30))|$(($ESM_TOTALS/2**40))\n"; | |
| printf "Ubuntu™ Cloud Archive:|$UCA_TOTALS|$(($UCA_TOTALS/2**10))|$(($UCA_TOTALS/2**20))|$(($UCA_TOTALS/2**30))|$(($UCA_TOTALS/2**40))\n"; | |
| LINE="$(printf '\u2550%0.0s' {1..15})"; | |
| printf "|${LINE}|${LINE}|${LINE}|${LINE}|${LINE}\n"; | |
| printf "\n\nTotal Ubuntu™ Archive Size(s):|$ALL_TOTALS|$(($ALL_TOTALS/2**10))|$(($ALL_TOTALS/2**20))|$(($ALL_TOTALS/2**30))|$(($ALL_TOTALS/2**40))\n"; | |
| )|column -ets"|"|sed -r 's/B.*TiB|Ubuntu™|:/'$(printf "\e[0;1;38;2;233;84;32m&\e[0m")'/g'; | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment