Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tips #13

Open
solsticedhiver opened this issue Apr 15, 2020 · 8 comments
Open

Tips #13

solsticedhiver opened this issue Apr 15, 2020 · 8 comments

Comments

@solsticedhiver
Copy link
Contributor

solsticedhiver commented Apr 15, 2020

This is not a bug report but more about sharing my uses around pacoloco. I don't know if it is suitable to be added as tips or notes to your README.

  • As I don't like the time related cleanup of pacoloco, I have setup paccache to cleanup pacoloco cache using paccache -r -k 2 -c /var/cache/pacoloco/pkgs/archlinux

  • The host running pacoloco (most likely running archlinux) will see a duplication of package present on disk. The package archives are both present in

    • /var/cache/pacoloco
    • and in /var/cache/pacman/pkg

    So I have setup that host to use localhost pacoloco mirror and changed /etc/pacman.confto use a CacheDir to point to a directory in /tmp
    The duplication is still there. I have added a .conf in /etc/tmpfiles.d to create my directory in /tmp at boot.

    For example, in /etc/tmpfiles.d/pacman-pkg-cache.conf :

    d /tmp/pacman-pkg-cache.d 0755 root root -
    

    And a .service and a .timer systemd file to clean up the /tmp/pacman-pkg-cache.d dir

The second "tip" is more questionnable and might not suit everyone.

@solsticedhiver
Copy link
Contributor Author

Do not symlink /var/cache/pacman/pkg to a directory in /tmp or anywhere else. You will exprience a bad situation when upgrading pacman. I just did. No pacman anymore. 😬

@okalm
Copy link

okalm commented Jun 6, 2020

Hi,

Thank you for tips @solsticedhiver :)

  • That's a good point you made, I also think it's better to manage this task with paccache instead of a specific duration of time but it depends on the use case I guess.
    In my case I've just made a systemd service to launch paccache at start since the server doesn't run all day.

# cat /etc/systemd/system/pacoloco-clean-cache.service

[Unit]
Description=Cleaning pacoloco's cache

[Service]
Type=oneshot
ExecStart=/usr/bin/paccache -r -k 3 -c /var/cache/pacoloco/pkgs/archlinux

[Install]
WantedBy=multi-user.target

As for the line purge_files_after from the paccoloco's configuration file, I've put a very high number (6 months) to be sure packages won't be delete by pacoloco itself after a while.

  • For the second tip I use a simple pacman's hook that delete packages, still by using paccache.

Thank you @anatol for this pretty good piece of software.
It runs out of the box, very handy .

@Y7n05h
Copy link

Y7n05h commented Jul 28, 2021

Thank for @solsticedhiver and @okalm .These suggestions are very useful.

@f35f0ef9d0e827dae86552d3899f78fc
Copy link

f35f0ef9d0e827dae86552d3899f78fc commented Mar 2, 2022

I have a small tip to add for anyone else who wants to run the pacoloco caching proxy on an arm64 SBC. You can compile on powerful system and then copy binary to SBC. The host system does not need to be Arch based to run pacoloco, as we can see from the Dockerfile as an example.

To compile for a Pine64 device for example, clone the pacoloco git repo, change into its directory, and then run these two commands:

export GOARCH=arm64
go build

From there, I used the Arch PKGBUILD file to guide me on where to place the binary and config files on the system. This is how Arch does it:

install -D -m755 pacoloco "$pkgdir"/usr/bin/pacoloco
install -D -m644 pacoloco.yaml.sample "$pkgdir"/etc/pacoloco.yaml
install -D -m644 pacoloco.sysusers.d "$pkgdir"/usr/lib/sysusers.d/pacoloco.conf
install -D -m644 pacoloco.service "$pkgdir"/usr/lib/systemd/system/pacoloco.service
install -D -m644 pacoloco.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/pacoloco.conf

Doing those steps on Debian works as well.

Finally, you will want to create a system account and chown the cache directory (/var/cache/pacoloco) to the system account.

useradd -r pacoloco
Edit /etc/password like this:
pacoloco:x:998:998::/var/cache/pacoloco:/usr/sbin/nologin

When testing on a client, be sure to do sudo pacman -Sy first so that pacoloco downloads the package list db files, then you can test installing/upgrading something with sudo pacman -S [package-name]

Next step would be to rightfully package it for Debian, but that hasn't been done yet.

@fhteagle
Copy link

fhteagle commented Sep 20, 2023

Any issues with setting CacheDir = /var/cache/pacoloco/pkgs/archlinux_x86_64 on the host's /etc/pacman.conf ? I tried that without really thinking about issues, and it seems to be working out, but just wanted to see if there is unannounced pitfalls of doing that.

@anatol
Copy link
Owner

anatol commented Sep 20, 2023

Any issues with setting CacheDir = /var/cache/pacoloco/pkgs/archlinux_x86_64 on the host's /etc/pacman.conf

One issue would a race condition between pacoloco when it downloading a package; and local pacman when it also tries to check/download the same package.

@fhteagle
Copy link

Wouldn't pacoloco have to download the file completely before being able to serve it to the host's pacman instance?

Or is the issue that pacoloco could be triggered to start downloading, the host pacman gives up on pacoloco for some reason and also starts downloading simultaneously from another mirror?

@Focshole
Copy link
Contributor

@fhteagle you end up having two processes (pacoloco and pacman) trying to write on the same package file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants