Last active
February 28, 2021 19:05
-
-
Save muradm/8ca56ecf89b8e60153233105e5c73a2d to your computer and use it in GitHub Desktop.
grub-latest.scm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-module (grub-latest) | |
#:use-module (guix build-system gnu) | |
#:use-module (guix build-system trivial) | |
#:use-module (guix download) | |
#:use-module (guix git-download) | |
#:use-module (guix licenses) | |
#:use-module (guix packages) | |
#:use-module (guix utils) | |
#:use-module (gnu packages) | |
#:use-module (gnu packages autotools) | |
#:use-module (gnu packages bash) | |
#:use-module (gnu packages bison) | |
#:use-module (gnu packages cdrom) | |
#:use-module (gnu packages disk) | |
#:use-module (gnu packages gettext) | |
#:use-module (gnu packages flex) | |
#:use-module (gnu packages fontutils) | |
#:use-module (gnu packages linux) | |
#:use-module (gnu packages man) | |
#:use-module (gnu packages mtools) | |
#:use-module (gnu packages ncurses) | |
#:use-module (gnu packages perl) | |
#:use-module (gnu packages pkg-config) | |
#:use-module (gnu packages python) | |
#:use-module (gnu packages texinfo) | |
#:use-module (gnu packages version-control) | |
#:use-module (gnu packages virtualization) | |
#:use-module (gnu packages xorg) | |
#:use-module ((gnu packages bootloaders) #:select (grub))) | |
(define gnulib-source | |
(let* ((commit "d271f868a8df9bbec29049d01e056481b7a1a263") | |
(hash "0ab57ccffdvrcab8i31yzvdzch0d26nc3hz067cj8vf48wq7bqq0")) | |
(package | |
(name "gnulib-source") | |
(version "git.d271f868") | |
(source (origin | |
(method git-fetch) | |
(uri (git-reference | |
(url "https://git.savannah.gnu.org/git/gnulib.git") | |
(commit commit))) | |
(file-name (git-file-name name version)) | |
(sha256 (base32 hash)))) | |
(build-system trivial-build-system) | |
(arguments | |
`(#:modules ((guix build utils)) | |
#:builder | |
(begin | |
(use-modules (guix build utils)) | |
(let* | |
((src (assoc-ref %build-inputs "source")) | |
(dst (assoc-ref %outputs "out")) | |
(sh (string-append (assoc-ref %build-inputs "bash") "/bin/bash"))) | |
(copy-recursively src dst #:log #f) | |
(substitute* (string-append dst "/gnulib-tool") | |
(("#! /bin/sh") (string-append "#! " sh)) | |
(("test -f /bin/sh") (string-append "test -f " sh)) | |
(("exec /bin/sh") (string-append "exec " sh)) | |
(("#!/bin/sh") (string-append "#!" sh)) | |
(("cp \"\\$lookedup_file\" \"\\$tmpfile\"") | |
"cp \"$lookedup_file\" \"$tmpfile\" && chmod 777 \"$tmpfile\""))) | |
#t))) | |
(inputs | |
`(("bash" ,bash-minimal))) | |
(home-page "https://www.gnu.org/software/gnulib/") | |
(synopsis "The GNU Portability Library") | |
(description "Gnulib is a central location for common GNU code") | |
(license gpl2+)))) | |
(define unifont | |
;; GNU Unifont, <http://gnu.org/s/unifont>. | |
;; GRUB needs it for its graphical terminal, gfxterm. | |
(origin | |
(method url-fetch) | |
(uri "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz") | |
(sha256 (base32 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys")))) | |
(define-public grub-efi-git | |
(let* ((commit "635ef55ed1252f92fe3bf70caefd185dcc507c43") | |
(hash "1xkjshzrdq643lwb1y7gmj90racpr4ry79xhga02474vn4pg0vfs")) | |
(package | |
(inherit grub) | |
(name "grub-git") | |
(version "2.04") | |
(source (origin | |
(method git-fetch) | |
(uri (git-reference | |
(url "https://git.savannah.gnu.org/git/grub.git") | |
(commit commit))) | |
(file-name (git-file-name name version)) | |
(sha256 (base32 hash)))) | |
(arguments | |
`(#:configure-flags (list "--with-platform=efi") | |
#:tests? #f | |
#:phases | |
(modify-phases %standard-phases | |
(add-after 'unpack 'patch-stuff | |
(lambda* (#:key inputs #:allow-other-keys) | |
(let* ((src (getcwd)) | |
(sbin-efibootmgr (string-append | |
(assoc-ref inputs "efibootmgr") | |
"/sbin/efibootmgr")) | |
(mtools (assoc-ref inputs "mtools")) | |
(bin-mformat (string-append "\"" mtools "/bin/mformat\"")) | |
(bin-mcopy (string-append "\"" mtools "/bin/mcopy\""))) | |
(substitute* "configure.ac" | |
(("AC_PREREQ\\(2.63\\)") "AC_PREREQ(2.64)")) | |
(substitute* "bootstrap" | |
(("#! /bin/sh") (string-append "#! " (which "bash"))) | |
(("\\$gnulib_tool_option_extras\\\\") (string-append "--dir=" src))) | |
(substitute* "autogen.sh" | |
(("#! /usr/bin/env bash") (string-append "#! " (which "bash")))) | |
(substitute* "grub-core/osdep/unix/platform.c" | |
(("efibootmgr") sbin-efibootmgr)) | |
(substitute* "util/grub-mkrescue.c" | |
(("\"mformat\"") bin-mformat) | |
(("\"mcopy\"") bin-mcopy))) | |
(copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz") | |
(system* "gunzip" "unifont.bdf.gz") | |
#t)) | |
(add-after 'unpack 'set-freetype-variables | |
(lambda* (#:key inputs #:allow-other-keys) | |
(when (assoc-ref inputs "freetype") | |
(let ((freetype (assoc-ref inputs "freetype"))) | |
(setenv "BUILD_FREETYPE_LIBS" | |
(string-append "-L" freetype "/lib -lfreetype")) | |
(setenv "BUILD_FREETYPE_CFLAGS" | |
(string-append "-I" freetype "/include/freetype2")))) | |
#t)) | |
(replace 'bootstrap | |
(lambda* (#:key inputs #:allow-other-keys) | |
(let* ((src (getcwd)) | |
(gnulib-src (assoc-ref inputs "gnulib-source"))) | |
(invoke (string-append src "/bootstrap") | |
(string-append "--gnulib-srcdir=" gnulib-src) | |
"--no-git" | |
"--copy")) | |
#t))))) | |
(inputs | |
`(("gettext" ,gettext-minimal) | |
("lvm2" ,lvm2) | |
("mdadm" ,mdadm) | |
("console-setup" ,console-setup) | |
("fuse" ,fuse) | |
("freetype" ,freetype) | |
("ncurses" ,ncurses) | |
("efibootmgr" ,efibootmgr) | |
("mtools" ,mtools))) | |
(native-inputs | |
`(("autoconf" ,autoconf) | |
("automake" ,automake) | |
("python" ,python-minimal-wrapper) | |
("gnulib-source" ,gnulib-source) | |
("git" ,git-minimal) | |
("pkg-config" ,pkg-config) | |
("unifont" ,unifont) | |
("bison" ,bison) | |
("flex" ,flex) | |
("texinfo" ,texinfo) | |
("help2man" ,help2man) | |
("freetype" ,freetype) | |
("parted" ,parted) | |
("qemu" ,qemu-minimal) | |
("xorriso" ,xorriso)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment