I'm trying to get a list of packages installed which come from my company's private apt repository.
This works:
#!/bin/bash
fqdn=$1
for pkg in $(dpkg-query --show | awk '{print $1;}'); do
if apt-cache showpkg $pkg | grep -q $fqdn; then
echo $pkg
fi
done
But running it on a system with ~3466 (dpkg -l | wc -l
) packages installed takes 1m45.812s. That's an awful long time to display a "Scanning locally for installed packages" to my users.
Is there a better way to do this?
---
I tried replacing apt-cache showpkg
with apt show
to read the APT-Sources:
line. This warns about apt's unstable CLI interface and takes 15m35.913s.
Asked by Stewart
(15631 rep)
Jan 25, 2021, 03:04 PM
Last activity: Jun 7, 2025, 09:12 PM
Last activity: Jun 7, 2025, 09:12 PM