aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 John Darrington <jmd@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages cook)
  #:use-module (guix packages)
  #:use-module (guix licenses)
  #:use-module (guix download)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages groff)
  #:use-module (gnu packages text-editors)
  #:use-module (guix build-system gnu))

(define-public cook
  (package
    (name "cook")
    (version "2.34")
    (source
     (origin
       (method url-fetch)
       (uri "http://fossies.org/linux/misc/old/cook-2.34.tar.gz")
       (sha256
        (base32
         "104saqnqql1l7zr2pm3f718fdky3ds8j07c6xvwrs1rfkhrw58yw"))))
    (build-system gnu-build-system)
    (arguments
     `(#:parallel-build? #f ; There are some nasty racy rules in the Makefile.
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'pre-conf
           (lambda _
             (substitute* (append '("common/env.c")
                                  (find-files "test" "\\.sh"))
               (("/bin/sh") (which "sh")))

             ;; Guix's binutils (because it wants bit-reproducable builds) is
             ;; is configured with the  --enable-deterministic-archives flag.
             ;; This means the timestamp of files appended to an ar archive
             ;; are automatically and silently mutated to 00:00 1 Jan 1970
             ;; which plays havoc with this test, for which correct timestamps
             ;; are very important. Adding the U flag undoes the effect of
             ;; --enable-deterministic-archives and allows this test to work
             ;; again.
             (substitute* "test/00/t0077a.sh"
               (("ar qc") "ar qcU"))

             ;; Guix builds have LC_ALL set to "en_US.utf8", which causes
             ;; `date` to use a 12-hour clock instead of 24h, which in turn
             ;; makes t0217a.sh fail because of unexpected date output.
             (substitute* "test/02/t0217a.sh"
               (("export TZ")
                "export TZ\nLC_ALL=POSIX\nexport LC_ALL"))

             (setenv "SH" (which "sh"))
             #t)))))
    (native-inputs (list bison-3.0
                         ;; For building the documentation:
                         groff
                         ;; For the tests:
                         sharutils
                         ;; One test wants rsh.  However there is no rsh server
                         ;; running in the build environment and so far as I'm
                         ;; aware, it cannot be started without root.
                         ;; This test is therefore just skipped.
                         ;; ("inetutils" ,inetutils)
                         ed))
    (home-page (string-append "https://web.archive.org/web/20140727122520/"
                              "http://miller.emu.id.au/pmiller/software/cook/"))
    (synopsis "Tool for constructing files")
    (description "Cook is a tool for constructing files.  It is given a set of
files to create, and recipes of how to create them.  In any non-trivial program
there will be prerequisites to performing the actions necessary to creating
any file, such as include files.  Cook provides a mechanism to define these.")
    (license gpl3+)))
mage (* 8 1024)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 40 1024))))) (define install-imx-u-boot #~(lambda (bootloader root-index image) (let ((spl (string-append bootloader "/libexec/SPL")) (u-boot (string-append bootloader "/libexec/u-boot.img"))) (write-file-on-device spl (stat:size (stat spl)) image (* 1 1024)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 69 1024))))) (define install-orangepi-r1-plus-lts-rk3328-u-boot #~(lambda (bootloader root-index image) (let ((idb (string-append bootloader "/libexec/idbloader.img")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device idb (stat:size (stat idb)) image (* 64 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 16384 512))))) (define install-puma-rk3399-u-boot #~(lambda (bootloader root-index image) (let ((spl (string-append bootloader "/libexec/idbloader.img")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device spl (stat:size (stat spl)) image (* 64 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 512 512))))) (define install-firefly-rk3399-u-boot #~(lambda (bootloader root-index image) (let ((idb (string-append bootloader "/libexec/idbloader.img")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device idb (stat:size (stat idb)) image (* 64 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 16384 512))))) (define install-rock64-rk3328-u-boot #~(lambda (bootloader root-index image) (let ((idb (string-append bootloader "/libexec/idbloader.img")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device idb (stat:size (stat idb)) image (* 64 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 16384 512))))) (define install-rockpro64-rk3399-u-boot #~(lambda (bootloader root-index image) (let ((idb (string-append bootloader "/libexec/idbloader.img")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device idb (stat:size (stat idb)) image (* 64 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 16384 512))))) (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot) (define install-sifive-unmatched-u-boot #~(lambda (bootloader root-index image) (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device spl (stat:size (stat spl)) image (* 34 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 2082 512))))) (define install-starfive-visionfive2-u-boot #~(lambda (bootloader root-index image) (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin.normal.out")) (u-boot (string-append bootloader "/libexec/u-boot.itb"))) (write-file-on-device spl (stat:size (stat spl)) image (* 34 512)) (write-file-on-device u-boot (stat:size (stat u-boot)) image (* 2082 512))))) (define install-starfive-visionfive2-uEnv.txt (make-u-boot-installer ;; If the board SPI uses the vendor's U-Boot, it will find starfive/ ;; starfive_visionfive2.dtb. We cannot guarantee that users will ;; update this U-Boot, so set the FDT explicitly. (plain-file "uEnv.txt" "fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb~%"))) ;;; ;;; Bootloader definitions. ;;; (define u-boot-bootloader (bootloader (inherit extlinux-bootloader) (name 'u-boot) (package #f) (installer #f) (disk-image-installer install-u-boot))) (define u-boot-beaglebone-black-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-am335x-boneblack) (disk-image-installer install-beaglebone-black-u-boot))) (define u-boot-allwinner-bootloader (bootloader (inherit u-boot-bootloader) (disk-image-installer install-allwinner-u-boot))) (define u-boot-allwinner64-bootloader (bootloader (inherit u-boot-bootloader) (disk-image-installer install-allwinner64-u-boot))) (define u-boot-imx-bootloader (bootloader (inherit u-boot-bootloader) (disk-image-installer install-imx-u-boot))) (define u-boot-nintendo-nes-classic-edition-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-nintendo-nes-classic-edition))) (define u-boot-a20-olinuxino-lime-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-a20-olinuxino-lime))) (define u-boot-a20-olinuxino-lime2-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-a20-olinuxino-lime2))) (define u-boot-a20-olinuxino-micro-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-a20-olinuxino-micro))) (define u-boot-bananapi-m2-ultra-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-bananapi-m2-ultra))) (define u-boot-cubietruck-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-cubietruck))) (define u-boot-firefly-rk3399-bootloader ;; SD and eMMC use the same format (bootloader (inherit u-boot-bootloader) (package u-boot-firefly-rk3399) (disk-image-installer install-firefly-rk3399-u-boot))) (define u-boot-mx6cuboxi-bootloader (bootloader (inherit u-boot-imx-bootloader) (package u-boot-mx6cuboxi))) (define u-boot-wandboard-bootloader (bootloader (inherit u-boot-imx-bootloader) (package u-boot-wandboard))) (define u-boot-novena-bootloader (bootloader (inherit u-boot-imx-bootloader) (package u-boot-novena))) (define u-boot-orangepi-r1-plus-lts-rk3328-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-orangepi-r1-plus-lts-rk3328) (disk-image-installer install-orangepi-r1-plus-lts-rk3328-u-boot))) (define u-boot-pine64-plus-bootloader (bootloader (inherit u-boot-allwinner64-bootloader) (package u-boot-pine64-plus))) (define u-boot-pine64-lts-bootloader (bootloader (inherit u-boot-allwinner-bootloader) (package u-boot-pine64-lts))) (define u-boot-pinebook-bootloader (bootloader (inherit u-boot-allwinner64-bootloader) (package u-boot-pinebook))) (define u-boot-puma-rk3399-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-puma-rk3399) (disk-image-installer install-puma-rk3399-u-boot))) (define u-boot-rock64-rk3328-bootloader ;; SD and eMMC use the same format (bootloader (inherit u-boot-bootloader) (package u-boot-rock64-rk3328) (disk-image-installer install-rock64-rk3328-u-boot))) (define u-boot-rockpro64-rk3399-bootloader ;; SD and eMMC use the same format (bootloader (inherit u-boot-bootloader) (package u-boot-rockpro64-rk3399) (disk-image-installer install-rockpro64-rk3399-u-boot))) (define u-boot-pinebook-pro-rk3399-bootloader ;; SD and eMMC use the same format (bootloader (inherit u-boot-bootloader) (package u-boot-pinebook-pro-rk3399) (disk-image-installer install-pinebook-pro-rk3399-u-boot))) (define u-boot-ts7970-q-2g-1000mhz-c-bootloader ;; This bootloader doesn't really need to be installed, as it is read from ;; an SPI memory chip, not the SD card. It is copied to /boot/u-boot.imx ;; for convenience and should be manually flashed at the U-Boot prompt. (bootloader (inherit u-boot-bootloader) (package u-boot-ts7970-q-2g-1000mhz-c) (installer (make-u-boot-installer "libexec/u-boot.imx")) (disk-image-installer #f))) (define u-boot-sifive-unmatched-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-sifive-unmatched) (disk-image-installer install-sifive-unmatched-u-boot))) (define u-boot-starfive-visionfive2-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-starfive-visionfive2) (installer install-starfive-visionfive2-uEnv.txt) (disk-image-installer install-starfive-visionfive2-u-boot))) (define u-boot-qemu-riscv64-bootloader (bootloader (inherit u-boot-bootloader) (package u-boot-qemu-riscv64) (installer (make-u-boot-installer "libexec/u-boot.bin")) (disk-image-installer #f)))