summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Leidi <goodoldpaul@autistici.org>2023-09-21 02:19:27 +0200
committerJonathan Brielmaier <jonathan.brielmaier@web.de>2023-12-28 23:41:04 +0100
commit00e0b5f319d660298f9650f8e225e755fdf79e6d (patch)
tree1a4da1f3ced4d60e0312cbb28672a483acb2448a
parent768f182776e9fb3e839883cf219bf4da6899de26 (diff)
nonguix: binary: Automatically detect and unpack .deb files.
A new binary-unpack phase is added to the binary-build-system. When a supported binary file is detected as the only file after the unpack phase it is then decompressed in a specific directory. * nonguix/build/binary-build-system.scm (deb-file?): new variable; (unpack-deb): new variable; (binary-unpack): new variable; (%standard-phases): use the new phase. Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
-rw-r--r--nonguix/build/binary-build-system.scm29
1 files changed, 27 insertions, 2 deletions
diff --git a/nonguix/build/binary-build-system.scm b/nonguix/build/binary-build-system.scm
index 087ef89..147aa18 100644
--- a/nonguix/build/binary-build-system.scm
+++ b/nonguix/build/binary-build-system.scm
@@ -1,6 +1,7 @@
1;;; SPDX-License-Identifier: GPL-3.0-or-later 1;;; SPDX-License-Identifier: GPL-3.0-or-later
2;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> 2;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
3;;; Copyright © 2022 Attila Lendvai <attila@lendvai.name> 3;;; Copyright © 2022 Attila Lendvai <attila@lendvai.name>
4;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
4 5
5(define-module (nonguix build binary-build-system) 6(define-module (nonguix build binary-build-system)
6 #:use-module ((guix build gnu-build-system) #:prefix gnu:) 7 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
@@ -133,10 +134,34 @@ The inputs are optional when the file is an executable."
133 patchelf-plan))) 134 patchelf-plan)))
134 #t) 135 #t)
135 136
137(define (deb-file? binary-file)
138 (string-suffix? ".deb" binary-file))
139
140(define (unpack-deb deb-file)
141 (invoke "ar" "x" deb-file)
142 (invoke "tar" "xvf" "data.tar.xz")
143 (invoke "rm" "-rfv" "control.tar.gz"
144 "data.tar.xz"
145 deb-file
146 "debian-binary"))
147
148(define* (binary-unpack #:key source #:allow-other-keys)
149 (let* ((files (filter (lambda (f)
150 (not (string=? (basename f) "environment-variables")))
151 (find-files (getcwd))))
152 (binary-file (car files)))
153 (when (= 1 (length files))
154 (mkdir "binary")
155 (chdir "binary")
156 (match binary-file
157 ((? deb-file?) (unpack-deb binary-file))
158 (_ (format #t "Unknown file type: ~a~%" (basename binary-file)))))))
159
136(define %standard-phases 160(define %standard-phases
137 ;; Everything is as with the GNU Build System except for the `configure' 161 ;; Everything is as with the GNU Build System except for the `binary-unpack',
138 ;; , `build', `check' and `install' phases. 162 ;; `configure', `build', `check' and `install' phases.
139 (modify-phases gnu:%standard-phases 163 (modify-phases gnu:%standard-phases
164 (add-after 'unpack 'binary-unpack binary-unpack)
140 (delete 'bootstrap) 165 (delete 'bootstrap)
141 (delete 'configure) 166 (delete 'configure)
142 (delete 'build) 167 (delete 'build)