Skip to main content
Topic: Sneaky immigrants (Read 425 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Sneaky immigrants

This is continuation of something few of us did several months ago. Since I made several iterations with this script, I'll paste it here since it may be useful to somebody else. Script lists source for all installed packages, so with Arch repos enabled (by hacking pacman.conf!) it shows all the sneaky immigrant packages that are not from Artix repo. With latest update, packages that are explicitly installed will have '*' on the left.

Code: [Select]
#!/usr/bin/env python3

from pathlib import Path

def get_distro(fn):
    item = {"name": "unknown", "distro": "Unknown", "reason": "*"}
    desc = fn.read_text().splitlines()
    for i, line in enumerate(desc):
         if line.strip() == "%NAME%":
             item["name"] = desc[i + 1].strip()
         if line.strip() == "%PACKAGER%":
             packager = desc[i + 1].strip()
             if "archlinux" in packager:
                 item["distro"] = "Arch"
             elif "artix" in packager:
                 item["distro"] = "Artix"
         if line.strip() == "%REASON%" and desc[i + 1].strip() == "1":
             item["reason"] = " "
    p_list.append(item)

def list_distro(distro_list):
    for distro in distro_list:
        print("#" * (len(distro) + 10))
        print(distro, "Packages:")
        print("#" * (len(distro) + 10))
        print("")
        for x in list(filter(lambda p: p['distro'] is distro, p_list)):
            print(x["reason"], x["name"])
        print("")

p_list = []
for fn in Path("/var/lib/pacman/local").glob("**/desc"):
    get_distro(fn)
p_list.sort(key=lambda x: x["name"])
list_distro(["Artix", "Arch", "Unknown"])

I have no requests to add anything to Artix but maybe something from the list makes sense to add anyway. My "Arch" section of the report looks like this:

Code: [Select]
##############
Arch Packages:
##############

* asciidoctor-pdf
* blanket
* chromium
* duf
* fd
* fdupes
* firefox-tridactyl
* khal
* libc++
  libc++abi
* lsd
* mpc
* ncmpc
  nim
* nwg-look
  python-click-log
  python-icalendar
  ruby-afm
  ruby-ascii85
  ruby-css_parser
  ruby-hashery
  ruby-pdf-core
  ruby-pdf-reader
  ruby-polyglot
  ruby-prawn
  ruby-prawn-icon
  ruby-prawn-svg
  ruby-prawn-table
  ruby-prawn-templates
  ruby-ruby-rc4
  ruby-treetop
  ruby-ttfunk
* the_silver_searcher
* tig
* ublock-origin
* vinagre
* wmctrl
* xcalib
  xcur2png
* xfce4-places-plugin
* xorg-xmag