diff options
author | Ludovic Courtès <ludo@gnu.org> | 2024-01-07 21:17:02 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2024-01-07 21:29:53 +0100 |
commit | b71d2ba8785e9883f4f2d239c557c9034b6be876 (patch) | |
tree | 52858686958c4c66c6c1f7a98ae63c3269eacb15 /gnu/build | |
parent | c5d670308cbd0a6ee67e04e58cb77fa40e8ad328 (diff) | |
parent | 5f8a993aa85554ca09bd27139230d7664107e1b6 (diff) |
Merge branch 'master' into core-updates
Change-Id: I150b4077fffca97c860439292a8d053579d64cb7
Diffstat (limited to 'gnu/build')
-rw-r--r-- | gnu/build/chromium-extension.scm | 43 | ||||
-rw-r--r-- | gnu/build/cross-toolchain.scm | 41 | ||||
-rw-r--r-- | gnu/build/icecat-extension.scm | 1 | ||||
-rw-r--r-- | gnu/build/shepherd.scm | 90 |
4 files changed, 61 insertions, 114 deletions
diff --git a/gnu/build/chromium-extension.scm b/gnu/build/chromium-extension.scm index 28449a1e1d..8171c72734 100644 --- a/gnu/build/chromium-extension.scm +++ b/gnu/build/chromium-extension.scm @@ -120,12 +120,7 @@ format." when installed, will make the extension contained in PKG available as a Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use." (let* ((name (package-name pkg)) - (version (package-version pkg)) - (private-key (make-signing-key name)) - (public-key (signing-key->public-der private-key)) - (checksum (file-sha256sum public-key)) - (crx (make-crx private-key pkg pkg-output)) - (json (crx->chromium-json crx version))) + (version (package-version pkg))) (package (inherit pkg) (name (string-append name "-chromium")) @@ -138,18 +133,24 @@ Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use." (arguments (list #:modules '((guix build utils)) #:builder - #~(begin - (use-modules (guix build utils)) - (define (base16-char->chromium-base16 char) - ;; Translate CHAR, a hexadecimal character, to a Chromium-style - ;; representation using the letters a-p (where a=0, p=15). - (string-ref "abcdefghijklmnop" - (string-index "0123456789abcdef" char))) - (let ((file-name (string-map base16-char->chromium-base16 - (string-take #$checksum 32))) - (extension-directory - (string-append #$output - "/share/chromium/extensions"))) - (mkdir-p extension-directory) - (symlink #$json (string-append extension-directory "/" - file-name ".json"))))))))) + (let* + ((private-key (make-signing-key name)) + (public-key (signing-key->public-der private-key)) + (checksum (file-sha256sum public-key)) + (crx (make-crx private-key pkg pkg-output)) + (json (crx->chromium-json crx version))) + #~(begin + (use-modules (guix build utils)) + (define (base16-char->chromium-base16 char) + ;; Translate CHAR, a hexadecimal character, to a Chromium-style + ;; representation using the letters a-p (where a=0, p=15). + (string-ref "abcdefghijklmnop" + (string-index "0123456789abcdef" char))) + (let ((file-name (string-map base16-char->chromium-base16 + (string-take #$checksum 32))) + (extension-directory + (string-append #$output + "/share/chromium/extensions"))) + (mkdir-p extension-directory) + (symlink #$json (string-append extension-directory "/" + file-name ".json")))))))))) diff --git a/gnu/build/cross-toolchain.scm b/gnu/build/cross-toolchain.scm index 9746be3e50..da9016488f 100644 --- a/gnu/build/cross-toolchain.scm +++ b/gnu/build/cross-toolchain.scm @@ -48,6 +48,12 @@ ;; Search path for target headers when cross-compiling. (map (cut string-append "CROSS_" <>) %gcc-include-paths)) +(define* (patch-genmultilib-shebang #:key inputs native-inputs #:allow-other-keys) + "Patch-shebang in the gcc/genmultilib file doesn't work as it contains several +scripts inside, each with a #!/bin/sh that needs patching." + (substitute* "gcc/genmultilib" + (("#!/bin/sh") (string-append "#!" (which "sh"))))) + (define* (make-cross-binutils-visible #:key outputs inputs target #:allow-other-keys) "Create symlinks for 'as', 'nm', and 'ld' in the \"out\" output, under @@ -162,6 +168,31 @@ C_*INCLUDE_PATH." (cons "LIBRARY_PATH" %gcc-include-paths)) #t)) +(define* (set-cross-path/avr #:key inputs #:allow-other-keys) + (match (assoc-ref inputs "libc") + ((? string? libc) + (define (cross? x) + ;; Return #t if X is a cross-libc. + (string-prefix? libc x)) + + (let ((cpath (string-append libc "/avr/include"))) + (for-each (cut setenv <> cpath) + %gcc-cross-include-paths)) + + (setenv "CROSS_LIBRARY_PATH" + (string-append libc "/avr/lib")) + + (for-each (lambda (var) + (and=> (getenv var) + (lambda (value) + (let* ((path (search-path-as-string->list value)) + (native-path (list->search-path-as-string + (remove cross? path) ":"))) + (setenv var native-path))))) + (cons "LIBRARY_PATH" %gcc-include-paths))) + ;; AVR sans-libc cross-compiler. + (else #t))) + (define (install-strip . _) "Install a stripped GCC." ;; Unlike our 'strip' phase, this will do the right thing for @@ -173,14 +204,18 @@ C_*INCLUDE_PATH." "Modify PHASES to include everything needed to build a cross-GCC for TARGET, a target triplet." (modify-phases phases + (add-after 'unpack 'patch-genmultilib-shebang + patch-genmultilib-shebang) (add-before 'configure 'set-cross-path ;; This mingw32 target checking logic should match that of target-mingw? ;; in (guix utils), but (guix utils) is too large too copy over to the ;; build side entirely and for now we have no way to select variables to ;; copy over. See (gnu packages cross-base) for more details. - (if (string-suffix? "-mingw32" target) - (cut set-cross-path/mingw #:target target <...>) - set-cross-path)) + (cond + ((string-suffix? "-mingw32" target) + (cut set-cross-path/mingw #:target target <...>)) + ((string-prefix? "avr" target) set-cross-path/avr) + (#t set-cross-path))) (add-after 'install 'make-cross-binutils-visible (cut make-cross-binutils-visible #:target target <...>)) (replace 'install install-strip))) diff --git a/gnu/build/icecat-extension.scm b/gnu/build/icecat-extension.scm index 1e6a9a54e4..e6927c79df 100644 --- a/gnu/build/icecat-extension.scm +++ b/gnu/build/icecat-extension.scm @@ -29,6 +29,7 @@ when installed, will make the extension contained in PKG available as an Icecat browser extension. PKG-OUTPUT specifies which output of PKG to use." (package (inherit pkg) + (location (package-location pkg)) (name (string-append (package-name pkg) "-icecat")) (native-inputs '()) (inputs '()) diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm index 9d9bfcfbc0..4ead27be0b 100644 --- a/gnu/build/shepherd.scm +++ b/gnu/build/shepherd.scm @@ -33,7 +33,6 @@ %precious-signals) #:autoload (shepherd system) (unblock-signals) #:export (default-mounts - make-forkexec-constructor/container fork+exec-command/container)) ;;; Commentary: @@ -101,27 +100,6 @@ (file-exists? (file-system-mapping-source mapping))) mappings))))) -(define* (read-pid-file/container pid pid-file #:key (max-delay 5)) - "Read PID-FILE in the container namespaces of PID, which exists in a -separate mount and PID name space. Return the \"outer\" PID. " - (match (container-excursion* pid - (lambda () - ;; XXX: Trick for Shepherd 0.9: prevent 'read-pid-file' from - ;; using (@ (fibers) sleep), which would try to suspend the - ;; current task, which doesn't work in this extra process. - (with-continuation-barrier - (lambda () - (read-pid-file pid-file - #:max-delay max-delay))))) - (#f - ;; Send SIGTERM to the whole process group. - (catch-system-error (kill (- pid) SIGTERM)) - #f) - ((? integer? container-pid) - ;; XXX: When COMMAND is started in a separate PID namespace, its - ;; PID is always 1, but that's not what Shepherd needs to know. - pid))) - (define* (exec-command* command #:key user group log-file pid-file (supplementary-groups '()) (directory "/") (environment-variables (environ))) @@ -144,74 +122,6 @@ shepherd (PID 1)." #:directory directory #:environment-variables environment-variables)) -(define* (make-forkexec-constructor/container command - #:key - (namespaces - (default-namespaces args)) - (mappings '()) - (user #f) - (group #f) - (supplementary-groups '()) - (log-file #f) - pid-file - (pid-file-timeout 5) - (directory "/") - (environment-variables - (environ)) - #:rest args) - "This is a variant of 'make-forkexec-constructor' that starts COMMAND in -NAMESPACES, a list of Linux namespaces such as '(mnt ipc). MAPPINGS is the -list of <file-system-mapping> to make in the case of a separate mount -namespace, in addition to essential bind-mounts such /proc." - (define container-directory - (match command - ((program _ ...) - (string-append "/var/run/containers/" (basename program))))) - - (define auto-mappings - `(,@(if log-file - (list (file-system-mapping - (source log-file) - (target source) - (writable? #t))) - '()))) - - (define mounts - (append (map file-system-mapping->bind-mount - (append auto-mappings mappings)) - (default-mounts #:namespaces namespaces))) - - (lambda args - (mkdir-p container-directory) - - (when log-file - ;; Create LOG-FILE so we can map it in the container. - (unless (file-exists? log-file) - (close (open log-file (logior O_CREAT O_APPEND O_CLOEXEC) #o640)) - (when user - (let ((pw (getpwnam user))) - (chown log-file (passwd:uid pw) (passwd:gid pw)))))) - - (let ((pid (run-container container-directory - mounts namespaces 1 - (lambda () - (exec-command* command - #:user user - #:group group - #:supplementary-groups - supplementary-groups - #:pid-file pid-file - #:log-file log-file - #:directory directory - #:environment-variables - environment-variables))))) - (if pid-file - (if (or (memq 'mnt namespaces) (memq 'pid namespaces)) - (read-pid-file/container pid pid-file - #:max-delay pid-file-timeout) - (read-pid-file pid-file #:max-delay pid-file-timeout)) - pid)))) - (define* (fork+exec-command/container command #:key pid #:allow-other-keys |