Last active
June 17, 2025 20:42
-
-
Save ThinGuy/f3f6dce648e43358be6ed03fc635c923 to your computer and use it in GitHub Desktop.
Create package manifests for all current LTS, Interim, and ESM Ubuntu releases
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 ARCH=amd64 | |
export MDIR=~/manifests | |
[[ -f ${MDIR} ]] && { find ${MDIR} -type f -delete -o type d -delete; } || { mkdir -p ${MDIR}; } | |
declare -ag UBU_REL_SHORT=($(ubuntu-distro-info --supported-esm && ubuntu-distro-info --supported)) | |
declare -ag UBU_REL_LONG=() | |
while IFS= read -r LINE;do | |
UBU_REL_LONG+=("${LINE}"); | |
done < <((ubuntu-distro-info --supported-esm -f && ubuntu-distro-info --supported -f)|sed -r 's/\x22//g') | |
# Debian Package index sections. Needed to get a complete list for main, since it's not listed under section | |
declare -ag SECTIONS=(admin cli-mono comm database debug devel doc editors education electronics embedded fonts games gnome gnu-r gnustep graphics hamradio haskell httpd interpreters introspection java javascript kde kernel libdevel libs lisp localization mail math metapackages misc net news ocaml oldlibs otherosfs perl php python ruby rust science shells sound tasks tex text utils vcs video web x11 xfce zope) | |
printf "\n\e[1m\e[1GUbuntu Package Manifest Maker\e[0m\n\e[2GPackage manifest maker for ${#UBU_REL_SHORT[@]} Ubuntu releases (Supported + ESM)\n" | |
# Create isolated environments | |
for R in ${!UBU_REL_SHORT[@]};do | |
printf "\n\r\e[K\r\e[2G\e[1mCreating an isolated APT environment for \e[0;1;38;2;233;84;20m${UBU_REL_LONG[${R}]}\e[0;1m (${ARCH})\e[0m\e[K\n" | |
export CACHE_DIR=${MDIR}/apt_${UBU_REL_SHORT[${R}]}_${ARCH} | |
mkdir -p ${CACHE_DIR}/{archives,lists} | |
export SOURCES_FILE=${MDIR}/sources_${UBU_REL_SHORT[${R}]}_${ARCH}.list | |
# Create sources.list for specific release | |
printf "\r\e[K\r\e[2G - Creating sources.list for \e[0;1;38;2;233;84;20mUbuntu ${UBU_REL_SHORT[${R}]}\e[0m (\e[3m${SOURCES_FILE}\e[0m)\e[K\n"; | |
cat > "${SOURCES_FILE}" << EOF | |
deb [trusted=yes arch=${ARCH}] https://us.archive.ubuntu.com/ubuntu ${UBU_REL_SHORT[${R}]} main universe multiverse restricted | |
deb [trusted=yes arch=${ARCH}] https://us.archive.ubuntu.com/ubuntu ${UBU_REL_SHORT[${R}]}-updates main universe multiverse restricted | |
deb [trusted=yes arch=${ARCH}] https://us.archive.ubuntu.com/ubuntu ${UBU_REL_SHORT[${R}]}-security main universe multiverse restricted | |
deb [trusted=yes arch=${ARCH}] https://us.archive.ubuntu.com/ubuntu ${UBU_REL_SHORT[${R}]}-backports main universe multiverse restricted | |
EOF | |
# Update package lists in isolation | |
printf "\r\e[K\r\e[2G - Updating available packages for \e[0;1;38;2;233;84;20mUbuntu ${UBU_REL_SHORT[${R}]^}\e[0m\e[K\n" | |
(sudo apt &>/dev/null \ | |
-o Dir::Cache="${CACHE_DIR}" \ | |
-o Dir::State::lists="${CACHE_DIR}/lists" \ | |
-o Dir::Etc::sourcelist="${SOURCES_FILE}" \ | |
-o Dir::Etc::sourceparts="/dev/null" \ | |
update) | |
# Get Main component by cycling through all the sections. Regex support not advanced enough to support or | |
printf "\r\e[K\r\e[6G - Listing packages for \e[0;1;38;2;233;84;20mUbuntu ${UBU_REL_SHORT[${R}]^}\e[0m: Main\e[K\n" | |
(printf '%s\n' ${SECTIONS[@]}|xargs -rn1 -P0 bash -c ' | |
apt -qqq 2>/dev/null \ | |
-o Dir::Cache="'${CACHE_DIR}'" \ | |
-o Dir::State::lists="'${CACHE_DIR}'/lists" \ | |
-o Dir::Etc::sourcelist="'${SOURCES_FILE}'" \ | |
-o Dir::Etc::sourceparts="/dev/null" \ | |
list "?section(^${0}$)"'|sed -r '/^$|^Llisting|^All|^WARNING/d'|sort -uV)|awk -F"/| " '/^[a-z0-9]+/{OFS="\t";print $1,$3}'|tee -a ${MDIR}/${UBU_REL_SHORT[${R}]}_main_${ARCH}.manifest 1>/dev/null; | |
# Get Universe, Multiverse, and Restricted | |
for C in universe multiverse restricted;do | |
printf "\r\e[K\r\e[6G - Listing packages for \e[0;1;38;2;233;84;20mUbuntu ${UBU_REL_SHORT[${R}]^}\e[0m: ${C^}\e[K\n"; | |
(apt -qqq 2>/dev/null \ | |
-o Dir::Cache="${CACHE_DIR}" \ | |
-o Dir::State::lists="${CACHE_DIR}"/lists \ | |
-o Dir::Etc::sourcelist="${SOURCES_FILE}" \ | |
-o Dir::Etc::sourceparts="/dev/null" \ | |
list "?section(^${C}/)")|sed -r '/^$|^[Ll]isting|^All|^WARNING/d'|sort -uV|awk -F"/| " '/^[a-z0-9]+/{OFS="\t";print $1,$3}'|tee ${MDIR}/${UBU_REL_SHORT[${R}]}_${C}_${ARCH}.manifest 1>/dev/null; | |
done | |
printf "\r\e[K\r\e[4G\e[0;3mManifests for \e[0;3;38;2;233;84;20m${UBU_REL_LONG[${R}]}\e[0;3m complete\x21\e[0m\e[K\n" | |
done | |
for R in "${!UBU_REL_LONG[@]}";do | |
printf "\n\e[1m\e[2G\e[0;1;38;2;233;84;20m${UBU_REL_LONG[${R}]}:\e[0m\n"; | |
(for i in $(find ${MDIR} -maxdepth 1 -type f -iname "${UBU_REL_SHORT[${R}]}*.manifest");do printf '\e[2G - \e[0;3m\e]8;;file://'${i}'\e\\'${i}'\e]8;;\e\\\e[0;3m: '$(cat ${i}|wc -l)' files\e[0m\n';done)|sort -uV|sed -r '/main.*|universe.*|multiverse.*|restricted.*/!H;//p;$!d;g;s/\n//' | |
done | |
printf "\n\n\e[1G\e[1mUbuntu Package Manifest Maker complete\x21\e[K\e[0m\n\n" |
Author
ThinGuy
commented
Jun 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment