NB: Also the licenses for these can be found inside the packages or in /usr/share/doc/<pkgname>/copyright if anyone else would benefit from this information.
Hamish On 14/03/2019 16:55, Hamish MB wrote: > Ralph, > > I have come to the same conclusion, but that will do just fine for me. I have > posted the script here in case anyone else finds it useful. > > The script I ended up using is as follows: > > """ > > #!/bin/bash > > RED='\033[0;31m' > GREEN='\033[0;32m' > YELLOW='\033[1;33m' > NC='\033[0m' > > for pkg in $(dpkg --get-selections) > do > component=$(apt-cache policy $pkg | grep "http" | awk '{print $3}') > component=$(echo $component | awk '{print $0}') > > #if [[ $component == *"main" || $component == *"contrib" ]] > #then > # echo -e "${YELLOW}$pkg:${NC} ${GREEN}$component${NC}" > # > #fi > > if [[ $component == *"non-free" ]] > then > echo -e "${YELLOW}$pkg:${NC} ${RED}$component${NC}" > > fi > done > > """ > > It took a while to write this, because I'm not familiar with weird bash > syntax, but it seems to work fine, if a bit slowly. Uncomment the commented > lines for a readout of other packages too. > > NOTE: The component names are different in Ubuntu and derivatives so it won't > work quite right on them, though i can easily be adapted. > > Hamish > > On 14/03/2019 16:18, Ralph Corderoy wrote: > > Hi Hamish, > > > > I was wondering if any of you had found a good way to list all > installed packages from a particular source (eg the "restricted" > component) on Debian-based systems? Basically I want to do this so I > can programmatically check exactly which non-OSS packages are > installed w/o there being any risk of me missing one, and without > going through every single package manually. > > > I don't think Debian's APT packaging system records where it installed a > package from. You can look instead at where that package is available > now. Not quite the same thing. I could be wrong, my main system hasn't > been APT-based for a while. > > This gives you a start. > > cd /var/lib/apt/lists && > fgrep -xf <(dpkg-query -Wf 'Package: ${package}\n') *_Packages > > It takes a list of installed packages and looks for the matching lines > in the indexes of what's available. That means they're sorted by > source, which is handy. The bad news is you get duplicates because some > packages are available in i386 and amd64. Also, you need to check that > every package you have installed has been found, so that command needs > expanding a little with some more checks. > > -- Next meeting: BEC, Bournemouth, Tuesday, 2019-04-02 20:00 Check to whom you are replying Meetings, mailing list, IRC, ... http://dorset.lug.org.uk/ New thread, don't hijack: mailto:dorset@mailman.lug.org.uk