diff --git a/sys-boot/grub-efi-image/Manifest b/sys-boot/grub-efi-image/Manifest new file mode 100644 index 0000000..93cd919 --- /dev/null +++ b/sys-boot/grub-efi-image/Manifest @@ -0,0 +1,5 @@ +AUX grub-bootstrap.cfg 26 BLAKE2B 9acd7b63bca7b4ef14c9e676de6b827afecb7f1b4e92b23e36b6f1042f234bd9e5ca52b5a48363c66c2a935b77199b14b251356eceebd586b57894a7198aa9ab SHA512 ab7b22bfb260408aa695212a346d9e6a33f75584c23f2f3e611b74e4a211d9484bdf529894b79af7bb6bb2c30081edcda2802b03ac4dde646d3c9710c7903a22 +AUX grub-efi-modules 781 BLAKE2B ee58cdb8f4c3e605b9f8d497e8bba038df9fbeaa179da0940df87308902f3c48eb737667773c0a8a95ce46d3bf85e76dac8477aa7207506c6175d6021bd804a1 SHA512 3d82163af9bd84a6e4bd210122fd2608d40e1c09ed81639e45b15e45c140988de90116e48f15c9853515b21c1aae37a46b129631db86a2c90e93e9d9a63df180 +AUX grub-memdisk.cfg.in 212 BLAKE2B 01f7501be93c859d89453fd7e3ff58de3397cf9def38bc61270d9d574defcb5c63eede0599df65948a59e6ecb330f11ec9dbef7696019d07dcc5a5cd68cd23d4 SHA512 c8b44f37a6cfb1f6fd13f375e3a36fcf893fca9a2fe8e0ea79539bb681c53252c9cd12e7c13f5dcaaa616f84a9bbbc155cdb885b20d7356457bb796526f2ba74 +AUX sbat.csv.in 258 BLAKE2B dfd196fff3334844c3fb8b944e78a7c502572afa0e84c1a92be2b4b09730656dcc0dc518a291fafa8262f4209466a076c088dcd4e5d8dbcde629a00d97a833a7 SHA512 25541f85b23ed3f9fe53be9c9b293e45ec9ae7523d1f3b3b16a1b84f0fc0295e7d868c796a5119fa1693f0eed7face09cbab5eb0ce9d3ce6589ae1a198829eb7 +EBUILD grub-efi-image-0.ebuild 1836 BLAKE2B 487f9527ea0d1a8fec81ec520236ff9dbfb8e1be96c87a7c77bcabadd1b67531ebabe1b44b6ab24b042d96f3410e09d6e5bd99582183cb227ac056d3a8a42b28 SHA512 c34a944476f2c4783d002331ad78f4bd678d288be14e2e7d6b9326466357f4bc6b111e8242a0ad46f1e7ed33c73248c715a31a278ab62874d8dc648c72b78b64 diff --git a/sys-boot/grub-efi-image/files/grub-bootstrap.cfg b/sys-boot/grub-efi-image/files/grub-bootstrap.cfg new file mode 100644 index 0000000..e988314 --- /dev/null +++ b/sys-boot/grub-efi-image/files/grub-bootstrap.cfg @@ -0,0 +1 @@ +normal (memdisk)/grub.cfg diff --git a/sys-boot/grub-efi-image/files/grub-efi-modules b/sys-boot/grub-efi-image/files/grub-efi-modules new file mode 100644 index 0000000..3e21550 --- /dev/null +++ b/sys-boot/grub-efi-image/files/grub-efi-modules @@ -0,0 +1,93 @@ +all_video +boot +btrfs +cat +chain +configfile +echo +efifwsetup +efinet +ext2 +fat +font +f2fs +gettext +gfxmenu +gfxterm +gfxterm_background +gzio +halt +help +hfsplus +iso9660 +jfs +jpeg +keystatus +loadenv +loopback +linux +ls +lsefi +lsefimmap +lsefisystab +lssal +memdisk +minicmd +normal +ntfs +part_apple +part_msdos +part_gpt +password_pbkdf2 +png +probe +reboot +regexp +search +search_fs_uuid +search_fs_file +search_label +serial +sleep +smbios +squash4 +tar +test +true +video +xfs +zfs +zfscrypt +zfsinfo +cpuid +play +tpm +cryptodisk +gcry_arcfour +gcry_blowfish +gcry_camellia +gcry_cast5 +gcry_crc +gcry_des +gcry_dsa +gcry_idea +gcry_md4 +gcry_md5 +gcry_rfc2268 +gcry_rijndael +gcry_rmd160 +gcry_rsa +gcry_seed +gcry_serpent +gcry_sha1 +gcry_sha256 +gcry_sha512 +gcry_tiger +gcry_twofish +gcry_whirlpool +luks +lvm +mdraid09 +mdraid1x +raid5rec +raid6rec diff --git a/sys-boot/grub-efi-image/files/grub-memdisk.cfg.in b/sys-boot/grub-efi-image/files/grub-memdisk.cfg.in new file mode 100644 index 0000000..9972c5d --- /dev/null +++ b/sys-boot/grub-efi-image/files/grub-memdisk.cfg.in @@ -0,0 +1,9 @@ +if loadfont (memdisk)/fonts/unicode.pf2 ; then + set gfxmode=auto + load_video + insmod gfxterm +fi + +search --no-floppy --fs-uuid --set=root @BOOT_PART_UUID@ +set prefix=(\$root)/boot/grub +source \$prefix/grub.cfg diff --git a/sys-boot/grub-efi-image/files/sbat.csv.in b/sys-boot/grub-efi-image/files/sbat.csv.in new file mode 100644 index 0000000..6691299 --- /dev/null +++ b/sys-boot/grub-efi-image/files/sbat.csv.in @@ -0,0 +1,3 @@ +sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md +grub,1,Free Software Foundation,grub,2.06,https//www.gnu.org/software/grub/ +grub.gentoo,1,Gentoo Linux,grub,@GENTOO_GRUB_VERSION@,https://packages.gentoo.org/packages/sys-boot/grub/ diff --git a/sys-boot/grub-efi-image/grub-efi-image-0.ebuild b/sys-boot/grub-efi-image/grub-efi-image-0.ebuild new file mode 100644 index 0000000..ee779f0 --- /dev/null +++ b/sys-boot/grub-efi-image/grub-efi-image-0.ebuild @@ -0,0 +1,85 @@ +# Copyright 2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit mount-boot + +DESCRIPTION="Make GRUB EFI boot image" +HOMEPAGE="https://www.gentoo.org/" +SRC_URI="" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="-* ~amd64 ~x86" + +IUSE="+grub_platforms_efi-64 grub_platforms_efi-32" + +DEPEND=" + sys-boot/grub:2=[fonts] +" +RDEPEND="${DEPEND}" +BDEPEND=" + sys-apps/util-linux +" + +GRUB_VERSION="2.06-r4" +EFI_VENDOR="gentoo" +GRUB_FONT_SIZE="24" + +S="${WORKDIR}" + +src_prepare() { + # grub-probe --target=fs_uuid doesn't work here + BOOT_DEV="$(grub-probe --target=device ${ROOT}/boot)" + BOOT_PART_UUID="$(lsblk -o UUID -n ${BOOT_DEV})" + + [[ -z $BOOT_PART_UUID ]] && die "Can't find /boot partition UUID" + sed -e 's#@GENTOO_GRUB_VERSION@#'${GRUB_VERSION}'#g' \ + "${FILESDIR}/sbat.csv.in" > sbat.csv || die + + mkdir -p "${WORKDIR}/memdisk/fonts" || die + sed -e 's#@BOOT_PART_UUID@#'${BOOT_PART_UUID}'#g' \ + "${FILESDIR}/grub-memdisk.cfg.in" > memdisk/grub.cfg || die + + cp "${FILESDIR}/grub-bootstrap.cfg" "${WORKDIR}/" + + eapply_user +} + +src_compile() { + local plateform + local efi_name + + grub-mkfont \ + -s "${GRUB_FONT_SIZE}" \ + -o "${WORKDIR}/memdisk/fonts/unicode.pf2" \ + /usr/share/fonts/dejavu/DejaVuSansMono.ttf + + tar -cf "${WORKDIR}/memdisk.tar" -C "${WORKDIR}/memdisk" . + + if use grub_platforms_efi-64; then + platform="x86_64-efi" + efi_name="x64" + elif use grub_platforms_efi-64; then + platform="i386-efi" + efi_name="x32" + else + die "Unsupported platform" + fi + + grub-mkimage \ + -O "${platform}" \ + -o "${WORKDIR}/grub${efi_name}.efi" \ + -c "${WORKDIR}/grub-bootstrap.cfg" \ + -d "/usr/lib/grub/${platform}" \ + -m "${WORKDIR}/memdisk.tar" \ + -p "/EFI/gentoo" \ + --sbat "${WORKDIR}/sbat.csv" \ + $(cat "${FILESDIR}/grub-efi-modules") +} + +src_install() { + insinto /usr/lib/${PN} + doins grub*.efi +}