[PATCH] gnu: polkit: Fix cross-compiling

  • Done
  • quality assurance status badge
Details
4 participants
  • Andrew Patterson
  • Maxim Cournoyer
  • Jean Pierre De Jesus DIAZ
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Andrew Patterson
Severity
normal

Debbugs page

A
A
Andrew Patterson wrote on 11 Aug 2022 16:11
(address . guix-patches@gnu.org)(name . Andrew Patterson)(address . andrewpatt7@gmail.com)
20220811231100.22090-1-andrewpatt7@gmail.com
The polkit package used to refer to docbook-xsl via inputs rather native inputs,
which obviously doesn't work when cross-compiling.
---
gnu/packages/polkit.scm | 165 ++++++++++++++++++++--------------------
1 file changed, 83 insertions(+), 82 deletions(-)

Toggle diff (196 lines)
diff --git a/gnu/packages/polkit.scm b/gnu/packages/polkit.scm
index a75608cd43..dd0cf42e5d 100644
--- a/gnu/packages/polkit.scm
+++ b/gnu/packages/polkit.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022 Andrew Patterson <andrewpatt7@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -27,6 +28,7 @@
(define-module (gnu packages polkit)
#:use-module ((guix licenses) #:select (lgpl2.0+))
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix memoization)
@@ -55,92 +57,91 @@ (define-public polkit-mozjs
(name "polkit")
(version "0.120")
(source (origin
- (method url-fetch)
- (uri (string-append
- "https://www.freedesktop.org/software/polkit/releases/"
- name "-" version ".tar.gz"))
- (sha256
- (base32
- "00zfg9b9ivkcj2jcf5b92cpvvyljz8cmfwj86lkvy5rihnd5jypf"))
- (patches (search-patches "polkit-configure-elogind.patch"
- "polkit-CVE-2021-4034.patch"))
- (modules '((guix build utils)))
- (snippet
- '(begin
- (use-modules (guix build utils))
- ;; Disable broken test.
- (substitute* "test/Makefile.in"
- (("SUBDIRS = mocklibc . polkit polkitbackend")
- "SUBDIRS = mocklibc . polkit"))
- ;; Disable a test that requires Python, D-Bus and a few
- ;; libraries and fails with "ERROR: timed out waiting for bus
- ;; process to terminate".
- (substitute* "test/polkitbackend/Makefile.am"
- (("TEST_PROGS \\+= polkitbackendjsauthoritytest-wrapper.py")
- ""))
- ;; Guix System's polkit
- ;; service stores actions under /etc/polkit-1/actions.
- (substitute* "src/polkitbackend/polkitbackendinteractiveauthority.c"
- (("PACKAGE_DATA_DIR \"/polkit-1/actions\"")
- "PACKAGE_SYSCONF_DIR \"/polkit-1/actions\""))
- ;; Set the setuid helper's real location.
- (substitute* "src/polkitagent/polkitagentsession.c"
- (("PACKAGE_PREFIX \"/lib/polkit-1/polkit-agent-helper-1\"")
- "\"/run/setuid-programs/polkit-agent-helper-1\""))))))
+ (method url-fetch)
+ (uri (string-append
+ "https://www.freedesktop.org/software/polkit/releases/"
+ name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "00zfg9b9ivkcj2jcf5b92cpvvyljz8cmfwj86lkvy5rihnd5jypf"))
+ (patches (search-patches "polkit-configure-elogind.patch"
+ "polkit-CVE-2021-4034.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ (use-modules (guix build utils))
+ ;; Disable broken test.
+ (substitute* "test/Makefile.in"
+ (("SUBDIRS = mocklibc . polkit polkitbackend")
+ "SUBDIRS = mocklibc . polkit"))
+ ;; Disable a test that requires Python, D-Bus and a few
+ ;; libraries and fails with "ERROR: timed out waiting for bus
+ ;; process to terminate".
+ (substitute* "test/polkitbackend/Makefile.am"
+ (("TEST_PROGS \\+= polkitbackendjsauthoritytest-wrapper.py")
+ ""))
+ ;; Guix System's polkit
+ ;; service stores actions under /etc/polkit-1/actions.
+ (substitute* "src/polkitbackend/polkitbackendinteractiveauthority.c"
+ (("PACKAGE_DATA_DIR \"/polkit-1/actions\"")
+ "PACKAGE_SYSCONF_DIR \"/polkit-1/actions\""))
+ ;; Set the setuid helper's real location.
+ (substitute* "src/polkitagent/polkitagentsession.c"
+ (("PACKAGE_PREFIX \"/lib/polkit-1/polkit-agent-helper-1\"")
+ "\"/run/setuid-programs/polkit-agent-helper-1\""))))))
(build-system gnu-build-system)
- (inputs
- (list expat linux-pam elogind mozjs nspr))
- (propagated-inputs
- (list glib)) ; required by polkit-gobject-1.pc
- (native-inputs
- (list pkg-config
- `(,glib "bin") ;for glib-mkenums
- intltool
- gobject-introspection
- libxslt ;for man page generation
- docbook-xsl)) ;for man page generation
+ (inputs (list expat linux-pam elogind mozjs nspr))
+ (propagated-inputs (list glib)) ;required by polkit-gobject-1.pc
+ (native-inputs (list pkg-config
+ `(,glib "bin") ;for glib-mkenums
+ intltool
+ gobject-introspection
+ libxslt ;for man page generation
+ docbook-xsl)) ;for man page generation
(arguments
- `(#:configure-flags '("--sysconfdir=/etc"
- "--enable-man-pages"
- ;; Prevent ‘configure: error: cannot check for
- ;; file existence when cross compiling’.
- ,@(if (%current-target-system)
- '("--with-os-type=unknown")
- '()))
- #:phases
- (modify-phases %standard-phases
- (add-after
- 'unpack 'fix-introspection-install-dir
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (substitute* (find-files "." "Makefile.in")
- (("@INTROSPECTION_GIRDIR@")
- (string-append out "/share/gir-1.0/"))
- (("@INTROSPECTION_TYPELIBDIR@")
- (string-append out "/lib/girepository-1.0/"))))))
- (add-after 'unpack 'fix-manpage-generation
- (lambda* (#:key inputs #:allow-other-keys)
- (let ((xsldoc (string-append (assoc-ref inputs "docbook-xsl")
- "/xml/xsl/docbook-xsl-"
- ,(package-version docbook-xsl))))
- (substitute* '("docs/man/Makefile.am" "docs/man/Makefile.in")
- (("http://docbook.sourceforge.net/release/xsl/current")
- xsldoc)))))
- (replace
- 'install
- (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
- ;; Override sysconfdir during "make install", to avoid attempting
- ;; to install in /etc, and to instead install the skeletons in the
- ;; output directory.
- (let ((out (assoc-ref outputs "out")))
- (apply invoke "make" "install"
- (string-append "sysconfdir=" out "/etc")
- (string-append "polkit_actiondir="
- out "/share/polkit-1/actions")
- make-flags)))))))
+ (list #:configure-flags `(list "--sysconfdir=/etc" "--enable-man-pages"
+ ;; Prevent ‘configure: error: cannot check for
+ ;; file existence when cross compiling’.
+ ,@(if (%current-target-system)
+ '("--with-os-type=unknown")
+ '()))
+ #:phases #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-introspection-install-dir
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (substitute* (find-files "." "Makefile.in")
+ (("@INTROSPECTION_GIRDIR@")
+ (string-append out "/share/gir-1.0/"))
+ (("@INTROSPECTION_TYPELIBDIR@")
+ (string-append out "/lib/girepository-1.0/"))))))
+ (add-after 'unpack 'fix-manpage-generation
+ (lambda* (#:key native-inputs #:allow-other-keys)
+ (let ((xsldoc (string-append (assoc-ref
+ native-inputs
+ "docbook-xsl")
+ "/xml/xsl/docbook-xsl-"
+ #$(package-version docbook-xsl))))
+ (substitute* '("docs/man/Makefile.am"
+ "docs/man/Makefile.in")
+ (("http://docbook.sourceforge.net/release/xsl/current")
+ xsldoc)))))
+ (replace 'install
+ (lambda* (#:key outputs
+ (make-flags '()) #:allow-other-keys)
+ ;; Override sysconfdir during "make install", to avoid attempting
+ ;; to install in /etc, and to instead install the skeletons in the
+ ;; output directory.
+ (let ((out (assoc-ref outputs "out")))
+ (apply invoke
+ "make"
+ "install"
+ (string-append "sysconfdir=" out "/etc")
+ (string-append "polkit_actiondir=" out
+ "/share/polkit-1/actions")
+ make-flags)))))))
(home-page "https://www.freedesktop.org/wiki/Software/polkit/")
(synopsis "Authorization API for privilege management")
- (description "Polkit is an application-level toolkit for defining and
+ (description
+ "Polkit is an application-level toolkit for defining and
handling the policy that allows unprivileged processes to speak to
privileged processes. It is a framework for centralizing the decision
making process with respect to granting access to privileged operations
--
2.37.1
M
M
Mathieu Othacehe wrote on 12 Aug 2022 01:29
(name . Andrew Patterson)(address . andrewpatt7@gmail.com)(address . 57146@debbugs.gnu.org)
87bksp27bl.fsf@gnu.org
Hello Andrew,

Toggle quote (3 lines)
> The polkit package used to refer to docbook-xsl via inputs rather native inputs,
> which obviously doesn't work when cross-compiling.

Thanks for working on that. It looks like this patch is breaking host
compilation:

Toggle snippet (9 lines)
error: in phase 'fix-manpage-generation': uncaught exception:
wrong-type-arg "string-append" "Wrong type (expecting ~A): ~S" ("string" #f) (#f)
phase `fix-manpage-generation' failed after 0.0 seconds
Backtrace:
9 (primitive-load "/gnu/store/k2p4qxc23g871rm5q50bcx45f3m…")
In guix/build/gnu-build-system.scm:
906:2 8 (gnu-build #:source _ #:outputs _ #:inputs _ #:phases . #)

Also you are doing a lot of things at the same time: fixing indentation,
introducing gexps, fixing cross-compilation. It would be great if you
could do that in separate patches to ease the review process.

Thanks,

Mathieu
J
J
Jean Pierre De Jesus DIAZ wrote on 12 Aug 2022 02:42
[PATCH] gnu: polkit: Fix cross-compiling
(name . 57146@debbugs.gnu.org)(address . 57146@debbugs.gnu.org)
Jciv8CxPRUw6Hg8JP8fTEowlrEHSia_IaCcSdVfEZT2keFJzas0AClA82LOFVYM8OmqeC3ZEBATSBS7nDhWJwfQa2QT-PM73hXUu6koBNWY=@jeandudey.tech
This issue is already solved:


Toggle quote (2 lines)
>Pushed to 'staging' in 7767d30f55, thanks!

Was fixed for both polkit-mozjs and polkit-duktape.

Jean-Pierre De Jesus DIAZ
J
J
Jean Pierre De Jesus DIAZ wrote on 12 Aug 2022 02:57
(name . 57146@debbugs.gnu.org)(address . 57146@debbugs.gnu.org)
QrB-kHrnJ8J1-bUGgL1tz97hf2mTdrGe2_92pdo4K41yV0OYfCNDih6DhapeED2snu9OlTChA_mUa-SC3V80B_YyTDmrSU1gETFyE6SE_kI=@jeandudey.tech
However, the patch to introduce G-Expressions is welcome as I did
only fix the inputs/native-inputs usage.

Toggle quote (2 lines)
>+ (let ((out (assoc-ref outputs "out")))

Can be removed probably, and replace `out' here:

Toggle quote (4 lines)
>+ (string-append "sysconfdir=" out "/etc")
>+ (string-append "polkit_actiondir=" out
>+ "/share/polkit-1/actions")

By #$output. But, rethinking it again, I would investigate if this phase
can be removed and instead use `#:make-flags' if possible directly as
make-flags can be specified as a G-Expression.

Toggle quote (8 lines)
>+ (lambda* (#:key outputs #:allow-other-keys)
>+ (let ((out (assoc-ref outputs "out")))
>+ (substitute* (find-files "." "Makefile.in")
>+ (("@INTROSPECTION_GIRDIR@")
>+ (string-append out "/share/gir-1.0/"))
>+ (("@INTROSPECTION_TYPELIBDIR@")
>+ (string-append out "/lib/girepository-1.0/"))))))

Same here. And then:

Toggle quote (2 lines)
>+ (lambda* (#:key outputs #:allow-other-keys)

Is just then:

Toggle snippet (4 lines)
(lambda _
...)

Toggle quote (7 lines)
>+ (list #:configure-flags `(list "--sysconfdir=/etc" "--enable-man-pages"
>+ ;; Prevent ‘configure: error: cannot check for
>+ ;; file existence when cross compiling’.
>+ ,@(if (%current-target-system)
>+ '("--with-os-type=unknown")
>+ '()))

G-Expressions can be used here too, e.g:

Toggle snippet (9 lines)
(list #:configure-flags #~(list "--sysconfdir=/etc"
"--enable-man-pages"
;; Prevent ‘configure: error: cannot check for
;; file existence when cross compiling’.
#$@(if (%current-target-system)
'("--with-os-type=unknown")
'()))

Jean-Pierre De Jesus DIAZ


------- Original Message -------
On Friday, August 12th, 2022 at 11:42 AM, Jean Pierre De Jesus DIAZ <me@jeandudey.tech> wrote:


Toggle quote (11 lines)
> This issue is already solved:
>
> https://issues.guix.gnu.org/56252
>
> > Pushed to 'staging' in 7767d30f55, thanks!
>
>
> Was fixed for both polkit-mozjs and polkit-duktape.
>
> —
> Jean-Pierre De Jesus DIAZ
A
A
Andrew Patterson wrote on 12 Aug 2022 14:24
Re: bug#57146: [PATCH] gnu: polkit: Fix cross-compiling
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 57146@debbugs.gnu.org)
87ilmxnoea.fsf@gmail.com
Toggle quote (14 lines)
> Thanks for working on that. It looks like this patch is breaking
> host
> compilation:
>
> error: in phase 'fix-manpage-generation': uncaught exception:
> wrong-type-arg "string-append" "Wrong type (expecting ~A): ~S"
> ("string" #f) (#f)
> phase `fix-manpage-generation' failed after 0.0 seconds
> Backtrace:
> 9 (primitive-load
> "/gnu/store/k2p4qxc23g871rm5q50bcx45f3m…")
> In guix/build/gnu-build-system.scm:
> 906:2 8 (gnu-build #:source _ #:outputs _ #:inputs _
> #:phases . #)
Huh. Looking at Jean Pierre's patch, apparently native-inputs
only exists when cross-compiling, good to know.

Toggle quote (5 lines)
> Also you are doing a lot of things at the same time: fixing
> indentation,
> introducing gexps, fixing cross-compilation. It would be great
> if you
> could do that in separate patches to ease the review process.
I'll make sure to keep that in mind in the future, sorry.

--
Andrew Patterson
A
A
Andrew Patterson wrote on 12 Aug 2022 14:27
Re: [PATCH] gnu: polkit: Fix cross-compiling
(name . Jean Pierre De Jesus DIAZ)(address . me@jeandudey.tech)
87edxlnnnf.fsf@gmail.com
Thanks for the suggestions! I'll try and work on this some.

Should I continue sending patches in this thread, or start a new
one?

--
Andrew Patterson
J
J
Jean Pierre De Jesus DIAZ wrote on 12 Aug 2022 15:48
(address . andrewpatt7@gmail.com)
VPn2rvq7-ay2QO6BePB26pEDXlBkG36fGLB-7BxpEdfNDCHywO3WpD9ZtLXQRfVVjpXZCv0Efvo9_ege4AHzI8FZn5e_i0nK9p-eEerXw8k=@jeandudey.tech
On this same thread by replying to 57146@debbugs.gnu.org
-------- Original Message --------
On Aug 12, 2022, 23:27, Andrew Patterson wrote:

Toggle quote (1 lines)
> Thanks for the suggestions! I'll try and work on this some. Should I continue sending patches in this thread, or start a new one? -- Andrew Patterson
Attachment: file
J
J
Jean Pierre De Jesus DIAZ wrote on 14 Aug 2022 03:06
(address . andrewpatt7@gmail.com)
uD-ig9Z5v72u2qLITGyuKUQFsluXPJd2DQgTNzcruc5zuCq2KyouC7JowaLIpSu5cO3e60CEivLca5SRy4okVmqwygJY8GwRkVUzIpw2aMc=@jeandudey.tech
Don't know what happened that made my mail send an empty message :).

Yes you can send the updated patch to this same thread at:

57146@debbugs.gnu.org

Jean-Pierre De Jesus DIAZ



------- Original Message -------
On Saturday, August 13th, 2022 at 12:48 AM, Jean Pierre De Jesus DIAZ <me@jeandudey.tech> wrote:


Toggle quote (6 lines)
> On this same thread by replying to 57146@debbugs.gnu.org
> -------- Original Message --------
> On Aug 12, 2022, 23:27, Andrew Patterson < andrewpatt7@gmail.com> wrote:
>
> >
> > Thanks for the suggestions! I'll try and work on this some. Should I continue sending patches in this thread, or start a new one? -- Andrew Patterson
M
M
Maxim Cournoyer wrote on 3 Jan 2023 14:23
Re: bug#57146: [PATCH] gnu: polkit: Fix cross-compiling
(name . Andrew Patterson)(address . andrewpatt7@gmail.com)
874jt7z28d.fsf_-_@gmail.com
Hi Andrew,

Andrew Patterson <andrewpatt7@gmail.com> writes:

Toggle quote (4 lines)
> Thanks for the suggestions! I'll try and work on this some.
>
> Should I continue sending patches in this thread, or start a new one?

Is there still something that needs fixing here, or can we close this?

--
Thanks,
Maxim
M
M
Maxim Cournoyer wrote on 3 Jan 2023 14:23
control message for bug #57146
(address . control@debbugs.gnu.org)
87358rz288.fsf@gmail.com
tags 57146 + moreinfo
quit
A
A
Andrew Patterson wrote on 3 Jan 2023 20:19
Re: bug#57146: [PATCH] gnu: polkit: Fix cross-compiling
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
871qoakjne.fsf@gmail.com
I haven't needed to cross-compile any guix images recently, but
`guix build --target=aarch64-linux-gnu polkit-duktape` on an
x86_64 machine just completed successfully, so I don't think
there's any issue still here?

--
Andrew Patterson
M
M
Maxim Cournoyer wrote on 3 Jan 2023 21:16
(name . Andrew Patterson)(address . andrewpatt7@gmail.com)
87edsax4kg.fsf@gmail.com
Hi,

Andrew Patterson <andrewpatt7@gmail.com> writes:

Toggle quote (5 lines)
> I haven't needed to cross-compile any guix images recently, but `guix
> build --target=aarch64-linux-gnu polkit-duktape` on an x86_64 machine
> just completed successfully, so I don't think there's any issue still
> here?

Thanks for checking. I'll close the issue. It can be reopen if
somethig w.r.t. cross-compilation and polkit is amiss.

--
Thanks,
Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 57146@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 57146
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch