FS#66182 - [pacman] CacheDir handling inconsistent

Attached to Project: Pacman
Opened by Toolybird (Toolybird) - Thursday, 09 April 2020, 07:20 GMT
Last edited by Allan McRae (Allan) - Friday, 23 December 2022, 13:24 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Consider the following with a default /etc/pacman.conf:

$ pwd
/tmp/p
$ grep Cache /etc/pacman.conf
#CacheDir = /var/cache/pacman/pkg/
$ pacman -v 2>&1 | grep Cache
Cache Dirs: /var/cache/pacman/pkg/
$ pacman -v --cachedir=$(pwd) 2>&1 | grep Cache
Cache Dirs: /tmp/p/

So far so good. This is what I would expect and matches what the manpage says for --cachedir i.e. "Specify an alternative package cache location"

Now, edit /etc/pacman.conf and uncomment the CacheDir directive:

$ pwd
/tmp/p
$ grep Cache /etc/pacman.conf
CacheDir = /var/cache/pacman/pkg/
$ pacman -v 2>&1 | grep Cache
Cache Dirs: /var/cache/pacman/pkg/
$ pacman -v --cachedir=$(pwd) 2>&1 | grep Cache
Cache Dirs: /tmp/p/ /var/cache/pacman/pkg/

We now have multiple CacheDirs which means there is no way to override or bypass the default pacman cache when /etc/pacman.conf contains CacheDir directive(s).

(yes, this is a fairly niche scenario, but it breaks at least supermin. I'm trying to understand if this a real pacman bug or whether supermin's pacman support needs fixing).

Thanks for looking at this.



This task depends upon

Closed by  Allan McRae (Allan)
Friday, 23 December 2022, 13:24 GMT
Reason for closing:  Not a bug
Additional comments about closing:  Working as expected.
Comment by Andrew Gregory (andrewgregory) - Thursday, 09 April 2020, 15:21 GMT
How does this behavior break supermin?
Comment by Toolybird (Toolybird) - Thursday, 09 April 2020, 21:29 GMT
The problem is easily reproduced in the supermin test suite (make check) when the build host has CacheDir directive(s) in /etc/pacman.conf

For example, when supermin prepares to assemble an appliance it basically does this:

cd '/var/tmp/superminc9d49d.tmpdir/s1gefh7n'
mkdir -p var/lib/pacman
/usr/bin/fakeroot /usr/bin/pacman -Syw --noconfirm --cachedir=$(pwd) --root=$(pwd) 'bash' 'filesystem' 'glibc' 'iana-etc' 'readline'
for f in '/var/tmp/superminc9d49d.tmpdir/s1gefh7n'/*.pkg.tar.xz; do tar -xf "$f" -C '/var/tmp/superminc9d49d.tmpdir/prepare.d'; done

It's downloading the pkgs into the tmpdir so it can unpack them and do processing. This is the part that fails, because pacman is honoring the cache and not downloading the pkgs.

Like I said, supermin's assumption about how --cachedir= works might be the real problem. Is there another way to force pacman to download pkgs?

Upstream bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=1683798
Comment by Andrew Gregory (andrewgregory) - Thursday, 09 April 2020, 21:57 GMT
Just glancing at the function linked in the bug report, that looks broken. It appears to be attempting to set up a temporary installation root to work with, but without --config it's still using the global config file. In addition to pulling in a custom CacheDir, it would also pull in things like a custom DBPath, which looks like it would break things as well.
Comment by Toolybird (Toolybird) - Thursday, 09 April 2020, 23:04 GMT
Doh, I didn't even think of the global config aspect. You've confirmed it's a supermin problem. I'll try and cook up something using --config.

Feel free to close this one. Thanks for your help.
Comment by Toolybird (Toolybird) - Friday, 10 April 2020, 04:43 GMT
Just to close this out, attached patch allows supermin test suite to pass.

It likely doesn't cover all scenarios but hey, it works for me. Please comment if I've missed anything obvious.

Loading...