mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2025-02-18 02:23:12 +01:00
nonguix: Add chromium-binary-build-system.
This build system is an extension to the binary-build-system, designed to abstract some common boilerplate necessary for packaging Chromium based software. * nonguix/build-system/chromium-binary.scm: New file; * nonguix/build/chromium-binary-build-system.scm: new file; * nonguix/build/utils.scm (build-paths-for-input): new variable; (build-paths-from-inputs): New variable. Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
parent
5622013d28
commit
f2970727de
3 changed files with 309 additions and 1 deletions
210
nonguix/build-system/chromium-binary.scm
Normal file
210
nonguix/build-system/chromium-binary.scm
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
|
||||||
|
|
||||||
|
(define-module (nonguix build-system chromium-binary)
|
||||||
|
#:use-module (gnu packages bash)
|
||||||
|
#:use-module (gnu packages compression)
|
||||||
|
#:use-module (gnu packages cups)
|
||||||
|
#:use-module (gnu packages databases)
|
||||||
|
#:use-module (gnu packages fontutils)
|
||||||
|
#:use-module (gnu packages gcc)
|
||||||
|
#:use-module (gnu packages gl)
|
||||||
|
#:use-module (gnu packages glib)
|
||||||
|
#:use-module (gnu packages gnome)
|
||||||
|
#:use-module (gnu packages gtk)
|
||||||
|
#:use-module (gnu packages kerberos)
|
||||||
|
#:use-module (gnu packages linux)
|
||||||
|
#:use-module (gnu packages nss)
|
||||||
|
#:use-module (gnu packages pulseaudio)
|
||||||
|
#:use-module (gnu packages xdisorg)
|
||||||
|
#:use-module (gnu packages xorg)
|
||||||
|
#:use-module (gnu packages xml)
|
||||||
|
#:use-module (guix store)
|
||||||
|
#:use-module (guix utils)
|
||||||
|
#:use-module (guix gexp)
|
||||||
|
#:use-module (guix monads)
|
||||||
|
#:use-module (guix derivations)
|
||||||
|
#:use-module (guix search-paths)
|
||||||
|
#:use-module (guix build-system)
|
||||||
|
#:use-module (guix build-system gnu)
|
||||||
|
#:use-module (guix packages)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (nonguix build-system binary)
|
||||||
|
#:use-module (nonguix utils)
|
||||||
|
#:export (%chromium-binary-build-system-modules
|
||||||
|
lower
|
||||||
|
chromium-binary-build
|
||||||
|
chromium-binary-build-system))
|
||||||
|
|
||||||
|
;; Commentary:
|
||||||
|
;;
|
||||||
|
;; Standard build procedure for Chromium based binary packages. This is
|
||||||
|
;; implemented as an extension of `binary-build-system'.
|
||||||
|
;;
|
||||||
|
;; Code:
|
||||||
|
|
||||||
|
(define %chromium-binary-build-system-modules
|
||||||
|
;; Build-side modules imported by default.
|
||||||
|
`((nonguix build chromium-binary-build-system)
|
||||||
|
(nonguix build utils)
|
||||||
|
,@%binary-build-system-modules))
|
||||||
|
|
||||||
|
(define (build-patchelf-plan wrapper-plan inputs)
|
||||||
|
#~(let ((patchelf-inputs
|
||||||
|
(list #$@(map car inputs))))
|
||||||
|
(map (lambda (file)
|
||||||
|
(cons file (list patchelf-inputs)))
|
||||||
|
#$wrapper-plan)))
|
||||||
|
|
||||||
|
(define* (lower name
|
||||||
|
#:key source inputs native-inputs outputs system target
|
||||||
|
(patchelf (default-patchelf))
|
||||||
|
(glibc (default-glibc))
|
||||||
|
#:allow-other-keys
|
||||||
|
#:rest arguments)
|
||||||
|
"Return a bag for NAME."
|
||||||
|
(define private-keywords
|
||||||
|
'(#:target #:patchelf #:inputs #:native-inputs))
|
||||||
|
(define host-inputs
|
||||||
|
`(,@(if source
|
||||||
|
`(("source" ,source))
|
||||||
|
'())
|
||||||
|
|
||||||
|
("alsa-lib" ,alsa-lib)
|
||||||
|
("atk" ,atk)
|
||||||
|
("at-spi2-atk" ,at-spi2-atk)
|
||||||
|
("at-spi2-core" ,at-spi2-core)
|
||||||
|
("bash-minimal" ,bash-minimal)
|
||||||
|
("cairo" ,cairo)
|
||||||
|
("cups" ,cups)
|
||||||
|
("dbus" ,dbus)
|
||||||
|
("eudev" ,eudev)
|
||||||
|
("expat" ,expat)
|
||||||
|
("fontconfig" ,fontconfig)
|
||||||
|
("freetype" ,freetype)
|
||||||
|
("gcc:lib" ,(make-libstdc++ gcc))
|
||||||
|
("glib" ,glib)
|
||||||
|
("gtk+" ,gtk+)
|
||||||
|
("libdrm" ,libdrm)
|
||||||
|
("libgccjit" ,libgccjit)
|
||||||
|
("libnotify" ,libnotify)
|
||||||
|
("librsvg" ,librsvg)
|
||||||
|
("libsecret" ,libsecret)
|
||||||
|
("libx11" ,libx11)
|
||||||
|
("libxcb" ,libxcb)
|
||||||
|
("libxcomposite" ,libxcomposite)
|
||||||
|
("libxcursor" ,libxcursor)
|
||||||
|
("libxdamage" ,libxdamage)
|
||||||
|
("libxext" ,libxext)
|
||||||
|
("libxfixes" ,libxfixes)
|
||||||
|
("libxi" ,libxi)
|
||||||
|
("libxkbcommon" ,libxkbcommon)
|
||||||
|
("libxkbfile" ,libxkbfile)
|
||||||
|
("libxrandr" ,libxrandr)
|
||||||
|
("libxrender" ,libxrender)
|
||||||
|
("libxshmfence" ,libxshmfence)
|
||||||
|
("libxtst" ,libxtst)
|
||||||
|
("mesa" ,mesa)
|
||||||
|
("mit-krb5" ,mit-krb5)
|
||||||
|
("nspr" ,nspr)
|
||||||
|
("nss" ,nss)
|
||||||
|
("pango" ,pango)
|
||||||
|
("pulseaudio" ,pulseaudio)
|
||||||
|
("sqlcipher" ,sqlcipher)
|
||||||
|
("xcb-util" ,xcb-util)
|
||||||
|
("xcb-util-image" ,xcb-util-image)
|
||||||
|
("xcb-util-keysyms" ,xcb-util-keysyms)
|
||||||
|
("xcb-util-renderutil" ,xcb-util-renderutil)
|
||||||
|
("xcb-util-wm" ,xcb-util-wm)
|
||||||
|
("zlib" ,zlib)
|
||||||
|
|
||||||
|
,@inputs
|
||||||
|
;; Keep the standard inputs of 'gnu-build-system'.
|
||||||
|
,@(standard-packages)))
|
||||||
|
|
||||||
|
(and (not target) ;XXX: no cross-compilation
|
||||||
|
(bag
|
||||||
|
(name name)
|
||||||
|
(system system)
|
||||||
|
(host-inputs host-inputs)
|
||||||
|
(build-inputs `(("patchelf" ,patchelf)
|
||||||
|
,@native-inputs
|
||||||
|
;; If current system is i686, the *32 packages will be the
|
||||||
|
;; same as the non-32, but that's OK.
|
||||||
|
("libc32" ,(to32 glibc))))
|
||||||
|
(outputs outputs)
|
||||||
|
(build chromium-binary-build)
|
||||||
|
(arguments (append
|
||||||
|
(strip-keyword-arguments private-keywords arguments)
|
||||||
|
(list #:wrap-inputs host-inputs))))))
|
||||||
|
|
||||||
|
(define* (chromium-binary-build name inputs
|
||||||
|
#:key
|
||||||
|
guile source wrap-inputs
|
||||||
|
(outputs '("out"))
|
||||||
|
(wrapper-plan ''())
|
||||||
|
(patchelf-plan ''())
|
||||||
|
(install-plan ''(("." "./")))
|
||||||
|
(search-paths '())
|
||||||
|
(out-of-source? #t)
|
||||||
|
(validate-runpath? #t)
|
||||||
|
(patch-shebangs? #t)
|
||||||
|
(strip-binaries? #t)
|
||||||
|
(strip-flags ''("--strip-debug"))
|
||||||
|
(strip-directories ''("lib" "lib64" "libexec"
|
||||||
|
"bin" "sbin"))
|
||||||
|
(phases '(@ (nonguix build chromium-binary-build-system)
|
||||||
|
%standard-phases))
|
||||||
|
(system (%current-system))
|
||||||
|
(imported-modules %chromium-binary-build-system-modules)
|
||||||
|
(modules '((nonguix build chromium-binary-build-system)
|
||||||
|
(guix build utils)
|
||||||
|
(nonguix build utils)))
|
||||||
|
(substitutable? #t)
|
||||||
|
allowed-references
|
||||||
|
disallowed-references)
|
||||||
|
"Build SOURCE using binary-build-system."
|
||||||
|
(define builder
|
||||||
|
(with-imported-modules imported-modules
|
||||||
|
#~(begin
|
||||||
|
(use-modules #$@modules)
|
||||||
|
|
||||||
|
#$(with-build-variables inputs outputs
|
||||||
|
#~(chromium-binary-build #:source #+source
|
||||||
|
#:system #$system
|
||||||
|
#:outputs %outputs
|
||||||
|
#:inputs %build-inputs
|
||||||
|
#:patchelf-plan
|
||||||
|
#$(if (equal? wrapper-plan ''())
|
||||||
|
patchelf-plan
|
||||||
|
(build-patchelf-plan wrapper-plan
|
||||||
|
wrap-inputs))
|
||||||
|
#:install-plan #$install-plan
|
||||||
|
#:search-paths '#$(map search-path-specification->sexp
|
||||||
|
search-paths)
|
||||||
|
#:phases #$phases
|
||||||
|
#:out-of-source? #$out-of-source?
|
||||||
|
#:validate-runpath? #$validate-runpath?
|
||||||
|
#:patch-shebangs? #$patch-shebangs?
|
||||||
|
#:strip-binaries? #$strip-binaries?
|
||||||
|
#:strip-flags #$strip-flags
|
||||||
|
#:strip-directories #$strip-directories)))))
|
||||||
|
|
||||||
|
(mlet %store-monad ((guile (package->derivation (or guile (default-guile))
|
||||||
|
system #:graft? #f)))
|
||||||
|
(gexp->derivation name builder
|
||||||
|
#:system system
|
||||||
|
#:target #f
|
||||||
|
#:substitutable? substitutable?
|
||||||
|
#:allowed-references allowed-references
|
||||||
|
#:disallowed-references disallowed-references
|
||||||
|
#:guile-for-build guile)))
|
||||||
|
|
||||||
|
(define chromium-binary-build-system
|
||||||
|
(build-system
|
||||||
|
(name 'chromium-binary)
|
||||||
|
(description "The Chromium based binary build system")
|
||||||
|
(lower lower)))
|
||||||
|
|
||||||
|
;;; chromium-binary.scm ends here
|
75
nonguix/build/chromium-binary-build-system.scm
Normal file
75
nonguix/build/chromium-binary-build-system.scm
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
|
||||||
|
|
||||||
|
(define-module (nonguix build chromium-binary-build-system)
|
||||||
|
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
|
||||||
|
#:use-module ((nonguix build binary-build-system) #:prefix binary:)
|
||||||
|
#:use-module (nonguix build utils)
|
||||||
|
#:use-module (guix build utils)
|
||||||
|
#:use-module (ice-9 ftw)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
|
#:export (%standard-phases
|
||||||
|
chromium-binary-build))
|
||||||
|
|
||||||
|
;; Commentary:
|
||||||
|
;;
|
||||||
|
;; Builder-side code of the Chromium binary build procedure.
|
||||||
|
;;
|
||||||
|
;; Code:
|
||||||
|
|
||||||
|
(define* (install-wrapper #:key inputs outputs #:allow-other-keys)
|
||||||
|
(let* ((output (assoc-ref outputs "out"))
|
||||||
|
(bin (string-append output "/bin"))
|
||||||
|
(fontconfig-minimal (assoc-ref inputs "fontconfig"))
|
||||||
|
(nss (assoc-ref inputs "nss"))
|
||||||
|
(wrap-inputs (map cdr inputs))
|
||||||
|
(lib-directories
|
||||||
|
(build-paths-from-inputs '("lib") wrap-inputs))
|
||||||
|
(bin-directories
|
||||||
|
(build-paths-from-inputs
|
||||||
|
'("bin" "sbin" "libexec")
|
||||||
|
wrap-inputs)))
|
||||||
|
(for-each
|
||||||
|
(lambda (exe)
|
||||||
|
(display (string-append "Wrapping " exe "\n"))
|
||||||
|
(wrap-program exe
|
||||||
|
`("FONTCONFIG_PATH" ":" prefix
|
||||||
|
(,(string-join
|
||||||
|
(list
|
||||||
|
(string-append fontconfig-minimal "/etc/fonts")
|
||||||
|
output)
|
||||||
|
":")))
|
||||||
|
`("PATH" ":" prefix
|
||||||
|
(,(string-join
|
||||||
|
(append
|
||||||
|
bin-directories
|
||||||
|
(list
|
||||||
|
bin))
|
||||||
|
":")))
|
||||||
|
`("LD_LIBRARY_PATH" ":" prefix
|
||||||
|
(,(string-join
|
||||||
|
(append
|
||||||
|
lib-directories
|
||||||
|
(list
|
||||||
|
(string-append nss "/lib/nss")
|
||||||
|
output))
|
||||||
|
":")))))
|
||||||
|
(map
|
||||||
|
(lambda (exe) (string-append bin "/" exe))
|
||||||
|
(filter
|
||||||
|
(lambda (exe) (not (string-prefix? "." exe)))
|
||||||
|
(scandir bin))))
|
||||||
|
#t))
|
||||||
|
|
||||||
|
(define %standard-phases
|
||||||
|
;; Everything is as with the binary-build-system except for the
|
||||||
|
;; `install-wrapper' phase.
|
||||||
|
(modify-phases binary:%standard-phases
|
||||||
|
(add-after 'install 'install-wrapper install-wrapper)))
|
||||||
|
|
||||||
|
(define* (chromium-binary-build #:key inputs (phases %standard-phases)
|
||||||
|
#:allow-other-keys #:rest args)
|
||||||
|
"Build the given package, applying all of PHASES in order."
|
||||||
|
(apply gnu:gnu-build #:inputs inputs #:phases phases args))
|
||||||
|
|
||||||
|
;;; chromium-binary-build-system.scm ends here
|
|
@ -1,15 +1,18 @@
|
||||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
|
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
|
||||||
;;; Copyright © 2020 Alex Griffin <a@ajgrf.com>
|
;;; Copyright © 2020 Alex Griffin <a@ajgrf.com>
|
||||||
|
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
|
||||||
|
|
||||||
(define-module (nonguix build utils)
|
(define-module (nonguix build utils)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 binary-ports)
|
#:use-module (ice-9 binary-ports)
|
||||||
#:use-module (guix build utils)
|
#:use-module (guix build utils)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:export (64-bit?
|
#:export (64-bit?
|
||||||
make-wrapper
|
make-wrapper
|
||||||
concatenate-files))
|
concatenate-files
|
||||||
|
build-paths-from-inputs))
|
||||||
|
|
||||||
(define (64-bit? file)
|
(define (64-bit? file)
|
||||||
"Return true if ELF file is in 64-bit format, false otherwise.
|
"Return true if ELF file is in 64-bit format, false otherwise.
|
||||||
|
@ -94,3 +97,23 @@ contents:
|
||||||
(call-with-output-file result
|
(call-with-output-file result
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(for-each (cut dump <> port) files))))
|
(for-each (cut dump <> port) files))))
|
||||||
|
|
||||||
|
(define build-paths-for-input
|
||||||
|
(lambda (dirs input)
|
||||||
|
(filter-map
|
||||||
|
(lambda (sub-directory)
|
||||||
|
(let ((directory
|
||||||
|
(string-append
|
||||||
|
input "/" sub-directory)))
|
||||||
|
(and
|
||||||
|
(directory-exists? directory)
|
||||||
|
directory)))
|
||||||
|
dirs)))
|
||||||
|
|
||||||
|
(define build-paths-from-inputs
|
||||||
|
(lambda (dirs inputs)
|
||||||
|
(reduce append '()
|
||||||
|
(map
|
||||||
|
(lambda (input)
|
||||||
|
(build-paths-for-input dirs input))
|
||||||
|
inputs))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue