Skip to content

Instantly share code, notes, and snippets.

@kyle0r
Last active October 25, 2025 13:31
Show Gist options
  • Save kyle0r/d180365a1f02b73054cb000cc7802e8b to your computer and use it in GitHub Desktop.
Save kyle0r/d180365a1f02b73054cb000cc7802e8b to your computer and use it in GitHub Desktop.
capturing steps + python script to read apt Packages files

Steps performed on a Debian bookworm node

sudo apt install python3-venv

mkdir ~/py-apt && cd $_

python3 -m venv --system-site-packages .venv

source .venv/bin/activate

# update pip and wheel
python3 -m pip install --upgrade pip wheel

# https://salsa.debian.org/python-debian-team/python-debian
python3 -m pip install --upgrade python-debian

# create the read_package.py script

python3 read_package.py
import apt
from debian import deb822
from os.path import expanduser
for pkg in deb822.Packages.iter_paragraphs(open(expanduser('~/Downloads/Packages'))):
if 'amd64' == pkg['Architecture']:
print(pkg['Package'], pkg['Filename'], pkg['version'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment