Created attachment 1701676 [details] The full libguestfs-test-tool output when encountering the bug. Description of problem: supermin tries to parse the pkgrel of a pacman package into an integer, which fails if the version contains anything else than numbers (for example a major.minor verison format). Version-Release number of selected component (if applicable): 5.2.0 How reproducible: Should be reproducible on any pacman-based system, as long as a package with a non-integer pkgrel is installed. Steps to Reproduce: 1. Install package with non-integer pkgrel (for example Manjaro's `dbus-x11` or `util-linux` packages). 2. Run `libguestfs-test-tool` Actual results: libguestfs-test-tool exits with the following (full output in the attachments): supermin: mapping package names to installed packages supermin: resolving full list of package dependencies supermin: failure: failed to parse epoch:version-release field 0.116-5.1 libguestfs: error: /usr/bin/supermin exited with error status 1, see debug messages above libguestfs: closing guestfs handle 0x55606feedaf0 (state 0) Expected results: libguestfs-test-tool does not fail while parsing pacman package versions. Additional info: While the PKGBUILD documentation says that pkgrel is _often_ an integer number, it also mentions exceptional cases where the version is written in a different format.
I'm not sure how to fix this, but I can explain what's happening. This is the code: https://github.com/libguestfs/supermin/blob/a27dd57d3a7c35093d3f5c71cac8d45a220ce016/src/ph_pacman.ml#L73-L89 In this code at line 84 the call to int_of_string is failing because (as you say) the code expects the release field to be an integer but it's "5.1". Furthermore in the internal pac_t type, release is an int (should it be a string)? https://github.com/libguestfs/supermin/blob/a27dd57d3a7c35093d3f5c71cac8d45a220ce016/src/ph_pacman.ml#L39 The release field is not significantly used for anything, so the following patch compiles for me (but I didn't test it further because I don't have a system handy which demonstrates the bug): diff --git a/src/ph_pacman.ml b/src/ph_pacman.ml index b3effca..67f7512 100644 --- a/src/ph_pacman.ml +++ b/src/ph_pacman.ml @@ -36,7 +36,7 @@ type pac_t = { name : string; epoch : int; version : string; - release : int; + release : string; arch : string; } @@ -81,7 +81,7 @@ let pacman_package_of_string str = with Not_found -> 0, evr in let version, release = match string_split "-" vr with - | [ v; r ] -> v, int_of_string r + | [ v; r ] -> v, r | _ -> assert false in epoch, version, release with @@ -117,9 +117,9 @@ let pacman_package_of_string str = let pacman_package_to_string pkg = let pac = pac_of_pkg pkg in if pac.epoch = 0 then - sprintf "%s-%s-%d.%s" pac.name pac.version pac.release pac.arch + sprintf "%s-%s-%s.%s" pac.name pac.version pac.release pac.arch else - sprintf "%s-%d:%s-%d.%s" + sprintf "%s-%d:%s-%s.%s" pac.name pac.epoch pac.version pac.release pac.arch let pacman_package_name pkg =
I dug a bit deeper into the pacman source (or rather libalpm, the actual core), and found more information regarding the format in the linter: https://git.archlinux.org/pacman.git/tree/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in#n40 It seems like only a pkgrel of the formats "%d" or "%d.%d" is allowed, nothing else. Since that can't be stored in an integer, I assume making that a string is the way to go. The patch you attached I built locally and confirmed that libguestfs-test-tool doesn't error out anymore, but instead passes all tests.
https://github.com/libguestfs/supermin/commit/1b6802ba85898c947f2276c365bf8be7eb5f1642
*** Bug 1895623 has been marked as a duplicate of this bug. ***
Hi, Has the fix for this been rolled out? I am running the latest available updates for Manjaro (System completely uptodate as at 16th December) Operating System: Manjaro Linux KDE Plasma Version: 5.20.4 KDE Frameworks Version: 5.76.0 Qt Version: 5.15.2 Kernel Version: 5.8.18-1-MANJARO OS Type: 64-bit I'm trying to clone a KVM domain and I'm getting an error when running "virt-sysprep": "supermin: failure: failed to parse epoch:version-release field 29-1.0 libguestfs: trace: launch = -1 (error) virt-sysprep: error: libguestfs error: /usr/bin/supermin exited with error status 1, see debug messages above"
Neither Arch Linux nor Manjaro have updated their supermin packages since the issue has been fixed, but that isn't surprising seeing how there hasn't been a tagged release since. The best way to get them to adopt the fix early would probably be to ask them to add that patch manually.
Thanks for taking the time to respond. I will follow up with Manjaro team.