On Sun, Oct 23, 2016 at 8:48 PM, kamaraju kusumanchi <raju.mailingli...@gmail.com> wrote: > How can I list all the packages installed on my system that are > currently part of the stable distribution but not present in either > testing or sid? > > For example, libkasten2okteta1controllers1abi1 libkasten2okteta1gui1 > are currently part of stable, but not present in either testing or > sid. The command should list these packages if they are currently > installed. > > If it matters, here are the repos I am tracking. > % inxi -r > Repos: Active apt sources in file: /etc/apt/sources.list > deb http://httpredir.debian.org/debian/ stretch main contrib > non-free > deb-src http://httpredir.debian.org/debian/ stretch main > contrib non-free > deb http://httpredir.debian.org/debian/ stretch-updates > main contrib non-free > deb-src http://httpredir.debian.org/debian/ stretch-updates > main contrib non-free > deb http://security.debian.org/ stretch/updates main contrib > non-free > deb-src http://security.debian.org/ stretch/updates main > contrib non-free > > I prefer to use apt-get to aptitude. But if this can only be done in > aptitude, I do not mind using that. > > thanks > raju >
I ended up writing a python script, grep_install.py [1] to do this. The idea is to first build a list of available packages in each distribution of interest and then query them with desired logic. For example Step1: Build/update the cache. This only needs to be done once per distribution % grep_installed.py --update-cache --include-dists='jessie' --exclude-dists='stretch,sid' Processed: http://httpredir.debian.org/debian/dists/jessie/main/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/jessie/contrib/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/jessie/non-free/binary-amd64/Packages.gz writing: /home/rajulocal/.cache/grep_insalled/jessie.gz Processed: http://httpredir.debian.org/debian/dists/stretch/main/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/stretch/contrib/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/stretch/non-free/binary-amd64/Packages.gz writing: /home/rajulocal/.cache/grep_insalled/stretch.gz Processed: http://httpredir.debian.org/debian/dists/sid/main/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/sid/contrib/binary-amd64/Packages.gz Processed: http://httpredir.debian.org/debian/dists/sid/non-free/binary-amd64/Packages.gz writing: /home/rajulocal/.cache/grep_insalled/sid.gz Step2: Query the cache % dpkg -l | grep ^ii | awk '{print $2}' | grep_installed.py --include-dists='jessie' --exclude-dists='stretch,sid' /* produces the list of packages in Jessie but not in sid and stretch */ Step3 (optional): Clear the cache % grep_installed.py --clear-cache removing /home/rajulocal/.cache/grep_insalled/jessie.gz removing /home/rajulocal/.cache/grep_insalled/sid.gz removing /home/rajulocal/.cache/grep_insalled/stretch.gz removing /home/rajulocal/.cache/grep_insalled The script can also work with apt-cache search output. For example, to filter apt-cache search output and only show information on installed packages, one can do % apt-cache search python apt | grep_installed.py Finally, it can produce a "matrix" type of report showing the availability of a given set of packages across different distributions. % echo "python3.4 python3.5" | tr ' ' '\n' | grep_installed.py --include-dists='jessie' --exclude-dists='stretch,sid' --report matrix | column -ts ',' data pkg is_installed jessie stretch sid python3.4 python3.4 True True False False python3.5 python3.5 True False True True This feature is "apt-cache search" friendly as well! :) % apt-cache search idle-python | grep_installed.py --include-dists='jessie' --exclude-dists='stretch,sid' --report matrix | column -ts ',' data pkg is_installed jessie stretch sid idle-python2.7 - IDE for Python (v2.7) using Tkinter idle-python2.7 True True True True idle-python3.5 - IDE for Python (v3.5) using Tkinter idle-python3.5 False False True True Appendix: [1] - The code for grep_installed.py can be found in https://gitlab.com/d3k2mk7/rutils/blob/master/bin/grep_installed.py Please let me know if you find any bugs or have suggestions for improvement (no matter how small you think they are). thanks raju -- Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog