Skip to content

Instantly share code, notes, and snippets.

@ThinGuy
Last active June 17, 2025 20:42
Show Gist options
  • Save ThinGuy/f3f6dce648e43358be6ed03fc635c923 to your computer and use it in GitHub Desktop.
Save ThinGuy/f3f6dce648e43358be6ed03fc635c923 to your computer and use it in GitHub Desktop.
Create package manifests for all current LTS, Interim, and ESM Ubuntu releases
#!/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"
@ThinGuy
Copy link
Author

ThinGuy commented Jun 17, 2025

craigbender@cbpc:~/$ apt-manifest-maker.sh 

Ubuntu Package Manifest Maker
 Package manifest maker for 10 Ubuntu releases (Supported + ESM)

 Creating an isolated APT environment for Ubuntu 16.04 LTS Xenial Xerus (amd64)
  - Creating sources.list for Ubuntu xenial (/home/craigbender/manifests/sources_xenial_amd64.list)
  - Updating available packages for Ubuntu Xenial
      - Listing packages for Ubuntu Xenial: Main
      - Listing packages for Ubuntu Xenial: Universe
      - Listing packages for Ubuntu Xenial: Multiverse
      - Listing packages for Ubuntu Xenial: Restricted
   Manifests for Ubuntu 16.04 LTS Xenial Xerus complete!

 Creating an isolated APT environment for Ubuntu 18.04 LTS Bionic Beaver (amd64)
  - Creating sources.list for Ubuntu bionic (/home/craigbender/manifests/sources_bionic_amd64.list)
  - Updating available packages for Ubuntu Bionic
      - Listing packages for Ubuntu Bionic: Main
      - Listing packages for Ubuntu Bionic: Universe
      - Listing packages for Ubuntu Bionic: Multiverse
      - Listing packages for Ubuntu Bionic: Restricted
   Manifests for Ubuntu 18.04 LTS Bionic Beaver complete!

 Creating an isolated APT environment for Ubuntu 20.04 LTS Focal Fossa (amd64)
  - Creating sources.list for Ubuntu focal (/home/craigbender/manifests/sources_focal_amd64.list)
  - Updating available packages for Ubuntu Focal
      - Listing packages for Ubuntu Focal: Main
      - Listing packages for Ubuntu Focal: Universe
      - Listing packages for Ubuntu Focal: Multiverse
      - Listing packages for Ubuntu Focal: Restricted
   Manifests for Ubuntu 20.04 LTS Focal Fossa complete!

 Creating an isolated APT environment for Ubuntu 22.04 LTS Jammy Jellyfish (amd64)
  - Creating sources.list for Ubuntu jammy (/home/craigbender/manifests/sources_jammy_amd64.list)
  - Updating available packages for Ubuntu Jammy
      - Listing packages for Ubuntu Jammy: Main
      - Listing packages for Ubuntu Jammy: Universe
      - Listing packages for Ubuntu Jammy: Multiverse
      - Listing packages for Ubuntu Jammy: Restricted
   Manifests for Ubuntu 22.04 LTS Jammy Jellyfish complete!

 Creating an isolated APT environment for Ubuntu 24.04 LTS Noble Numbat (amd64)
  - Creating sources.list for Ubuntu noble (/home/craigbender/manifests/sources_noble_amd64.list)
  - Updating available packages for Ubuntu Noble
      - Listing packages for Ubuntu Noble: Main
      - Listing packages for Ubuntu Noble: Universe
      - Listing packages for Ubuntu Noble: Multiverse
      - Listing packages for Ubuntu Noble: Restricted
   Manifests for Ubuntu 24.04 LTS Noble Numbat complete!

 Creating an isolated APT environment for Ubuntu 22.04 LTS Jammy Jellyfish (amd64)
  - Creating sources.list for Ubuntu jammy (/home/craigbender/manifests/sources_jammy_amd64.list)
  - Updating available packages for Ubuntu Jammy
      - Listing packages for Ubuntu Jammy: Main
      - Listing packages for Ubuntu Jammy: Universe
      - Listing packages for Ubuntu Jammy: Multiverse
      - Listing packages for Ubuntu Jammy: Restricted
   Manifests for Ubuntu 22.04 LTS Jammy Jellyfish complete!

 Creating an isolated APT environment for Ubuntu 24.04 LTS Noble Numbat (amd64)
  - Creating sources.list for Ubuntu noble (/home/craigbender/manifests/sources_noble_amd64.list)
  - Updating available packages for Ubuntu Noble
      - Listing packages for Ubuntu Noble: Main
      - Listing packages for Ubuntu Noble: Universe
      - Listing packages for Ubuntu Noble: Multiverse
      - Listing packages for Ubuntu Noble: Restricted
   Manifests for Ubuntu 24.04 LTS Noble Numbat complete!

 Creating an isolated APT environment for Ubuntu 24.10 Oracular Oriole (amd64)
  - Creating sources.list for Ubuntu oracular (/home/craigbender/manifests/sources_oracular_amd64.list)
  - Updating available packages for Ubuntu Oracular
      - Listing packages for Ubuntu Oracular: Main
      - Listing packages for Ubuntu Oracular: Universe
      - Listing packages for Ubuntu Oracular: Multiverse
      - Listing packages for Ubuntu Oracular: Restricted
   Manifests for Ubuntu 24.10 Oracular Oriole complete!

 Creating an isolated APT environment for Ubuntu 25.04 Plucky Puffin (amd64)
  - Creating sources.list for Ubuntu plucky (/home/craigbender/manifests/sources_plucky_amd64.list)
  - Updating available packages for Ubuntu Plucky
      - Listing packages for Ubuntu Plucky: Main
      - Listing packages for Ubuntu Plucky: Universe
      - Listing packages for Ubuntu Plucky: Multiverse
      - Listing packages for Ubuntu Plucky: Restricted
   Manifests for Ubuntu 25.04 Plucky Puffin complete!

 Creating an isolated APT environment for Ubuntu 25.10 Questing Quokka (amd64)
  - Creating sources.list for Ubuntu questing (/home/craigbender/manifests/sources_questing_amd64.list)
  - Updating available packages for Ubuntu Questing
      - Listing packages for Ubuntu Questing: Main
      - Listing packages for Ubuntu Questing: Universe
      - Listing packages for Ubuntu Questing: Multiverse
      - Listing packages for Ubuntu Questing: Restricted
   Manifests for Ubuntu 25.10 Questing Quokka complete!

 Ubuntu 16.04 LTS Xenial Xerus:
  - /home/craigbender/manifests/xenial_main_amd64.manifest: 23842 files
  - /home/craigbender/manifests/xenial_multiverse_amd64.manifest: 791 files
  - /home/craigbender/manifests/xenial_restricted_amd64.manifest: 56 files
  - /home/craigbender/manifests/xenial_universe_amd64.manifest: 46517 files


 Ubuntu 18.04 LTS Bionic Beaver:
  - /home/craigbender/manifests/bionic_main_amd64.manifest: 42652 files
  - /home/craigbender/manifests/bionic_multiverse_amd64.manifest: 920 files
  - /home/craigbender/manifests/bionic_restricted_amd64.manifest: 7513 files
  - /home/craigbender/manifests/bionic_universe_amd64.manifest: 55587 files


 Ubuntu 20.04 LTS Focal Fossa:
  - /home/craigbender/manifests/focal_main_amd64.manifest: 51348 files
  - /home/craigbender/manifests/focal_multiverse_amd64.manifest: 906 files
  - /home/craigbender/manifests/focal_restricted_amd64.manifest: 21767 files
  - /home/craigbender/manifests/focal_universe_amd64.manifest: 54196 files


 Ubuntu 22.04 LTS Jammy Jellyfish:
  - /home/craigbender/manifests/jammy_main_amd64.manifest: 74864 files
  - /home/craigbender/manifests/jammy_multiverse_amd64.manifest: 1072 files
  - /home/craigbender/manifests/jammy_restricted_amd64.manifest: 20350 files
  - /home/craigbender/manifests/jammy_universe_amd64.manifest: 59360 files


 Ubuntu 24.04 LTS Noble Numbat:
  - /home/craigbender/manifests/noble_main_amd64.manifest: 41512 files
  - /home/craigbender/manifests/noble_multiverse_amd64.manifest: 1186 files
  - /home/craigbender/manifests/noble_restricted_amd64.manifest: 6673 files
  - /home/craigbender/manifests/noble_universe_amd64.manifest: 65536 files


 Ubuntu 22.04 LTS Jammy Jellyfish:
  - /home/craigbender/manifests/jammy_main_amd64.manifest: 74864 files
  - /home/craigbender/manifests/jammy_multiverse_amd64.manifest: 1072 files
  - /home/craigbender/manifests/jammy_restricted_amd64.manifest: 20350 files
  - /home/craigbender/manifests/jammy_universe_amd64.manifest: 59360 files


 Ubuntu 24.04 LTS Noble Numbat:
  - /home/craigbender/manifests/noble_main_amd64.manifest: 41512 files
  - /home/craigbender/manifests/noble_multiverse_amd64.manifest: 1186 files
  - /home/craigbender/manifests/noble_restricted_amd64.manifest: 6673 files
  - /home/craigbender/manifests/noble_universe_amd64.manifest: 65536 files


 Ubuntu 24.10 Oracular Oriole:
  - /home/craigbender/manifests/oracular_main_amd64.manifest: 15536 files
  - /home/craigbender/manifests/oracular_multiverse_amd64.manifest: 1055 files
  - /home/craigbender/manifests/oracular_restricted_amd64.manifest: 1501 files
  - /home/craigbender/manifests/oracular_universe_amd64.manifest: 65184 files


 Ubuntu 25.04 Plucky Puffin:
  - /home/craigbender/manifests/plucky_main_amd64.manifest: 11810 files
  - /home/craigbender/manifests/plucky_multiverse_amd64.manifest: 1095 files
  - /home/craigbender/manifests/plucky_restricted_amd64.manifest: 267 files
  - /home/craigbender/manifests/plucky_universe_amd64.manifest: 67234 files


 Ubuntu 25.10 Questing Quokka:
  - /home/craigbender/manifests/questing_main_amd64.manifest: 13042 files
  - /home/craigbender/manifests/questing_multiverse_amd64.manifest: 1171 files
  - /home/craigbender/manifests/questing_restricted_amd64.manifest: 264 files
  - /home/craigbender/manifests/questing_universe_amd64.manifest: 67666 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment