Hello, after some fiddling I have found a way to have almost some automation:
#!/bin/python3
import subprocess
cust_repo = "/var/cache/pacman/custom-arch"
arch_conf = "/home/common/Remote/presets/arch-repo.conf"
pkg_inst = "/home/common/Remote/presets/pkg-from-arch.txt"
cmds = ["pacman", "--config", arch_conf, "-Sl", "extra"]
cmds1 = ["pacman", "-Qe"]
cmds2 = ["pacman", "--config", arch_conf, "-Syw", "--cachedir", cust_repo]
def do_command(cmd_list):
output = subprocess.run(cmd_list, capture_output=True)
if output.returncode > 0:
print(output.stderr)
return output.stdout.splitlines()
pkgs = do_command(cmds)
inst_pkgs_r = do_command(cmds1)
list_pkgs = []
with open(pkg_inst, "r") as f:
for line in f:
list_pkgs.append(line.strip("\n"))
inst_pkgs = {}
# no repo info
for pkg in inst_pkgs_r:
pkg_data = pkg.decode('utf-8').split(" ")
# print(pkg_data)
if pkg_data[0] in list_pkgs:
inst_pkgs[pkg_data[0]] = pkg_data[1]
rem_pkgs = {}
# with repo info
for pkg in pkgs:
pkg_data = str(pkg).split(" ")
# print(pkg_data)
if pkg_data[1] in list_pkgs:
rem_pkgs[pkg_data[1]] = pkg_data[2]
reg_cust_db = False
for pkg in inst_pkgs:
if inst_pkgs[pkg] == rem_pkgs[pkg]:
print(f"{pkg} updated")
else:
print(f"{pkg} not updated")
# TODO: Add command to dowload new package
reg_cust_db = True
if reg_cust_db:
pass
# TODO: Add command to regenerate custom db
You have a txt file with list of installed package from arch repositories in: ../pkg-from-arch.txt Note: the path must be absolute as it seems that subprocess.run command need absolute paths.
You have installed the packages from a custom repository, after you having retrieved them from arch linux.
you run the script and the it should output a list of "updated" or "not updated"
What is missing for now is the way to downlod the package from the arch repo and recreated the repo database to make:
pacman -Syu /b]
work as expected.
Probably the correct way will be to add this ommand to download only package that need to be upadted:
pacman --config /home/common/Remote/presets/arch-repo.conf -Syw --cachedir $cust_repo
And then recreate the db.
Any other hints?
Regards
Carlo D.