[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt policy / listing packages from repo



On Thu 10 Aug 2023, at 18:54, Sven Joachim <svenjoac@gmx.de> wrote:
> On 2023-08-10 09:30 -0500, David Wright wrote:
>
>>> I was looking for a way to list packages installed from a particular
>>> repo and/or sub-repo or whatever it's called (eg. main, non-free).
>>> 
>>> Does anyone know of a way to do this, with apt policy or otherwise?
>>
>> What I do in this situation is to type "apt" and press TAB twice.
>> Look at the resulting list of commands and check the man page for
>> the most likely looking, in this case apt-cache.
>>
>> An alternative method of course is to type   apt policy   into any
>> search engine. This will typically tell you not only how to invoke
>> the command, but also more about what it produces.
>>
>> As for your listing, I've done this in the past with a script that
>> runs apt-cache dump, grepping the Package/Version/File lines,
>> concatenating and sorting them, then filtering that list against
>> the output of dpkg-query -W -f to include only installed packages.
>> This yields a list like:
>>
>>   Package: acl Version: 2.2.53-10 File: /var/lib/apt/lists/deb.debian.org_debian_dists_bullseye_main_binary-amd64_Packages
>>   Package: adduser Version: 3.118 File: /var/lib/apt/lists/deb.debian.org_debian_dists_bullseye_main_binary-amd64_Packages
>>   [ … … ]
>>   Package: xtoolwait Version: 1.3-6.2 File: /var/lib/dpkg/status
>>   [ … … ]
>>   Package: yt-dlp Version: 2023.03.04-1~bpo11+1 File: /var/lib/dpkg/status
>>
>> which you can grep for particular subsets, though I'm usually more
>> interested in grep -v for packages originating from elsewhere,
>> like xtoolwait (squeeze) and yt-dlp (backports) there.
>>
>> There may well be better ways.
>
> I would probably use "apt list" with a search pattern described in
> apt-patterns(7), e.g. the following command lists all installed packages
> from non-free:
>
> $ apt list '~i ~snon-free/'
>
> Lots of interesting possibilities one can toy with. :-)

I will look into both approaches - my thanks to you and David.

G


Reply to: