Skip to main content
Topic: dedicated custom local repository for hanpicked packes, is possible? (Read 445 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

dedicated custom local repository for hanpicked packes, is possible?

Hello, this could be a strange question:

I have the exigence of having some packages downloaded from Arch Linux repo but I don't want to put Arch repostiories on pacman.conf.

It is possible to create a custom repository that will contain these packges (around 20 I think) and keep it syncronized with Arch Linux ones in term of version and then when I issue:

Code: [Select]
sudo pacman -Syu 

to have them upgraded?

I think that there is the need to have a script that:

- verify against "cutome repository" installed version of package and Arch linux repositories
- download packages from Arch Linux if something update is present
- update the repo database to reflect changes.


Regards

Carlo D.

Re: dedicated custom local repository for hanpicked packes, is possible?

Reply #1
I have done something similar but the fileserver in question had some dummy sync files that pacman understood, all that was left to do was add the gpg signature manually.
In your case, if you will host them with a fileserver, below it you will also need to include SigLevel = Never.

So basically what you will want to do is rsync updates from the arch server to your own, only those few packages. Complicated, but if you like it like that, so be it :)
I'd just update them manually with a script with pacman -U. :-)

Re: dedicated custom local repository for hanpicked packes, is possible?

Reply #2
- update the repo database to reflect changes.
It's all feasible. You may have to write the script yourself unless you can find something suitable. I wouldn't be surprised if there's something out there already you could use or modify ?
repo-add (part of pacman) is what you need for the bit I've quoted.

 

Re: dedicated custom local repository for hanpicked packes, is possible?

Reply #3
- verify against "cutome repository" installed version of package and Arch linux repositories
- download packages from Arch Linux if something update is present
- update the repo database to reflect changes.
Out of the top of my head and without any testing:
Code: [Select]
# pacman --config pacman-arch-repo.conf  -Syw pkg1 pkg2 pkg3 --cachedir /path/to/custom-repo
(cd to custom-repo)
# repo-add -R custom-repo.db.tar.gz *.pkg.zst

Re: dedicated custom local repository for hanpicked packes, is possible?

Reply #4
Out of the top of my head and without any testing:
...


Many thanks for the reply, I have done as below:

I have created this file named custom-arch in /etc/pacman.d

Code: [Select]
[options]
CacheDir = /var/cache/pacman/pkg
CacheDir = /var/cache/pacman/custom-arch
CleanMethod = KeepCurrent

[custom]
SigLevel = Optional TrustAll
Server = file:///var/cache/pacman/custom-arch


added this to /etc/pacman.conf

Code: [Select]
[custom-arch]
Include = /etc/pacman.d/custom-arch


created the directory using:

Code: [Select]
sudo install -d /var/cache/pacman/custom-arch -o $USER


And then create this bash script:

Code: [Select]
#!/bin/bash
cust_repo="/var/cache/pacman/custom-arch"
pacman --config /home/common/Remote/presets/arch-repo.conf  -Syw --cachedir $cust_repo - < /home/common/Remote/presets/pkg-from-arch.txt

repo-add -R $cust_repo/custom.db.tar.gz $cust_repo/*.pkg.tar.zst


in /home/common/Remote/presets/pkg-from-arch.txt I have the list of packages to have in artix.

and  /home/common/Remote/presets/arch-repo.conf like this:

as I save some setting on GitHub to have them in other place in case of a major disaster to my machine.


Code: [Select]
#
# minimal pacman.conf
#
[options]
Architecture = auto

# Arch
[extra]
Include = /etc/pacman.d/mirrorlist-arch


obviously I have installed the artix-archlinux-support to have updated repositories and keys.

It seems to work, at most, it seems that it will brute force download the package list but as they are 50mb in total, probably it is not a big problem, as I launch the script from time to time or in case of problems with package updates.

I wonder if there is a way to check for updates, to reduce bandwidth, but is more an optimisation that a real need.

Thanks for the info and Kind Regards

Carlo D.

Re: dedicated custom local repository for hanpicked packes, is possible?

Reply #5
Hello, after some fiddling I have found a way to have almost some automation:

Code: [Select]
#!/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:

Code: [Select]
pacman --config /home/common/Remote/presets/arch-repo.conf  -Syw --cachedir $cust_repo 


And then recreate the db.

Any other hints?

Regards

Carlo D.