Subject: [bug#53434] Patches to unbreak many i686 packages

From: Maxime Devos <[email-masked]>
Date: Fri, 18 Feb 2022 08:50:45 +0100

Ludovic Courtès schreef op do 17-02-2022 om 11:40 [+0100]:
> Yes, we can do that on master.  Do you want to give it a try?

See attachment! I verified that:

* upower builds: ./pre-inst-env guix build upower
* upower builds on i686:
 ./pre-inst-env guix build upower --system=i686-linux
* linting (almost) succeeds:

  ./pre-inst-env guix lint upower umockdev
  [...] [email-masked]: label 'glib' does not match package name 'glib:bin'

  I just did `(,glib "bin") (new-input style), so this seems more a problem
  of the linter or whatever code is reponsible for constructing labels to me.

  [...]: [email-masked]: line 5457 is way too long (101 characters)

  It contains a long URL, so not much that can be done here.

* the dependents of upower and umockdev build:

  ./pre-inst-env guix refresh -l upower umockdev
  [...]: [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] gnome-shell-extension-gsconnect@33 arc-theme@20210412 [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked]
  ./pre-inst-env guix build [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] gnome-shell-extension-gsconnect@33 arc-theme@20210412 [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked] [email-masked]

  This took to long to run it to the end, but no build failures so far

It has _not_ been verified whether this upower is usable for system services!

Some remarks:

* "guix refresh -u upower" did not work completely because the 'commit' field
  was

 (string-append "UPOWER_" (string-map (match-lambda (#\. #\_)
                                        (chr chr))
                                      version))

  before the update and (string-append "v" version) after the update,
  which (guix upstream) does not not how to change.

  If the tag was replaced by the commit it referred to, this would not
  have been necessary.

Greetings,
Maxime.
From 08cc8cdb129241d194c2c2bac4b05a7809eae00c Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 14:47:38 +0000
Subject: [PATCH 1/6] gnu: upower: Make it auto-updatable.

* gnu/packages/gnome.scm (upower)[properties]: Set 'release-tag-prefix'
  and 'release-tag-delimiter'.
---
 gnu/packages/gnome.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 92900c8421..b5c81fe6ff 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -5512,7 +5512,11 @@ faster results and to avoid unnecessary server load.")
 listening to device events and querying history and statistics.  Any
 application or service on the system can access the org.freedesktop.UPower
 service via the system message bus.")
-    (license license:gpl2+)))
+    (license license:gpl2+)
+    ;; Old versions of upower are tagged as UPOWER_0_99_13, which confuses
+    ;; the 'generic-git' updater.  Give it a little help.
+    (properties '((release-tag-prefix . "v")
+                  (release-tag-version-delimiter . ".")))))
 
 (define-public libgweather
   (package

base-commit: 877da38bd3f279d5618d6c6517f48b50541a1e4c
-- 
2.30.2

From 6bdcd52a01e16c31b91c01805e9d1cc15ad0cc4f Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 14:51:13 +0000
Subject: [PATCH 2/6] gnu: upower: Update to 0.99.15.

Upstream has removed the Autotools build system and now
only supports Meson, so the build system has been changed
to 'meson-build-system'.

The patch 'power-builddir.patch' has to be replaced to
adjust to the switch to Meson.  This has been done by adding
an origin snippet.

The origin snippet has been simplified, and for consistency,
it has been made a gexp.

Some dependencies were Autotools-only and could be removed.

* gnu/packages/gnome.scm (upower): Update to 0.99.15.
---
 gnu/local.mk                               |  1 -
 gnu/packages/gnome.scm                     | 67 +++++++++++-----------
 gnu/packages/patches/upower-builddir.patch | 34 -----------
 3 files changed, 33 insertions(+), 69 deletions(-)
 delete mode 100644 gnu/packages/patches/upower-builddir.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index dddda78efa..e354ddcfb0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1938,7 +1938,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/util-linux-tests.patch			\
   %D%/packages/patches/util-linux-CVE-2021-3995.patch		\
   %D%/packages/patches/util-linux-CVE-2021-3996.patch		\
-  %D%/packages/patches/upower-builddir.patch			\
   %D%/packages/patches/valgrind-enable-arm.patch		\
   %D%/packages/patches/vboot-utils-fix-format-load-address.patch	\
   %D%/packages/patches/vboot-utils-fix-tests-show-contents.patch	\
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index b5c81fe6ff..64571d414a 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -62,7 +62,7 @@
 ;;; Copyright © 2021 Solene Rapenne <[email-masked]>
 ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <[email-masked]>
 ;;; Copyright © 2021 Felix Gruber <[email-masked]>
-;;; Copyright © 2021 Maxime Devos <[email-masked]>
+;;; Copyright © 2021, 2022 Maxime Devos <[email-masked]>
 ;;; Copyright © 2021 Josselin Poiret <[email-masked]>
 ;;; Copyright © 2021 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2022 Daniel Meißner <[email-masked]>
@@ -5441,55 +5441,54 @@ faster results and to avoid unnecessary server load.")
 (define-public upower
   (package
     (name "upower")
-    (version "0.99.13")
+    (version "0.99.15")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
              (url "https://gitlab.freedesktop.org/upower/upower")
-             (commit (string-append "UPOWER_"
-                                    (string-map (match-lambda (#\. #\_)
-                                                              (chr chr))
-                                                version)))))
+             (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0khwg6jpq81dcylkpi7cn75bjzif0q9qscwvirrk41krma23iddj"))
-       (patches (search-patches "upower-builddir.patch"))
+        (base32 "1zk7w7pw8dhlnxhxzcbk33gmxmg8f32mppd67556v9z2qgcg4lhs"))
        (modules '((guix build utils)))
        (snippet
-        '(begin
-           ;; Upstream commit
-           ;; <https://cgit.freedesktop.org/upower/commit/?id=18457c99b68786cd729b315723d680e6860d9cfa>
-           ;; moved 'dbus-1/system.d' from etc/ to share/.  However,
-           ;; 'dbus-configuration-directory' in (gnu services dbus)
-           ;; expects it in etc/.  Thus, move it back to its previous
-           ;; location.
-           (substitute* "src/Makefile.am"
-             (("^dbusconfdir =.*$")
-              "dbusconfdir = $(sysconfdir)/dbus-1/system.d\n"))))))
-    (build-system glib-or-gtk-build-system)
+         ;; Upstream commit
+         ;; <https://cgit.freedesktop.org/upower/commit/?id=18457c99b68786cd729b315723d680e6860d9cfa>
+         ;; moved 'dbus-1/system.d' from etc/ to share/.  However,
+         ;; 'dbus-configuration-directory' in (gnu services dbus)
+         ;; expects it in etc/.  Thus, move it back to its previous
+         ;; location.
+         #~(substitute* "src/meson.build"
+            (("dbusdir / 'system.d'")
+              "get_option('sysconfdir') / 'dbus-1/system.d'")
+            ;; Avoid writing to /var during the build, this is
+            ;; not possible in Guix!
+            (("^install_subdir\\('does-not-exist'.*$") "")))))
+    (build-system meson-build-system)
     (arguments
-     '(#:phases
-       (modify-phases %standard-phases
-         (add-before 'check 'pre-check
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((umockdev (string-append (assoc-ref inputs "umockdev")
-                                            "/lib")))
-               (setenv "LD_LIBRARY_PATH" umockdev)))))
-       #:configure-flags (list "--localstatedir=/var"
-                               (string-append "--with-udevrulesdir="
-                                              (assoc-ref %outputs "out")
-                                              "/lib/udev/rules.d"))))
+      (list
+       #:glib-or-gtk? #t
+       #:phases
+       #~(modify-phases %standard-phases
+          (add-before 'check 'pre-check
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((umockdev (string-append (assoc-ref inputs "umockdev")
+                                             "/lib")))
+                (setenv "LD_LIBRARY_PATH" umockdev)))))
+       #:configure-flags
+       #~(list "-Dsystemdsystemunitdir=no"
+               ;; If not specified, udev will try putting history information
+               ;; in /gnu/store.
+               "-Dhistorydir=/var/lib/upower"
+               (string-append "-Dudevrulesdir=" #$output "/bin/udev/rules.d"))))
     (native-inputs
-     (list autoconf
-           automake
+     (list `(,glib "bin") ; for gdbus-codegen
            gobject-introspection
            gtk-doc
            intltool
-           libtool
            pkg-config
            python
-           which ; for ./autogen.sh
            ;; For tests.
            python-dbus
            python-dbusmock
diff --git a/gnu/packages/patches/upower-builddir.patch b/gnu/packages/patches/upower-builddir.patch
deleted file mode 100644
index a61d387faf..0000000000
--- a/gnu/packages/patches/upower-builddir.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 27ae011b31d831752b97eb209bc2b2206fcf40f7 Mon Sep 17 00:00:00 2001
-From: Tobias Geerinckx-Rice <[email-masked]>
-Date: Mon, 28 Jun 2021 11:58:47 +0200
-Subject: [PATCH] gnu: upower: Fix build directory.
-
-Remove explicit set of UPOWER_CONF_FILE_NAME in up-self-test.c;
-instead the harness should set it.  In Guix we set it explicitly; the
-right thing is to use AM_TEST_ENVIRONMENT and regenerate the
-makefiles, but we can't regenerate because current autotools carp on
-some things, so we patch the Makefile.in instead.
-
-Also fix to not try to create /var/lib/upower if /var isn't writable.
-
-Based on a patch by Andy Wingo <[email-masked]>
----
- src/Makefile.am | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 3400139..f51ee89 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -181,7 +181,7 @@ $(systemdservice_DATA): $(systemdservice_in_files) Makefile
- endif
- 
- install-data-hook:
--	if test -w $(DESTDIR)$(prefix)/; then \
-+	if test -w $(DESTDIR)$(localstatedir)/; then \
- 		mkdir -p $(DESTDIR)$(historydir); \
- 	fi
- 
--- 
-2.32.0
-
-- 
2.30.2

From c36d191e64303e1f58f77b7c106d73f8a9f4f324 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 18:09:49 +0000
Subject: [PATCH 3/6] gnu: umockdev: Use G-expressions.

While we're at it, remove the trailing #t.

* gnu/packagers/check.scm (umockdev)[arguments]<#:phases>: Change to a G-exp.
---
 gnu/packages/check.scm | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 4115a5c22b..6060bff4cb 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -2844,13 +2844,12 @@ provides a simple way to achieve this.")
                 "0xmi24ckpps32k7hc139psgbsnsf4g106sv4l9m445m46amkxggd"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'fix-test
-           (lambda _
-             (substitute* "tests/test-umockdev.c"
-               (("/run") "/tmp"))
-             #t)))))
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'fix-test
+                 (lambda _
+                   (substitute* "tests/test-umockdev.c"
+                     (("/run") "/tmp")))))))
     (native-inputs
      (list vala
            gobject-introspection
-- 
2.30.2

From 7668016b2db3fcf1dd24f74e7060962dfd48cd36 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 18:30:00 +0000
Subject: [PATCH 4/6] gnu: umockdev: Reference 'env' and 'sh' by absolute path.

* gnu/packages/check.scm
  (umockdev)[inputs]: Add 'bash-minimal' and 'coreutils-minimal'.
  (umockdev)[arguments]<#:phases>{absolute-filenames}: New phase.
---
 gnu/packages/check.scm | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 6060bff4cb..deffcefda2 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -37,6 +37,7 @@
 ;;; Copyright © 2020 Tanguy Le Carrour <[email-masked]>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2021 Hugo Lecomte <[email-masked]>
+;;; Copyright © 2022 Maxime Devos <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2849,7 +2850,14 @@ provides a simple way to achieve this.")
                (add-after 'unpack 'fix-test
                  (lambda _
                    (substitute* "tests/test-umockdev.c"
-                     (("/run") "/tmp")))))))
+                     (("/run") "/tmp"))))
+               (add-after 'install 'absolute-filenames
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; 'patch-shebangs' will take care of the shebang.
+                   (substitute* (string-append #$output "/bin/umockdev-wrapper")
+                     (("env") (search-input-file inputs "bin/env"))
+                     (("libumockdev")
+                      (string-append #$output "/lib/libumockdev"))))))))
     (native-inputs
      (list vala
            gobject-introspection
@@ -2859,7 +2867,9 @@ provides a simple way to achieve this.")
            python
            which))
     (inputs
-     (list glib eudev libgudev))
+     (list bash-minimal ;for umockdev-wrapper
+           coreutils-minimal ;for bin/env
+           glib eudev libgudev))
     (home-page "https://github.com/martinpitt/umockdev/")
     (synopsis "Mock hardware devices for creating unit tests")
     (description "umockdev mocks hardware devices for creating integration
-- 
2.30.2

From 5f133f50031fb194e212af1ec39c11abb64d47c7 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 19:02:08 +0000
Subject: [PATCH 5/6] gnu: umockdev: Reference libumockdev by absolute path.

* gnu/packages/check.scm
  (umockdev)[arguments]<#:phases>{absolute-introspection-library}:
  New phase.
---
 gnu/packages/check.scm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index deffcefda2..39273c6fb5 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -2851,6 +2851,14 @@ provides a simple way to achieve this.")
                  (lambda _
                    (substitute* "tests/test-umockdev.c"
                      (("/run") "/tmp"))))
+               ;; Avoid having to set 'LD_LIBRARY_PATH' to use umockdev
+               ;; via introspection.
+               (add-after 'unpack 'absolute-introspection-library
+                 (lambda _
+                   (substitute* "Makefile.in"
+                     (("g-ir-compiler -l libumockdev")
+                      (string-append "g-ir-compiler -l " #$output
+                                     "/lib/libumockdev")))))
                (add-after 'install 'absolute-filenames
                  (lambda* (#:key inputs #:allow-other-keys)
                    ;; 'patch-shebangs' will take care of the shebang.
-- 
2.30.2

From 3771de31fc23a626eebb153589ceac4aa25189f6 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Thu, 17 Feb 2022 19:05:26 +0000
Subject: [PATCH 6/6] gnu: upower: Remove obsolete phase

Now umockdev-wrapper refers to things by absolute path, this phase
is no longer necessary.

* gnu/packages/gnome.scm
  (upower)[arguments]<#:phases>{pre-check}: Remove.
---
 gnu/packages/gnome.scm | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 64571d414a..708542ccd7 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -5469,13 +5469,6 @@ faster results and to avoid unnecessary server load.")
     (arguments
       (list
        #:glib-or-gtk? #t
-       #:phases
-       #~(modify-phases %standard-phases
-          (add-before 'check 'pre-check
-            (lambda* (#:key inputs #:allow-other-keys)
-              (let ((umockdev (string-append (assoc-ref inputs "umockdev")
-                                             "/lib")))
-                (setenv "LD_LIBRARY_PATH" umockdev)))))
        #:configure-flags
        #~(list "-Dsystemdsystemunitdir=no"
                ;; If not specified, udev will try putting history information
-- 
2.30.2