Giter Site home page Giter Site logo

pacoloco's Introduction

Pacoloco - caching proxy server for pacman

Pacoloco is a web server that acts if it was an Arch Linux pacman repository. Every time pacoloco server gets a request from user it downloads this file from real Arch Linux mirror and bypasses it to the user. Additionally pacoloco saves this file to local filesystem cache and serves it to the future users. It also allows to prefetch updates of the most recently used packages.

How does it help?

Fast internet is still a luxury in many parts of the world. There are many places where access to internet is expensive and slow due to geographical and economical reasons.

Now think about a situation when multiple pacman users connected via fast local network. Each of these users needs to download the same set of files. Pacoloco allows to minimize the Internet workload by caching pacman files content and serving it over fast local network.

Pacoloco does not mirror the whole Arch repository. It only downloads files needed by local users. You can think of pacoloco as a lazy Arch mirror.

Install

Arch systems

Install pacoloco package from the official Arch repository. Then start its systemd service: # systemctl start pacoloco.

Docker

Pacoloco can be used with docker.

You can get a prebuilt image from GitHub's container registry (see also sidebar). Currently the images are built for amd64 and ARM (arm64, armv7) architectures.

docker pull ghcr.io/anatol/pacoloco

Available tags are: latest = git master and any git tags.

You can also build it yourself:

$ git clone https://github.com/anatol/pacoloco && cd pacoloco
$ docker build -t ghcr.io/anatol/pacoloco .

Run it like this:

$ docker run -p 9129:9129 \
    -v /path/to/config/pacoloco.yaml:/etc/pacoloco.yaml \
    -v /path/to/cache:/var/cache/pacoloco \
    ghcr.io/anatol/pacoloco

You need to provide paths or volumes to store application data.

Alternatively, you can use docker-compose:

---
version: "3.8"
services:
  pacoloco:
#   if a specific user id is provided, you have to make sure
#   the mounted directories have the same user id owner on host
#   user: 1000:1000
    container_name: pacoloco
#   to pull the image from github's registry:
    image: ghcr.io/anatol/pacoloco
#   or replace it for for self-building with:
#    build: https://github.com/anatol/pacoloco.git
    ports:
      - "9129:9129"
    volumes:
      - /path/to/cache:/var/cache/pacoloco
      - /path/to/config/pacoloco.yaml:/etc/pacoloco.yaml
    restart: unless-stopped
#   to set time zone within the container for cron and log timestamps:
#    environment:
#      - TZ=Europe/Berlin

Build from sources

Optionally you can build the binary from sources using go build command.

Configure

The server configuration is located at /etc/pacoloco.yaml. Here is an example how the config file looks like:

port: 9129
cache_dir: /var/cache/pacoloco
purge_files_after: 360000 # 360000 seconds or 100 hours, 0 to disable
download_timeout: 3600 # download will timeout after 3600 seconds
repos:
  archlinux:
    urls:
      - http://mirror.lty.me/archlinux
      - http://mirrors.kernel.org/archlinux
  quarry:
    url: http://pkgbuild.com/~anatolik/quarry/x86_64
  sublime:
    http_proxy: http://bar.company.com:8989 # Proxy could be enabled per-repo, shadowing the global `http_proxy` (see below)
    url: https://download.sublimetext.com/arch/stable/x86_64
  archlinux-reflector:
    mirrorlist: /etc/pacman.d/reflector_mirrorlist # Be careful! Check that pacoloco URL is NOT included in that file!
http_proxy: http://foo.company.com:8989 # Enable this only if you have pacoloco running behind a proxy
user_agent: Pacoloco/1.2
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  # It deletes and stop prefetch packages(and db links) when not downloaded after ttl_unaccessed_in_days days that it had been updated.
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.
  • cache_dir is the cache directory, this location needs to read/writable by the server process.
  • purge_files_after specifies inactivity duration (in seconds) after which the file should be removed from the cache. This functionality uses unix "AccessTime" field to find out inactive files. Default value is 0 that means never run the purging.
  • port is the server port.
  • download_timeout is a timeout (in seconds) for internet->cache downloads. If a remote server gets slow and file download takes longer than this will be terminated. Default value is 0 that means no timeout.
  • repos is a list of repositories to mirror. Each repo needs name and url of its Arch mirrors. Note that url can be specified either with url or urls properties, one and only one can be used for each repo configuration. Each repo could have its own http_proxy, which would shadow the global http_proxy (see below).
  • http_proxy is only to be used if you have pacoloco running behind a proxy
  • user_agent user agent used to fetch the files from repositories. Default value is Pacoloco/1.2.
  • The prefetch section allows to enable packages prefetching. Comment it out to disable it.
  • To test out if the cron value does what you'd expect to do, check cronexpr implementation or test it
  • For what regards mirrorlist, be sure that pacoloco itself is NOT included in the chosen mirrorlist file. It can be integrated with reflector too, either by changing reflector's output path or by including pacoloco directly for standard repos in /etc/pacman.conf (e.g. adding a Server=... entry or a custom mirrorlist file which includes only pacoloco URL).

With the example configured above http://YOURSERVER:9129/repo/archlinux looks exactly like an Arch pacman mirror. For example a request to http://YOURSERVER:9129/repo/archlinux/core/os/x86_64/openssh-8.2p1-3-x86_64.pkg.tar.zst will be served with file content from http://mirror.lty.me/archlinux/core/os/x86_64/openssh-8.2p1-3-x86_64.pkg.tar.zst

Once the pacoloco server is up and running it is time to configure the user host. Modify user's /etc/pacman.conf with

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

[quarry]
Server = http://yourpacoloco:9129/repo/quarry

[sublime-text]
Server = http://yourpacoloco:9129/repo/sublime

And /etc/pacman.d/mirrorlist with

Server = http://yourpacoloco:9129/repo/archlinux/$repo/os/$arch

That's it. Since now pacman requests will be proxied through our pacoloco server.

Handling multiple architectures

pacoloco does not care about the architecture of your repo as it acts as a mere proxy.

Thus it can handle multiple different arches transparently. One way to do it is to add multiple repositories with names foobar_$arch e.g.:

repos:
  archlinux_x86_64:
    urls:
      - http://mirror.lty.me/archlinux
      - http://mirrors.kernel.org/archlinux
  archlinux_armv7h:
    url: http://mirror.archlinuxarm.org
  archlinux_x86:
    url: http://mirror.clarkson.edu/archlinux32

Then modify user's /etc/pacman.d/mirrorlist and add

For x86_64:

Server = http://yourpacoloco:9129/repo/archlinux_$arch/$repo/os/$arch

For armv7h:

Server = http://yourpacoloco:9129/repo/archlinux_$arch/$arch/$repo

For x86:

Server = http://yourpacoloco:9129/repo/archlinux_$arch/$arch/$repo

Please note that archlinux_$arch is the repo name in pacoloco.yaml.

Credits

Huge thanks to all the people who contributed to this project! Pacoloco would not be able to become successful without your help.

pacoloco's People

Contributors

7ji avatar anatol avatar aude avatar bradan avatar cofinalsubnets avatar davidknoll avatar dezeroku avatar ericlay avatar focshole avatar harharlinks avatar ilya-zlobintsev avatar krameler avatar lquidfire avatar machsix avatar orochimarufan avatar renr3n avatar rushmore75 avatar solsticedhiver avatar svenstaro avatar thefox0x7 avatar ykelvis avatar zhulik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pacoloco's Issues

Memory leak when downloading from an upstream mirror

I have noticed a weird behaviour:

  • pacoloco started using GBs of memory when downloading from an upstream mirror a large file, like if it is keeping it in memory.
  • Once the large package have been served, pacoloco didn't free the memory.

I suppose it is due to an unclosed request. I thought it was about req in downloadFile in pacoloco.go which doesn't seem to invoke Close, but I was wrong. So far, by adding defer req.Body.Close() to that function breaks the downloaded file.

This behaviour doesn't seem to happen when it serves a cached file.

Report progress to pacman

In case a download takes more than a couple of seconds, since nothing is reported by pacoloco, it's being interpreted as a timeout.

Consider the following config:

ck:
    url: http://repo-ck.com/

Trying to run pacman -S linux-ck would result in an error:

error: failed retrieving file 'linux-ck-5.5.5-1-x86_64.pkg.tar.zst' from server:port : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds

Cheers.

Race condition when multiple clients request the same uncached file while still downloading

Under certain circumstances, pacoloco replies only a partial file to clients.

For the sake of simplicity, assume there are 2 clients (clients A and B), and both request the file foo.pkg.
Assume further that foo.pkg is not cached yet and has to be downloaded by pacoloco first.
Now imagine A requests foo.pkg first. pacoloco will start downloading the file from the server, save it in the cache and let A wait on the download to finish (ignoring further details here).
While it is still downloading foo.pkg, B also requests foo.pkg.
One would expect pacoloco to make B also wait on the completion of the download.
Actually, it will send the partially downloaded to B immediately as if it was the whole file.
In the end this will lead to pacman complaining about the file being corrupt.

This actually happened to me with some bigger package when I updated two machines simultaneously.

It is not a big issue, because pacman asks to delete the file anyway and on the next try it will probably be downloaded completely already. But it is confusing at least. Especially when it happens for the first time.

Seems like there is only some internal synchronization missing.

prefetch only fetches db, but not packages

I think pacoloco only prefetches the databases, but never any package.
I use an aarch64 (armv8) system, but I doubt that this is the issue.

This system was down for several days, so it couldn't have downloaded/updated any packages for this time - thus there must've been some updates.
After updating today I noticed that some dbs were cached, but none of the packages.

pacoloco.yaml:

cache_dir: /[…]/@pacoloco
repos:
  arch_x86-64:
    urls:
      - https://mirror.lty.me/archlinux
      - https://mirrors.kernel.org/archlinux
  arch_aarch64:
    urls:
      - http://mirror.archlinuxarm.org/aarch64
  blackarch:
    urls:
      - https://ftp.halifax.rwth-aachen.de/blackarch
  endeavouros:
    urls:
      - https://de.freedif.org/EndeavourOS/repo
      - https://mirror.alpix.eu/endeavouros/repo
      - https://mirror.moson.org/endeavouros/repo

prefetch:
  cron: 30 1,9,16 * * *
  ttl_unaccessed_in_days: 30
  ttl_unupdated_in_days: 300

journal:

Nov 21 01:30:00 prefetch.go:269: Starting prefetching routine...
Nov 21 01:30:00 prefetch.go:182: Cleaning the db...
Nov 21 01:30:00 prefetch.go:231: Db cleaned.
Nov 21 01:30:00 prefetch.go:273: Starting prefetching packages...
Nov 21 01:30:01 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/core/os/x86_64/core.db
Nov 21 01:30:02 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/core.db...
Nov 21 01:30:02 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/core.db.tar...
Nov 21 01:30:02 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/core.db.tar.
Nov 21 01:30:02 repo_db_mirror.go:184: Adding entries to db...
Nov 21 01:30:02 repo_db_mirror.go:220: Added entries to db.
Nov 21 01:30:02 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/extra.db
Nov 21 01:30:04 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/extra.db...
Nov 21 01:30:04 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/extra.db.tar...
Nov 21 01:30:05 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/extra.db.tar.
Nov 21 01:30:05 repo_db_mirror.go:184: Adding entries to db...
Nov 21 01:30:05 repo_db_mirror.go:220: Added entries to db.
Nov 21 01:30:06 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/multilib.db
Nov 21 01:30:06 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/multilib.db...
Nov 21 01:30:06 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/multilib.db.tar...
Nov 21 01:30:06 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/multilib.db.tar.
Nov 21 01:30:06 repo_db_mirror.go:184: Adding entries to db...
Nov 21 01:30:06 repo_db_mirror.go:220: Added entries to db.
Nov 21 01:30:06 pacoloco.go:362: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/endeavouros.db
Nov 21 01:30:06 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/endeavouros.db...
Nov 21 01:30:06 repo_db_mirror.go:28: error: gzip: invalid header
Nov 21 01:30:06 repo_db_mirror.go:238: An error occurred for mirror {https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/ende>
Nov 21 01:30:06 pacoloco.go:362: downloading https://ftp.halifax.rwth-aachen.de/blackarch/blackarch/os/x86_64/blackarch.db
Nov 21 01:30:08 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/blackarch.db...
Nov 21 01:30:08 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/blackarch.db.tar...
Nov 21 01:30:08 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/blackarch.db.tar.
Nov 21 01:30:08 repo_db_mirror.go:184: Adding entries to db...
Nov 21 01:30:09 repo_db_mirror.go:220: Added entries to db.
Nov 21 01:30:09 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 01:30:18 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/community.db...
Nov 21 01:30:19 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/community.db.tar...
Nov 21 01:30:20 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/community.db.tar.
Nov 21 01:30:20 repo_db_mirror.go:184: Adding entries to db...
Nov 21 01:30:22 repo_db_mirror.go:220: Added entries to db.
Nov 21 01:30:22 prefetch.go:275: Finished prefetching packages!
Nov 21 01:30:22 prefetch.go:276: Finished prefetching routine!
Nov 21 01:30:22 prefetch.go:45: On 2021-11-21 09:29:59.999999416 +0100 CET m=+37388.400574289 the prefetching routine will be run ag>

# note - probably update notification of endeavourOS
Nov 21 08:51:54 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/extra.db
Nov 21 08:51:55 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 08:51:55 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/core.db
Nov 21 08:51:58 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/core.db.sig: no such file or directory
Nov 21 08:51:59 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/multilib.db
Nov 21 08:52:02 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/multilib.db.sig: no such file or directory
Nov 21 08:52:02 pacoloco.go:432: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/endeavouros.db
Nov 21 08:52:03 pacoloco.go:131: open /[…]/@pacoloco/pkgs/endeavouros/endeavouros.db.sig: no such file or directory
Nov 21 08:52:03 pacoloco.go:432: downloading https://ftp.halifax.rwth-aachen.de/blackarch/blackarch/os/x86_64/blackarch.db
Nov 21 08:52:04 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/extra.db.sig: no such file or directory
Nov 21 08:52:04 pacoloco.go:432: downloading https://ftp.halifax.rwth-aachen.de/blackarch/blackarch/os/x86_64/blackarch.db.sig
Nov 21 08:52:19 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/community.db.sig: no such file or directory

Nov 21 09:30:00 prefetch.go:269: Starting prefetching routine...
Nov 21 09:30:00 prefetch.go:182: Cleaning the db...
Nov 21 09:30:00 prefetch.go:231: Db cleaned.
Nov 21 09:30:00 prefetch.go:273: Starting prefetching packages...
Nov 21 09:30:01 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/core/os/x86_64/core.db
Nov 21 09:30:01 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/core.db...
Nov 21 09:30:01 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/core.db.tar...
Nov 21 09:30:01 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/core.db.tar.
Nov 21 09:30:01 repo_db_mirror.go:184: Adding entries to db...
Nov 21 09:30:01 repo_db_mirror.go:220: Added entries to db.
Nov 21 09:30:01 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/extra.db
Nov 21 09:30:04 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/extra.db...
Nov 21 09:30:04 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/extra.db.tar...
Nov 21 09:30:05 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/extra.db.tar.
Nov 21 09:30:05 repo_db_mirror.go:184: Adding entries to db...
Nov 21 09:30:05 repo_db_mirror.go:220: Added entries to db.
Nov 21 09:30:05 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/multilib.db
Nov 21 09:30:06 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/multilib.db...
Nov 21 09:30:06 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/multilib.db.tar...
Nov 21 09:30:06 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/multilib.db.tar.
Nov 21 09:30:06 repo_db_mirror.go:184: Adding entries to db...
Nov 21 09:30:06 repo_db_mirror.go:220: Added entries to db.
Nov 21 09:30:06 pacoloco.go:362: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/endeavouros.db
Nov 21 09:30:06 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/endeavouros.db...
Nov 21 09:30:06 repo_db_mirror.go:28: error: gzip: invalid header
Nov 21 09:30:06 repo_db_mirror.go:238: An error occurred for mirror {https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/ende>
Nov 21 09:30:06 pacoloco.go:362: downloading https://ftp.halifax.rwth-aachen.de/blackarch/blackarch/os/x86_64/blackarch.db
Nov 21 09:30:07 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/blackarch.db...
Nov 21 09:30:08 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/blackarch.db.tar...
Nov 21 09:30:08 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/blackarch.db.tar.
Nov 21 09:30:08 repo_db_mirror.go:184: Adding entries to db...
Nov 21 09:30:09 repo_db_mirror.go:220: Added entries to db.
Nov 21 09:30:09 pacoloco.go:362: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 09:30:19 repo_db_mirror.go:166: Extracting /[…]/@pacoloco/tmp-db/community.db...
Nov 21 09:30:20 repo_db_mirror.go:175: Parsing /[…]/@pacoloco/tmp-db/community.db.tar...
Nov 21 09:30:21 repo_db_mirror.go:177: Parsed /[…]/@pacoloco/tmp-db/community.db.tar.
Nov 21 09:30:21 repo_db_mirror.go:184: Adding entries to db...
Nov 21 09:30:23 repo_db_mirror.go:220: Added entries to db.
Nov 21 09:30:24 prefetch.go:275: Finished prefetching packages!
Nov 21 09:30:24 prefetch.go:276: Finished prefetching routine!
Nov 21 09:30:24 prefetch.go:45: On 2021-11-21 16:29:59.999999416 +0100 CET m=+62588.400574289 the prefetching routine will be run ag>

# note - probably update notification of endeavourOS
Nov 21 10:06:06 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/extra.db
Nov 21 10:06:07 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/core.db
Nov 21 10:06:07 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 10:06:08 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/core.db.sig: no such file or directory
Nov 21 10:06:10 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/multilib.db
Nov 21 10:06:11 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/multilib.db.sig: no such file or directory
Nov 21 10:06:11 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/extra.db.sig: no such file or directory
Nov 21 10:06:12 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/endeavouros/endeavouros.db
Nov 21 10:06:12 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/blackarch/blackarch.db
Nov 21 10:06:12 pacoloco.go:131: open /[…]/@pacoloco/pkgs/endeavouros/endeavouros.db.sig: no such file or directory
Nov 21 10:06:12 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/blackarch/blackarch.db.sig
Nov 21 10:06:17 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/community.db.sig: no such file or directory

# note - manual update via pacman -Syu on my notebook
Nov 21 11:49:54 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/extra.db
Nov 21 11:49:54 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 11:49:54 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/core.db
Nov 21 11:49:56 pacoloco.go:442: write tcp 192.168.yy.xx:9129->192.168.yy.ZZ:50918: write: broken pipe
Nov 21 11:49:56 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/extra.db.sig: no such file or directory
Nov 21 11:49:57 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/core.db.sig: no such file or directory
Nov 21 11:49:57 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/community.db: no such file or directory
Nov 21 11:49:57 server.go:3159: http: superfluous response.WriteHeader call from main.pacolocoHandler (pacoloco.go:132)
Nov 21 11:50:05 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/community.db
Nov 21 11:50:05 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/core.db
Nov 21 11:50:05 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/extra.db
Nov 21 11:50:08 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/extra.db.sig: no such file or directory
Nov 21 11:50:08 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/core.db.sig: no such file or directory
Nov 21 11:50:09 pacoloco.go:432: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/endeavouros.db
Nov 21 11:50:09 pacoloco.go:131: open /[…]/@pacoloco/pkgs/endeavouros/endeavouros.db.sig: no such file or directory
Nov 21 11:50:10 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/blackarch/blackarch.db
Nov 21 11:50:10 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/blackarch/blackarch.db.sig
Nov 21 11:50:11 pacoloco.go:472: serving cached file /[…]/@pacoloco/pkgs/arch_x86-64/multilib.db
Nov 21 11:50:13 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/multilib.db.sig: no such file or directory
Nov 21 11:50:17 pacoloco.go:131: open /[…]/@pacoloco/pkgs/arch_x86-64/community.db.sig: no such file or directory
Nov 21 11:50:21 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libreoffice-fresh-7.2.2-3-x86_64.pkg.ta>
Nov 21 11:50:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/wine-6.21-3-x86_64.pkg.tar.zst
Nov 21 11:50:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/firefox-94.0.2-2-x86_64.pkg.tar.zst
Nov 21 11:52:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libreoffice-fresh-7.2.2-3-x86_64.pkg.ta>
Nov 21 11:52:24 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/thunderbird-91.3.2-1-x86_64.pkg.tar.zst
Nov 21 11:52:58 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/firefox-94.0.2-2-x86_64.pkg.tar.zst.sig
Nov 21 11:52:59 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/electron12-12.2.3-1-x86_64.pkg.tar.>
Nov 21 11:53:33 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/thunderbird-91.3.2-1-x86_64.pkg.tar.zst>
Nov 21 11:53:34 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qt5-base-5.15.2+kde+r257-1-x86_64.pkg.t>
Nov 21 11:54:15 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/electron12-12.2.3-1-x86_64.pkg.tar.>
Nov 21 11:54:16 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/cmake-3.22.0-1-x86_64.pkg.tar.zst
Nov 21 11:54:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qt5-base-5.15.2+kde+r257-1-x86_64.pkg.t>
Nov 21 11:54:21 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/fwupd-1.7.2-1-x86_64.pkg.tar.zst
Nov 21 11:54:26 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/cmake-3.22.0-1-x86_64.pkg.tar.zst.sig
Nov 21 11:54:28 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/imagemagick-7.1.0.15-1-x86_64.pkg.tar.z>
Nov 21 11:54:29 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/fwupd-1.7.2-1-x86_64.pkg.tar.zst.sig
Nov 21 11:54:30 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/gnupg-2.2.32-2-x86_64.pkg.tar.zst
Nov 21 11:54:50 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/imagemagick-7.1.0.15-1-x86_64.pkg.tar.z>
Nov 21 11:54:51 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lsp-plugins-1.1.30-2-x86_64.pkg.tar>
Nov 21 11:54:51 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/gnupg-2.2.32-2-x86_64.pkg.tar.zst.sig
Nov 21 11:54:53 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/sudo-1.9.8.p2-3-x86_64.pkg.tar.zst
Nov 21 11:55:00 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/wine-6.21-3-x86_64.pkg.tar.zst.sig
Nov 21 11:55:00 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/sudo-1.9.8.p2-3-x86_64.pkg.tar.zst.sig
Nov 21 11:55:00 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/krb5-1.19.2-2-x86_64.pkg.tar.zst
Nov 21 11:55:02 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lsp-plugins-1.1.30-2-x86_64.pkg.tar>
Nov 21 11:55:02 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qpdf-10.4.0-1-x86_64.pkg.tar.zst
Nov 21 11:55:04 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/dhclient-4.4.2.P1-2-x86_64.pkg.tar.zst
Nov 21 11:55:05 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/krb5-1.19.2-2-x86_64.pkg.tar.zst.sig
Nov 21 11:55:05 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qpdf-10.4.0-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:05 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/dhclient-4.4.2.P1-2-x86_64.pkg.tar.zst.>
Nov 21 11:55:05 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-krb5-1.19.2-2-x86_64.pkg.tar.z>
Nov 21 11:55:07 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/cups-filters-1.28.10-2-x86_64.pkg.tar.z>
Nov 21 11:55:08 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/ptex-2.4.1-2-x86_64.pkg.tar.zst
Nov 21 11:55:09 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-krb5-1.19.2-2-x86_64.pkg.tar.z>
Nov 21 11:55:09 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/cups-filters-1.28.10-2-x86_64.pkg.tar.z>
Nov 21 11:55:09 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/ptex-2.4.1-2-x86_64.pkg.tar.zst.sig
Nov 21 11:55:09 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/cryptsetup-2.4.2-1-x86_64.pkg.tar.zst
Nov 21 11:55:10 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/elfutils-0.186-1-x86_64.pkg.tar.zst
Nov 21 11:55:11 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/iwd-1.20-1-x86_64.pkg.tar.zst
Nov 21 11:55:12 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/cryptsetup-2.4.2-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:12 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/elfutils-0.186-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:12 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/iwd-1.20-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:13 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libelf-0.186-1-x86_64.pkg.tar.>
Nov 21 11:55:14 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/libelf-0.186-1-x86_64.pkg.tar.zst
Nov 21 11:55:15 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libjpeg-turbo-2.1.2-1-x86_64.pkg.tar.zst
Nov 21 11:55:15 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libelf-0.186-1-x86_64.pkg.tar.>
Nov 21 11:55:15 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/libelf-0.186-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:16 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lv2-1.18.2-1-x86_64.pkg.tar.zst
Nov 21 11:55:16 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/audit-3.0.6-2-x86_64.pkg.tar.zst
Nov 21 11:55:17 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libjpeg-turbo-2.1.2-1-x86_64.pkg.tar.zs>
Nov 21 11:55:17 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lv2-1.18.2-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:17 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/audit-3.0.6-2-x86_64.pkg.tar.zst.sig
Nov 21 11:55:18 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libmbim-1.26.2-1-x86_64.pkg.tar.zst
Nov 21 11:55:18 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/libldap-2.6.0-2-x86_64.pkg.tar.zst
Nov 21 11:55:19 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/ell-0.46-1-x86_64.pkg.tar.zst
Nov 21 11:55:19 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/core/os/x86_64/libldap-2.6.0-2-x86_64.pkg.tar.zst.sig
Nov 21 11:55:19 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libmbim-1.26.2-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:19 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/ell-0.46-1-x86_64.pkg.tar.zst.sig
Nov 21 11:55:19 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libjpeg-turbo-2.1.2-1-x86_64.p>
Nov 21 11:55:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libldap-2.6.0-1-x86_64.pkg.tar>
Nov 21 11:55:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/apr-util-1.6.1-9-x86_64.pkg.tar.zst
Nov 21 11:55:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libjpeg-turbo-2.1.2-1-x86_64.p>
Nov 21 11:55:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libldap-2.6.0-1-x86_64.pkg.tar>
Nov 21 11:55:20 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/apr-util-1.6.1-9-x86_64.pkg.tar.zst.sig
Nov 21 11:55:21 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libdrm-2.4.108-1-x86_64.pkg.ta>
Nov 21 11:55:21 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/pcsc-tools-1.5.8-1-x86_64.pkg.tar.z>
Nov 21 11:55:21 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lilv-0.24.12-2-x86_64.pkg.tar.zst
Nov 21 11:55:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libdrm-2.4.108-1-x86_64.pkg.ta>
Nov 21 11:55:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/lilv-0.24.12-2-x86_64.pkg.tar.zst.s>
Nov 21 11:55:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qtkeychain-qt5-0.13.2-1-x86_64.pkg.tar.>
Nov 21 11:55:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/pcsc-tools-1.5.8-1-x86_64.pkg.tar.z>
Nov 21 11:55:22 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libqrtr-glib-1.2.0-1-x86_64.pkg.tar.zst
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libtasn1-4.18.0-1-x86_64.pkg.t>
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/qtkeychain-qt5-0.13.2-1-x86_64.pkg.tar.>
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/multilib/os/x86_64/lib32-libtasn1-4.18.0-1-x86_64.pkg.t>
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/extra/os/x86_64/libqrtr-glib-1.2.0-1-x86_64.pkg.tar.zst>
Nov 21 11:55:23 pacoloco.go:432: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/welcome-3.16.19-1-any.pkg.ta>
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/suil-0.10.10-2-x86_64.pkg.tar.zst
Nov 21 11:55:23 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/sratom-0.6.8-3-x86_64.pkg.tar.zst
Nov 21 11:55:24 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/sratom-0.6.8-3-x86_64.pkg.tar.zst.s>
Nov 21 11:55:24 pacoloco.go:432: downloading https://de.freedif.org/EndeavourOS/repo/endeavouros/x86_64/welcome-3.16.19-1-any.pkg.ta>
Nov 21 11:55:24 pacoloco.go:432: downloading https://mirror.lty.me/archlinux/community/os/x86_64/suil-0.10.10-2-x86_64.pkg.tar.zst.s>

Question: Remove some packages from prefetching manually

Hello!

I'd like to remove some packages manually by hand because I do no longer need them prefetched, so these packages do not take unnecessary space.

I know that ttl_unaccessed_in_days and ttl_unupdated_in_days exists, however I do not want to change this globally for each package but only for a few selected ones and just one time only.

Would the following be a viable workflow?

  • delete from packages where package_name = "package";
  • remove package from package cache at /cache/pkgs/archlinux: rm package.pkg.tar.zst and rm package.pkg.tar.zst.sig

[BUG]: HTTP server doesn't seem to support byte ranges. Cannot resume

Total Download Size:     15.64 MiB
Total Installed Size:  1451.94 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 vim-runtime-9.0.0814-1-x86_64.pkg.tar.zst failed to download
 Total ( 1/19)                                                            15.6 MiB  27.1 MiB/s 00:01 [############################################################] 100%
error: failed retrieving file 'vim-runtime-9.0.0814-1-x86_64.pkg.tar.zst' from 0.0.0.0:9129 : HTTP server doesn't seem to support byte ranges. Cannot resume.
warning: failed to retrieve some files
error: failed to commit transaction (download library error)
Errors occurred, no packages were upgraded.

Feature request: allow integration with reflector

I had thought about allowing pacoloco to be integrated with reflector generated files, i.e.:

# cache_dir: /var/cache/pacoloco
# port: 9129
download_timeout: 3600 # downloads will timeout if not completed after 3600 sec, 0 to disable timeout
purge_files_after: 2592000 # purge file after 30 days
repos:
  archlinux:
    mirrorlist: /etc/pacman.d/mirrorlist
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  # It deletes and stop prefetch packages(and db links) when not downloaded after ttl_unaccessed_in_days days that it had been updated.
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.

Which parses the /etc/pacman.d/mirrorlist file to get the Server entries with some simple regexs, after stripping the $repo/os/$arch part. The file should be parsed each time before the prefetching routine is going to be executed, to ensure that the mirrors are updated

I could write it, I wrote this issue to discuss on corner cases/issues which may rise from such a feature

docker retain sqlite-pkg-cache.db between upgrades

I learned this the hard way but it seems the sqlite-pkg-cache.db which is responsible to keep track of prefetching is not mapped to a directory outside the container when using docker.

This means whenever you build a new container this file will be created from scratch and is therefore empty.

I would change the docker run command in the README.md:

docker run -p 9129:9129 -v /path/to/config/pacoloco.yaml:/etc/pacoloco.yaml -v /path/to/cache:/var/cache/pacoloco/pkgs -v /path/to/sqlite-db:/var/cache/pacoloco/sqlite-pkg-cache.db pacoloco

I would also be happy to provide my simple docker-compose.yml if you so desire.

cron not working with commas

I defined a few specific hours for downloading automatically.
This doesn't seem to work, as my journal told me journalctl -t pacoloco.

In pacoloco.yml:

prefetch:
  cron: 0 30 1,9,16 * * * *
  ttl_unaccessed_in_days: 30
  ttl_unupdated_in_days: 300

This should mean: on 30 minutes at 1 am, 9 am and 4 pm, everyday.
Have I done something wrong or is the cron implementation wrong?

support automatic detection and configuration

Client: detect proxies on LAN before downloading packages. See auto-apt-proxy for a debian-based example.

Server: use avahi to announce proxy server. apt-cacher-ng package on debian includes the following avahi service definition in /etc/avahi/services/apt-cacher-ng.service.

<?xml version="1.0" standalone='no'?>
<!--
From: Lisandro Damián Nicanor Pérez Meyer <[email protected]>
X-Source: http://blog.surgut.co.uk/2013/03/avahi-apt-cacher-ng-sbuild.html
 See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704790 for details.
-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">apt-cacher-ng proxy on %h</name>
 <service protocol="ipv6">
  <type>_apt_proxy._tcp</type>
  <port>3142</port>
 </service>
 <service protocol="ipv4">
  <type>_apt_proxy._tcp</type>
  <port>3142</port>
 </service>
</service-group>

DB requests failing: `superfluous response.WriteHeader call`

Pacoloco has been running just fine for quite a few months now, but I recently discovered the opposite. Here is what I've found:

Feb 28 03:01:10 Server pacoloco[2956722]: pacoloco.go:446: downloading http://mirror.lty.me/archlinux/core/os/x86_64/core.db
Feb 28 03:01:10 Server pacoloco[2956722]: pacoloco.go:456: write tcp 192.168.178.2:9129->192.168.178.3:41712: write: broken pipe
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:446: downloading http://mirrors.kernel.org/archlinux/core/os/x86_64/core.db
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:456: write tcp 192.168.178.2:9129->192.168.178.3:41712: write: broken pipe
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/core.db: no such file or directory
Feb 28 03:01:11 Server pacoloco[2956722]: server.go:3197: http: superfluous response.WriteHeader call from main.pacolocoHandler (pacoloco.go:139)
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/core.db.sig: no such file or directory
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:446: downloading http://mirror.lty.me/archlinux/extra/os/x86_64/extra.db
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:456: write tcp 192.168.178.2:9129->192.168.178.3:41724: write: broken pipe
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:446: downloading http://mirrors.kernel.org/archlinux/extra/os/x86_64/extra.db
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:456: write tcp 192.168.178.2:9129->192.168.178.3:41724: write: broken pipe
Feb 28 03:01:11 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/extra.db: no such file or directory
Feb 28 03:01:11 Server pacoloco[2956722]: server.go:3197: http: superfluous response.WriteHeader call from main.pacolocoHandler (pacoloco.go:139)
Feb 28 03:01:12 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/extra.db.sig: no such file or directory
Feb 28 03:01:12 Server pacoloco[2956722]: pacoloco.go:486: serving cached file /var/cache/pacoloco/pkgs/archlinux/community.db
Feb 28 03:01:13 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/community.db.sig: no such file or directory
Feb 28 03:01:13 Server pacoloco[2956722]: pacoloco.go:486: serving cached file /var/cache/pacoloco/pkgs/archlinux/multilib.db
Feb 28 03:01:13 Server pacoloco[2956722]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/multilib.db.sig: no such file or directory

Downloading extra.db with wget works just fine, so I suppose no network related issues.
Config is almost identical to the pre-generated one (not using a http-proxy).

pacoloco 1.2-2
Kernel: 6.1.12-arch1-1

Issue with pacman files database

Pacoloco crashed after I tried to search for which package had a specific binary. The specific command I used was:

sudo pacman -Fy /usr/bin/host

The log of Pacoloco is as follows:

Jan 10 19:14:20 alpha systemd[1]: Started Pacoloco caching proxy server.
Jan 10 19:14:20 alpha pacoloco[2173366]: pacoloco.go:102: Reading config file from /etc/pacoloco.yaml
Jan 10 19:14:20 alpha pacoloco[2173366]: prefetch.go:34: The prefetching routine will be run on 2022-01-11 03:00:00.000036132 -0800 PST m=+27939.112777436
Jan 10 19:14:20 alpha pacoloco[2173366]: prefetch_db.go:78: Creating /var/cache/pacoloco/sqlite-pkg-cache.db
Jan 10 19:14:20 alpha pacoloco[2173366]: pacoloco.go:129: Starting server at port 9129
Jan 10 19:16:30 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//community/os/x86_64/community.db
Jan 10 19:16:30 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//extra/os/x86_64/extra.db
Jan 10 19:16:30 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//core/os/x86_64/core.db
Jan 10 19:17:26 alpha pacoloco[2173366]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/extra.db.sig: no such file or directory
Jan 10 19:17:26 alpha pacoloco[2173366]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/community.db.sig: no such file or directory
Jan 10 19:17:26 alpha pacoloco[2173366]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/archlinux/core.db.sig: no such file or directory
Jan 10 19:54:04 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//extra/os/x86_64/extra.files
Jan 10 19:54:04 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//core/os/x86_64/core.files
Jan 10 19:54:04 alpha pacoloco[2173366]: pacoloco.go:446: downloading https://arch.mirror.constant.com//community/os/x86_64/community.files
Jan 10 19:54:04 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'core.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:05 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'extra.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:05 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'community.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'extra.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: pacoloco.go:486: serving cached file /var/cache/pacoloco/pkgs/archlinux/extra.files
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'extra.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'community.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: pacoloco.go:486: serving cached file /var/cache/pacoloco/pkgs/archlinux/community.files
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'community.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'core.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:22 alpha pacoloco[2173366]: pacoloco.go:486: serving cached file /var/cache/pacoloco/pkgs/archlinux/core.files
Jan 10 19:54:22 alpha pacoloco[2173366]: prefetch.go:78: error: package with name 'core.files' cannot be prefetched cause it doesn't follow the package name formatting regex
Jan 10 19:54:40 alpha pacoloco[2173366]: fatal error: concurrent map writes
Jan 10 19:54:40 alpha pacoloco[2173366]: goroutine 1197 [running]:
Jan 10 19:54:40 alpha pacoloco[2173366]: runtime.throw({0x562fa2341285, 0x562fa1f6b3d4})
Jan 10 19:54:40 alpha pacoloco[2173366]:         runtime/panic.go:1198 +0x71 fp=0xc00004d620 sp=0xc00004d5f0 pc=0x562fa1ee5d51
Jan 10 19:54:40 alpha pacoloco[2173366]: runtime.mapassign_faststr(0x562fa2441100, 0xc0001f8ae0, {0xc0000287f8, 0x18})
...

Full log here: https://gist.github.com/krathalan/e1147dd4ab036f63847e2a9363843280

pacoloco fails to start with a valid cache directory

Feb 20 12:09:10 nuc6 pacoloco[3465322]: pacoloco.go:31: Reading config file from /etc/pacoloco.yaml
Feb 20 12:09:10 nuc6 pacoloco[3465322]: config.go:53: directory /srv/samba2/pacoloco does not exist or isn't writable for user pacoloco
Feb 20 12:09:10 nuc6 systemd[1]: pacoloco.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 12:09:10 nuc6 systemd[1]: pacoloco.service: Failed with result 'exit-code'.
total 8
drwxr-xr-x 2 pacoloco  pacoloco  4096 Feb 20 12:01 .
drwxrwx--T 8 shareuser shareuser 4096 Feb 19 16:46 ..

Commit 567e1ce breaks arm build

Commit 567e1ce seems to break the build on ARM devices (including native and cross-compilation).

Building on master (99d64f3) gives:

./purge.go:43:31: cannot use atimeUnix.Sec (type int32) as type int64 in argument to time.Unix
./purge.go:43:46: cannot use atimeUnix.Nsec (type int32) as type int64 in argument to time.Unix

Last working commit: 8c7b8d9

This was tested on a Raspberry Pi 4 (armv7).

cold files cause timeouts

Hi,

First of all, great project! I'm using this on a couple places with the intent of downloading less packages and being faster where a second pc needs the same updates. Win-win to me :)

But..
I've noticed a lot of timeouts to a point where using this, otherwise awesome project, is becoming a pain.

Lets just for simplicity sake describe a connection between 2 pc's (server - running pacoloco - and the client making a connection to that server. The mirrorlist on the client only knows the server, this is intentional.

  • client asks package (through pacman, yay, ...)
  • server looks if package exists. If not - cold - then it downloads said package itself
  • ... time passes ...
  • ... 10+ seconds pass, client now errors out due to no activity
  • server still downloads package
  • Update has to be restarted due to said error

Now multiply the above by a large number of updates and you all of a sudden spend hours struggling through timeout errors. No joke. I had about 600 package updates and it kept giving me package timeouts. I ended up disabling pacoloco for this update round.

What the server should do in this case, and perhaps in every case, is act as a caching reverse proxy.
With the caveat that it should do chunked transfers to keep the client side fed with data.

I did look at some go reverse proxy examples but this combination of factors seems to be tricky. I did find this though that's a full blown solution on it's own. You might find some of it's code interesting for this project.

Any caveats when chaining two instances?

Any caveats when chaining two instances?

I plan to run pacoloco & apt-cacher ng on a vps which has reflector scheduled via crond.

And locally I run a second layer of both on my nas inside docker.

The idea is that I will always have the most optimal and a single connection for my local vms & servers to the nas and the nas downstream request the same from my upstream vps in the cloud.

Will there be any problems with this setup? Does that even make sense?

Simplify default pacoloco.yaml config

I found it a little confusing to have the optional repositories included in the installed config file pacoloco.yaml

 quarry:
    url: http://pkgbuild.com/~anatolik/quarry/x86_64
 sublime:
    url: https://download.sublimetext.com/arch/stable/x86_64

It is not noted in the configuration section that these are purely optional. And possibly lead those who are unaware to have unused extra repositories configured.

Arch wiki has a sample config that is a lot more bare bones.

port: 9129
repos:
  mycopy:
    urls:
      - http://mirror.lty.me/archlinux
      - http://mirrors.kernel.org/archlinux

IMO moving the sample config as is to /usr/share and documenting both the optional repositories as well the need to edit/move/recreate the file in /etc would be a more appropriate method.

At minimum, please signify that these are purely optional repositories and are not needed to function somewhere in the configuration section?

limiting prefetch download speed

Pacoloco is very useful especially for people with limited bandwidth.
In case you want to install a new package you are probably fine with the download taking up all the bandwidth there is.
For prefetching though it would be really nice to limit the speed in order to prevent a congested connection.

Add support for http proxy

Hi, my server is behind corporate proxy so when using pacman I have to define env variables which is pretty annoying.
I thought caching proxy will be great solution to this situation.
Installed pacoloco and running but I see that packages aren't downloading.
Is there any solution to work pacoloco with proxy server or the server must have internet connection ?

Setup CI buildbot for the project

We need to check that any commit and PR passes all the tests successfully.

It would be great to test ARM architecture as well GOARCH=arm GOARM=7 go build.

download is killed unfinished

When running pacman -Syu, I get while donwloading libreoffice-fresh:

error: failed retrieving file 'libreoffice-fresh-7.0.1-1-x86_64.pkg.tar.zst' from ymir:9129 : transfer closed with 32344552 bytes remaining to read#---------------]  76%
warning: failed to retrieve some files
error: failed to commit transaction (download library error)
Errors occurred, no packages were upgraded.

This seems to come from that error in pacoloco log

Sep 05 19:09:30 ymir pacoloco[19235]: pacoloco.go:196: downloading http://mir.archlinux.fr//extra/os/x86_64/libreoffice-fresh-7.0.1-1-x86_64.pkg.tar.zst
Sep 05 19:09:50 ymir pacoloco[19235]: pacoloco.go:206: context deadline exceeded

This is because of commit abe6bf6

I have a fiber connexion and 20 seconds is not enough to download the 134MB package. I don't even speak for the ADSL guys.

log with timestamp

it would be helpful to be able to track when things happened in the log, for example #64. currently the log lines don't include timestamps. i would suggest adding them.

Many packages and dbs cannot be downloaded

Many packages cannot be downloaded by pacoloco, context deadline exceeded and http: wrote more than the declared Content-Length errors seem to be the most relevant messages.
This is the log with the current version, after renaming mirror names:

ago 24 00:25:45 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/core.db.sig: no such file or directory
ago 24 00:25:48 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/extra.db.sig: no such file or directory
ago 24 00:25:50 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/community.db.sig: no such file or directory
ago 24 00:25:51 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/multilib.db.sig: no such file or directory
ago 24 00:26:09 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/core.db.sig: no such file or directory
ago 24 00:26:11 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/extra.db.sig: no such file or directory
ago 24 00:26:20 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/community.db.sig: no such file or directory
ago 24 00:26:22 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/multilib.db.sig: no such file or directory
ago 24 00:26:25 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror1.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:30 test pacoloco[150550]: pacoloco.go:218: context deadline exceeded
ago 24 00:26:30 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror2.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:34 test pacoloco[150550]: pacoloco.go:218: http: wrote more than the declared Content-Length
ago 24 00:26:34 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror3.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:34 test pacoloco[150550]: pacoloco.go:218: http: wrote more than the declared Content-Length
ago 24 00:26:34 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror4.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:34 test pacoloco[150550]: pacoloco.go:218: http: wrote more than the declared Content-Length
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror5.example/repos//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:218: http: wrote more than the declared Content-Length
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror6.example//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:218: http: wrote more than the declared Content-Length
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst: no such file or directory
ago 24 00:26:35 test pacoloco[150550]: server.go:3159: http: superfluous response.WriteHeader call from main.pacolocoHandler (pacoloco.go:58)
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror1.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:35 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:36 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror2.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:36 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:36 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror3.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:36 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror4.example/archlinux//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror5.example/repos//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:208: downloading https://mirror6.example//community/os/x86_64/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:218: write tcp 192.168.1.30:9129->192.168.1.37:49292: write: broken pipe
ago 24 00:26:37 test pacoloco[150550]: pacoloco.go:57: open /opt/pacoloco/cache/pkgs/archlinux/gcc10-libs-1:10.3.0-1-x86_64.pkg.tar.zst: no such file or directory
ago 24 00:26:37 test pacoloco[150550]: server.go:3159: http: superfluous response.WriteHeader call from main.pacolocoHandler (pacoloco.go:58)

It happens also when connecting to pacoloco through localhost.
Saw a similar issue here .
I am using go1.17 linux/amd64.

Also, on the client side, error messages are like (i have translated them, for the same error that happened for another file):

error: cannot download package 'community.db' from 192.168.1.30:9129 : transfer closed with 14897 bytes remaining to read
error: cannot download package 'community.db' from 192.168.1.30:9129 : transfer closed with 14897 bytes remaining to read
error: cannot download package 'community.db' from 192.168.1.30:9129 : transfer closed with 14897 bytes remaining to read
warning: too many errors from 192.168.0.104:61637, skipping for the remainder of this transaction

These error messages are about another transaction (community.db) but they should be informative enough

FR: Uploading packages via HTTP

Hello,
I am looking for a HTTP server for Arch packages that works similar to chartmuseum. Since there is already a HTTP mirror for Arch packages with pacoloco I wanted to ask if it would be possible to extend it so that it is possible to upload packages via HTTP. My requirements would be:

  • HTTP API
  • update of the repository database
  • Multitanent capability
  • Delivery via container image

If there is already something I am quite interested in a solution.

pacoloco.go:138: repo archlinux_x86_64 does not exist in config

we installed on two different boxes the pacoloco service and on both we get the same error:

● pacoloco.service - Pacoloco caching proxy server
     Loaded: loaded (/usr/lib/systemd/system/pacoloco.service; disabled; vendor preset: disabled)
     Active: active (running) since Sun 2022-04-17 07:24:52 CEST; 11min ago
   Main PID: 866 (pacoloco)
      Tasks: 6 (limit: 2350)
     Memory: 14.6M
        CPU: 26ms
     CGroup: /system.slice/pacoloco.service
             └─866 /usr/bin/pacoloco

Apr 17 07:25:46 archvm pacoloco[866]: pacoloco.go:138: repo archlinux_x86_64 does not exist in config
Apr 17 07:28:49 archvm pacoloco[866]: pacoloco.go:138: repo archlinux_x86_64 does not exist in config
Apr 17 07:28:49 archvm pacoloco[866]: pacoloco.go:138: repo archlinux_x86_64 does not exist in config
Apr 17 07:28:49 archvm pacoloco[866]: pacoloco.go:138: repo archlinux_x86_64 does not exist in config
Apr 17 07:32:26 archvm pacoloco[866]: pacoloco.go:138: repo archlinux_x86_64 does not exist in config

The clients get error: The requested URL returned error: 404
The config file on both server looks the same:

/etc/pacoloco.yaml

# cache_dir: /var/cache/pacoloco
# port: 9129
download_timeout: 3600 # downloads will timeout if not completed after 3600 sec, 0 to disable timeout
purge_files_after: 2592000 # purge file after 30 days
repos:
  archlinux:
    urls:
      - http://mirror.lty.me/archlinux
      - http://mirrors.kernel.org/archlinux
  archlinux-reflector:
    mirrorlist: /etc/pacman.d/mirrorlist # Be careful! Check that pacoloco URL is NOT included in that file!
  quarry:
    url: http://pkgbuild.com/~anatolik/quarry/x86_64
  sublime:
    url: https://download.sublimetext.com/arch/stable/x86_64
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.

the clients mirrorlist:

Server = http://archvm.local:9129/repo/archlinux_$arch/$repo/os/$arch

Support for more compression formats for prefetching

I have enabled prefetching and it is working well for most repositories. However it doesn’t work with chaotic-aur and repo-ck.
According to the log output pacoloco assumes that the .db files are gzip compressed.
According to the file tool, one is XZ compressed and the other one is zstd compressed.
I am not sure if there are also other compressions in use with other repositories.

It would be nice if pacoloco could support the same compression formats as pacman.
Seems like pacman uses libarchive for that.

Docker does not download from Archlinux servers

Situation: The LAN server here actually runs Debian 10, but many workstations run Archlinux. Hence the desire to set up a proxy cache for pacman that also purges its storage. I am trying out Pacoloco.

Problem: I pulled the official docker image; I modified the pacoloco.yaml file, and created a directory for the cache. I then run the docker container, which starts up with no errors.

Herewith the local-mirrorlist on the Archlinux client; and the pacoloco.yaml file on the server.

local-mirrorlist.txt
pacoloco.yaml.txt

The container is run with the following command: $ docker run -p 9129:9129 -v /home/[redacted]/docker/pacoloco/files/pacoloco.yaml:/etc/pacoloco.yaml -v /srv/pacoloco/:/var/cache/pacoloco ghcr.io/anatol/pacoloco

However, the docker container does not seem to pull files (databases, packages, signature files) from upstream servers.

When I manually place a .zst file in the correct directory, my Archlinux client downloads it (and then stumbles over the fact that there isn't a .sig file, but that is not important now). I conclude that the server can distribute within the LAN.

I did create a second container, based on the official Archlinux image; I installed the package pacoloco in it from the official mirror; and realise that that container can talk to the Internet in any event, since it can download and install software. The same issue of not pulling updates from official servers exists in that container, though.

I reckon that I am missing a simple configuration step. Since I did not find a GitHub Discussions page, I am posting this Issue.

Thank you for your assistance.

Edit: Correction in line 1.

Tips

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.

How to reset the Pacoloco docker server when the "byte range" issue occurs?

Hi all,

I recently interrupted a download of updates, and now I cannot update my system via the local Pacoloco mirror, as it throws the following error:

failed retrieving file '[redacted].pkg.tar.zst' from [redacted]:9129 : HTTP server doesn't seem to support byte ranges. Cannot resume.

This seems related to the following open issue here on GitHub: Issue 7.

While awaiting an update that adds support or works around this issue, how can I resume updating my system while using the Pacoloco server?

My guess is that there is a partial file somewhere, and Pacoloco cannot resume the download and/or the serving of this partial file. This might well be a wrong assumption, hence my request for assistance here.

Based on my assumption, I logged into the Pacoloco docker container via docker exec -it [redacted] ash and tried to find a download cache. I couldn't find it.

I then used find to try locate any partial downloads with a filename of the to be downloaded package (e.g. `find / -name poppler*), but nothing turned up.

What is the way to 'reset' the pacoloco server so that I can continue using it?

Thank you in advance!

Cleanup old cached files

Currently pacoloco does not do anything with the old cached files. But older files have less chance to be reused so we need to purge them to save some disk space.

A simple solution like having a config option clean_after: 1m should be fine.

exits with "no such table"

i'm running with docker compose.

tonight at the scheduled prefetch time, pacoloco exited with code 1.

this is the end of the log:

pacoloco  | prefetch.go:255: Starting prefetching routine...
pacoloco  | prefetch.go:182: Cleaning the db...
pacoloco  | prefetch.go:217: Db cleaned.
pacoloco  | prefetch.go:261: Starting prefetching packages...
pacoloco  | prefetch_db.go:196: no such table: mirror_packages

Having trouble running pacoloco via Docker

When I try to start the Docker container after building it with the provided instructions (as well as putting the config file listed below), this is what it returns:

pacoloco.go:102: Reading config file from /etc/pacoloco.yaml
pacoloco.go:105: read /etc/pacoloco.yaml: is a directory

Add cross-distribution cache hit support

Packages that exist for both Manjaro and Archlinux, for example, with the same sig will be downloaded twice.

pi@raspberrypi:~ $ ls -l ext_disk1/archmirror-cache/pkgs/*/acl-2.3.1-2-x86_64.pkg.tar.zst
-rw-r--r-- 1 pi pi 138970 Feb  1 15:50 ext_disk1/archmirror-cache/pkgs/archlinux/acl-2.3.1-2-x86_64.pkg.tar.zst
-rw-r--r-- 1 pi pi 138970 Feb  2 15:01 ext_disk1/archmirror-cache/pkgs/manjaro/acl-2.3.1-2-x86_64.pkg.tar.zst

pi@raspberrypi:~ $ sha256sum ext_disk1/archmirror-cache/pkgs/*/acl-2.3.1-2-x86_64.pkg.tar.zst.sig 
00b0bcd4ac5e7e8f3308bfca5892ba46086b13b81b5aa8d523bb61905c85b16c  ext_disk1/archmirror-cache/pkgs/archlinux/acl-2.3.1-2-x86_64.pkg.tar.zst.sig
00b0bcd4ac5e7e8f3308bfca5892ba46086b13b81b5aa8d523bb61905c85b16c  ext_disk1/archmirror-cache/pkgs/manjaro/acl-2.3.1-2-x86_64.pkg.tar.zst.sig

Ideally, this should cause a cache hit rather than re-download.

Filename regex for prefetching does not match

There are still some packages whose filenames don’t match the regex and are ignored (see #28 (review)). It seems that the packages are from a third party repository. See this log excerpt:

repo_db_mirror.go:184: Adding entries to db...
repo_db_mirror.go:191: error: filename android-sdk-26.1.1-1.1-x86_64.pkg.tar.xz does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename grub2-theme-arch-leap-1-3.1-any.pkg.tar.xz does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename hpoj-0.91-21.1-x86_64.pkg.tar.xz does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename libnatspec-0.3.0-2.1-x86_64.pkg.tar.xz does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename qt5-base-24h-5.15.2+kde+r254-1.7-x86_64.pkg.tar.zst does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename qt5-base-24hms-5.15.2+kde+r254-1.7-x86_64.pkg.tar.zst does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename rxvt-unicode-better-wheel-scrolling-9.22-5.1-x86_64.pkg.tar.zst does not match regex, matches length is 0
repo_db_mirror.go:191: error: filename vim-pathogen-2.4-1.1-any.pkg.tar.xz does not match regex, matches length is 0
repo_db_mirror.go:220: Added entries to db.

docker-compose build fails.

Hi! I created a docker-compose file to easily bring up the proxy however I am facing the following error:

This is my docker-compose.yml:

---
version: "3.3"
services:
  pacoloco:
    container_name: pacoloco
    build: https://github.com/anatol/pacoloco.git
    ports:
      - "9129:9129"
    volumes:
      - /mnt/pacoloco/cache:/var/cache/pacoloco/pkgs
      - /mnt/pacoloco/config/pacoloco.yaml:/etc/pacoloco.yaml
    networks:
      - pacoloco

networks:
  pacoloco:
    external: true

to start this I use:

sudo docker-compose -f docker-compose-pacoloco.yml up

and as a result I get:

Starting pacoloco ... done
Attaching to pacoloco
pacoloco    | pacoloco.go:104: Reading config file from /etc/pacoloco.yaml
pacoloco    | prefetch.go:34: The prefetching routine will be run on 2021-11-11 03:00:00.000052408 +0000 UTC m=+28762.631952104
pacoloco    | prefetch.go:67: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
pacoloco exited with code 1

Unfortunately I have no expertise with Go so I would appreciate if you could give me some hint to fix this issue.

Thanks.

Fails to build on armv6h

You should consider reverting the last commit efcf97d because it gives this error on armv6h (which is a 32bit architecture if I am not wrong):

go: downloading golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8
go: downloading gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
# github.com/anatol/pacoloco
./purge.go:43:31: cannot use atimeUnix.Sec (type int32) as type int64 in argument to time.Unix
./purge.go:43:46: cannot use atimeUnix.Nsec (type int32) as type int64 in argument to time.Unix

It compiles fine without that commit

Add travis runner for a 32-bit platform

Issue #18 happened because of API inconsistency between 64-bit and 32-bit environments. To avoid such issues in the future we need to run pacoloco tests at 32-bit platform regularly. Ideally it should be done with travis.

Figure out how to run travis pacoloco tests at multiple platforms (linux 64bit, linux 32bit, macosx maybe, ...).

Auto fetch updates

What about a feature, which makes the proxy more of an "intelligent" proxy. The proxy detects the downloaded package. If a new version of this package exists, the proxy downloads this new version, even if it hasn't been requested by a client. If this new version won't be used/downloaded, upcoming versions won't be predownloaded. This improves updates even at the first download.

doc for different arch

The tip found on aur.archlinux.org about the use of different arch should definitvly be in the README.md or in some sort of doc.

If you need to proxy pacman databases for different arches then you need to have multiple different repos:

repos:
  archlinux_x86_64:
    urls:
      - http://mirror.lty.me/archlinux
      - http://mirrors.kernel.org/archlinux
 archlinux_arm:
    urls:
      - http://foo.bar/archlinux/arm
      - http://bar.foo/another_arch_arm_repo
Then modify pacman.conf to point to the repo with the required architecture http://myserver:9129/repo/archlinux_$arch

System hangs every once in a while while downloading files

After finally getting this all working I have noticed that when it is downloading a large number of new files it seems to cause the VM to hand for about close to 10 seconds. Some downloads fail cause if it and others will pick up shortly after. I noticed the issue when I was ssh into the server and when it froze downloading files ssh also froze. Any ideas would be nice.

The VM is a Hyper-V VM with 1 GB of ram and 1 core. If I should increase those I will.

Many thanks.

error: failed retrieving file 'core.db' from nuc6.lan:9129 : Empty reply from server

journal output

Feb 19 17:11:57 nuc6 pacoloco[3330027]: server.go:3056: http: panic serving 192.168.1.103:44840: runtime error: invalid memory address or nil pointer dereference
Feb 19 17:11:57 nuc6 pacoloco[3330027]: goroutine 29 [running]:
Feb 19 17:11:57 nuc6 pacoloco[3330027]: net/http.(*conn).serve.func1(0xc0000a1d60)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:1767 +0x139
Feb 19 17:11:57 nuc6 pacoloco[3330027]: panic(0x710d00, 0x9e1bf0)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/runtime/panic.go:679 +0x1b2
Feb 19 17:11:57 nuc6 pacoloco[3330027]: main.handleRequest(0x7e7420, 0xc0000f6540, 0xc0001b4500, 0x75d4a0, 0xc00003dbc0)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /home/drago5/.cache/yay/pacoloco-git/src/pacoloco/pacoloco.go:94 +0x6e8
Feb 19 17:11:57 nuc6 pacoloco[3330027]: main.pacolocoHandler(0x7e7420, 0xc0000f6540, 0xc0001b4500)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /home/drago5/.cache/yay/pacoloco-git/src/pacoloco/pacoloco.go:43 +0x43
Feb 19 17:11:57 nuc6 pacoloco[3330027]: net/http.HandlerFunc.ServeHTTP(0x78bc80, 0x7e7420, 0xc0000f6540, 0xc0001b4500)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:2007 +0x44
Feb 19 17:11:57 nuc6 pacoloco[3330027]: net/http.(*ServeMux).ServeHTTP(0x9eea60, 0x7e7420, 0xc0000f6540, 0xc0001b4500)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:2387 +0x1bd
Feb 19 17:11:57 nuc6 pacoloco[3330027]: net/http.serverHandler.ServeHTTP(0xc0000f6000, 0x7e7420, 0xc0000f6540, 0xc0001b4500)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:2802 +0xa4
Feb 19 17:11:57 nuc6 pacoloco[3330027]: net/http.(*conn).serve(0xc0000a1d60, 0x7e7c20, 0xc0000a4c80)
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:1890 +0x875
Feb 19 17:11:57 nuc6 pacoloco[3330027]: created by net/http.(*Server).Serve
Feb 19 17:11:57 nuc6 pacoloco[3330027]:         /usr/lib/go/src/net/http/server.go:2928 +0x384

yaml config

cache_dir: /srv/samba2/pacoloco
port: 9129
repos:
  archlinux:
    urls:
      - https://archlinux.mivzakim.net
      - http://mirror.isoc.org.il/pub/archlinux
      - http://mirrors.evowise.com/archlinux
      - http://mirror.rackspace.com/archlinux
      - https://mirror.rackspace.com/archlinux
      - http://mirrors.kernel.org/archlinux

Fail to download

pacolo.yml

repos:
  archlinux:
    urls:
    - https://mirrors.sonic.net/archlinux
    - https://mirrors.kernel.org/archlinux
    - https://mirror.sfo12.us.leaseweb.net/archlinux
    - https://mirror.fcix.net/archlinux
    - https://mirrors.xtom.com/archlinux
    - https://mirror.arizona.edu/archlinux
    - https://mirror.lty.me/archlinux
  arch4edu:
    url: https://mirrors.tuna.tsinghua.edu.cn/arch4edu
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.

/etc/pacman.conf

[arch4edu]
# Server = https://arch4edu.keybase.pub/$arch
# Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch
Server = http://10.1.0.2:9129/repo/arch4edu/$arch

Issue:

When I run sudo pacman -Sw visual-studio-code-bin, I got the error error: failed retrieving file 'visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst' from 10.1.0.2:9129 : The requested URL returned error: 404 . If I run curl http://10.1.0.2:9129/repo/arch4edu/x86_64 , I can get a correct list of packages. The journal shows

Oct 20 23:52:17 NAS pacoloco[115768]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/arch4edu/visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst: no such file or directory

Publishing to ghcr.io

Hello,

I was looking for a shared pacman cache for my computers and found pacoloco. I looks exactly like what I need, the only problem is that my NAS running kubernetes which means I need pacoloco to be published in a registry.

What do you say if I open a PR with a github workflow that runs tests and then builds and publishes the image to ghcr.io so that anyone can simply pull the image from there?

The logic is simple: every time you push to master it will publish to latest, every time you create a release, it will publish a corresponding tag.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.