mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2025-01-01 15:39:20 +00:00
Rewrite fetch_installed_packages script
This commit is contained in:
parent
d4c812980b
commit
ea0aa8ab18
2 changed files with 79 additions and 16 deletions
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
set -l output_dir "$HOME/bk/installed_packages_info"
|
||||
mkdir -p $output_dir
|
||||
|
||||
rpm-ostree status -b | rg -A 100 "Packages:" >$output_dir/rpm-ostree.txt
|
||||
|
||||
flatpak list --app --columns=name,application,origin >$output_dir/flatpak.txt
|
||||
|
||||
cargo install --list | rg '(.+) .+:.*' -r '$1' >$output_dir/cargo.txt
|
||||
|
||||
pipx list | rg '.*package ([^\s]+).*' -r '$1' >$output_dir/pipx.txt
|
||||
|
||||
npm list -g >$output_dir/npm.txt
|
||||
|
||||
fisher list >$output_dir/fisher.txt
|
79
.scripts/fetch_installed_packages.xsh
Normal file
79
.scripts/fetch_installed_packages.xsh
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/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)
|
Loading…
Reference in a new issue