Bug 1683798 - supermin broken on Arch / pacman
Summary: supermin broken on Arch / pacman
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: supermin
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-27 20:28 UTC by Toolybird
Modified: 2020-05-26 14:49 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)
Example log file showing test failure (3.28 KB, text/plain)
2019-02-27 20:28 UTC, Toolybird
no flags Details
supermin-pacman.patch (591 bytes, patch)
2019-04-17 05:42 UTC, Toolybird
rjones: review-
Details | Diff
Fix pacman CacheDir handling (1.47 KB, patch)
2020-04-19 07:00 UTC, Toolybird
no flags Details | Diff
pacman-Fix-package-file-extensions (818 bytes, patch)
2020-05-24 07:52 UTC, Toolybird
no flags Details | Diff
pacman-Fix-loop-when-downloading-packages (2.88 KB, patch)
2020-05-24 07:53 UTC, Toolybird
no flags Details | Diff

Description Toolybird 2019-02-27 20:28:16 UTC
Created attachment 1539269 [details]
Example log file showing test failure

Description of problem:
Package builds OK but the *-network part of the testsuite fails.

PASS: test-basic.sh
PASS: test-execstack.sh
PASS: test-build-bash.sh
PASS: test-binaries-exist.sh
PASS: test-harder.sh
FAIL: test-build-bash-network.sh
FAIL: test-binaries-exist-network.sh
FAIL: test-harder-network.sh

Version-Release number of selected component (if applicable):
supermin-5.1.20

How reproducible:
100%

Steps to Reproduce:
1. build supermin on Arch Linux using the recommended chroot (makechrootpkg)
2. run `make check'
3.

Actual results:
Failed tests as per above

Expected results:
All tests should pass

Additional info:
This blocks the build of libguestfs because the appliance fails to build.

The test seems to get stuck in some kind of loop as per the attached log file for example. Any help debugging this would be appreciated.

Comment 1 Toolybird 2019-03-06 07:28:35 UTC
For the record, I ended up being able to build libguestfs by passing:

--with-supermin-extra-options="--use-installed"

to the libguestfs configure script.

Comment 2 Richard W.M. Jones 2019-04-09 08:09:22 UTC
tar: /var/tmp/supermin469d72.tmpdir/d1jcezvx/*.pkg.tar.xz: Cannot open: No such file or directory

The failure seems to happen in this function:

https://github.com/libguestfs/supermin/blob/bca633bfd14aeeb8ae1331d468db75d1ef31f9ff/src/ph_pacman.ml#L164

but I don't know how Arch packaging works or has changed for why this is
now broken, however patches welcome.

Using --use-installed is not recommended.

Comment 3 Toolybird 2019-04-17 05:42:06 UTC
Created attachment 1555733 [details]
supermin-pacman.patch

Comment 4 Toolybird 2019-04-17 05:46:17 UTC
The pacman package handler wants to "Unpack the downloaded packages" but the packages are just not there in the tmpdir where the code expects them to be. pacman uses a download cache as part of its normal operation, so just getting rid of the unpack clause is enough to make it all work.

I've attached a simple patch which allows the testsuite to pass. Not sure if this is the correct approach.

Comment 5 Richard W.M. Jones 2019-04-17 07:45:50 UTC
That's not going to work because supermin will then ignore all configuration files.  You'll
likely find that the generated tarball base.tar.gz from this command now has no files, whereas
it should contain both directories and configuration files:

$ supermin --prepare -o /tmp/supermin.d bash
$ ls -l /tmp/supermin.d

Comment 6 Toolybird 2019-04-18 08:40:28 UTC
You're right. I was barking up the wrong tree.. But I've figured out what's going on now.

A default /etc/pacman.conf does not include a CacheDir directive, in which case pacman assumes a default of /var/cache/pacman/pkg.

The supermin code adds `--cachedir=$(pwd)' to the pacman commandline which satisfactorily overrides the default and forces packages to be downloaded i.e. supermin works.

Things go pear shaped when there is more than 1 CacheDir directive in /etc/pacman.conf, which is often the case for more advanced users who are also running a custom personal package repo.

In this scenario pacman *adds* `--cachedir=$(pwd)' to the *existing* cache dirs and refuses to download the packages because they are already in a CacheDir i.e. supermin breaks.

I can work around the issue with something like:

grep -v CacheDir /etc/pacman.conf > /tmp/pacman.conf
supermin --prepare --packager-config=/tmp/pacman.conf ...

Though, it does seem rather unnecessary for supermin to go and download packages when perfectly up-to-date copies are sitting in a local cache dir. It would be nice if supermin could somehow pull them from the cache. I'm sure the code could be made smarter but this is starting to get above my pay grade.

Comment 7 Toolybird 2020-04-19 06:59:02 UTC
Revisiting this one after latest libguestfs release.

I've attached a patch which makes the supermin testsuite pass. This allows me to finally get libguestfs working in the optimal recommended fashion on Arch.

pacman-conf is part of pacman itself and has been around since mid 2018. Due to the rolling release nature of Arch, it's pretty well guaranteed to be present on every Arch system.

I raised this issue with the pacman devs and there weren't any complaints.

https://bugs.archlinux.org/task/66182

Comment 8 Toolybird 2020-04-19 07:00:22 UTC
Created attachment 1679966 [details]
Fix pacman CacheDir handling

Comment 9 Richard W.M. Jones 2020-04-20 09:04:41 UTC
I pushed it, thanks:

https://github.com/libguestfs/supermin/commit/c05b77000f6a13ac2932121bd625574eea6d5a80

Comment 10 Toolybird 2020-05-24 07:51:07 UTC
I'm attaching another 2 patches for related fixes. Thanks.

Comment 11 Toolybird 2020-05-24 07:52:13 UTC
Created attachment 1691477 [details]
pacman-Fix-package-file-extensions

Comment 12 Toolybird 2020-05-24 07:53:27 UTC
Created attachment 1691478 [details]
pacman-Fix-loop-when-downloading-packages

Comment 13 Richard W.M. Jones 2020-05-26 14:49:14 UTC
Thanks, I've pushed both patches upstream.

Can we close this bug now or are there further issues?


Note You need to log in before you can comment on or make changes to this bug.