mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2025-01-03 15:49:19 +00:00
79 lines
2.1 KiB
Text
79 lines
2.1 KiB
Text
#!/usr/bin/env xonsh
|
|
|
|
import os
|
|
import json
|
|
from pathlib import Path
|
|
|
|
def rpm_ostree_packages(output_dir):
|
|
out = $(rpm-ostree status --json)
|
|
json_out = json.loads(out)
|
|
|
|
deployments = json_out["deployments"]
|
|
booted_deployment = deployments[0]
|
|
|
|
if not booted_deployment["booted"]:
|
|
for depl in deployments:
|
|
if depl["booted"]:
|
|
booted_deployment = depl
|
|
break
|
|
|
|
removals = booted_deployment["requested-base-removals"]
|
|
additions = booted_deployment["requested-packages"]
|
|
|
|
file = output_dir / "rpm-ostree.adoc"
|
|
with file.open("w") as f:
|
|
f.write("== Removed:\n")
|
|
for p in removals:
|
|
f.write(p + "\n")
|
|
|
|
f.write("\n== Added:\n")
|
|
for p in additions:
|
|
f.write(p + "\n")
|
|
|
|
def npm_packages(output_dir):
|
|
out = $(npm list --json -g)
|
|
json_out = json.loads(out)
|
|
deps = json_out["dependencies"].keys()
|
|
|
|
file = output_dir / "npm.txt"
|
|
with file.open("w") as f:
|
|
for dep in deps:
|
|
f.write(dep + "\n")
|
|
|
|
def pipx_packages(output_dir):
|
|
out = $(pipx list --json)
|
|
json_out = json.loads(out)
|
|
|
|
venvs = json_out["venvs"]
|
|
|
|
packages = []
|
|
injections = {}
|
|
for ind, venv_key in enumerate(venvs.keys()):
|
|
metadata = venvs[venv_key]["metadata"]
|
|
packages.append(metadata["main_package"]["package_or_url"])
|
|
injections[ind] = metadata["injected_packages"].keys()
|
|
|
|
file = output_dir / "pipx.adoc"
|
|
with file.open("w") as f:
|
|
for ind, package in enumerate(packages):
|
|
f.write(f"== {package}\n")
|
|
|
|
package_injections = injections[ind]
|
|
if package_injections is not None:
|
|
for injec in package_injections:
|
|
f.write(injec + "\n")
|
|
|
|
f.write("\n")
|
|
|
|
output_dir = Path(f"{$HOME}/bk/installed_packages_info")
|
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
rpm_ostree_packages(output_dir)
|
|
|
|
flatpak list --app --columns=name,application,origin >@(output_dir)/flatpak.txt
|
|
|
|
cargo install --list | rg '(.+) .+:.*' -r '$1' >@(output_dir)/cargo.txt
|
|
|
|
pipx_packages(output_dir)
|
|
|
|
npm_packages(output_dir)
|