New Package: grub-cereus-2.06_1

GRUB is now packaged apart to have full control of default configuration.
This commit is contained in:
KF-Art 2023-01-20 00:57:30 -06:00
parent 1b98920024
commit 3824365a46
19 changed files with 810 additions and 0 deletions

View file

@ -0,0 +1 @@
grub-cereus

View file

@ -0,0 +1 @@
grub-cereus

View file

@ -0,0 +1 @@
grub-cereus

View file

@ -0,0 +1 @@
grub-cereus

1
srcpkgs/grub-cereus-utils Symbolic link
View file

@ -0,0 +1 @@
grub-cereus

View file

@ -0,0 +1 @@
grub-cereus

1
srcpkgs/grub-cereus-xen Symbolic link
View file

@ -0,0 +1 @@
grub-cereus

View file

@ -0,0 +1,24 @@
#
# Configuration file for GRUB.
#
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Cereus"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4"
# Uncomment to use basic console
#GRUB_TERMINAL_INPUT="console"
# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console
GRUB_BACKGROUND=/usr/share/backgrounds/grub-img.png
#GRUB_GFXMODE=1920x1080x32
#GRUB_DISABLE_LINUX_UUID=true
#GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
# Enable os-prober support by default
GRUB_DISABLE_OS_PROBER=false

View file

@ -0,0 +1,19 @@
#!/bin/sh
#
# Kernel hook for GRUB 2.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
export ZPOOL_VDEV_NAME_PATH=YES
if command -v grub-mkconfig >/dev/null 2>&1; then
if [ -d $ROOTDIR/boot/grub ]; then
grub-mkconfig -o $ROOTDIR/boot/grub/grub.cfg
exit $?
fi
fi
exit 0

View file

@ -0,0 +1 @@
grub-cereus-utils

View file

@ -0,0 +1,32 @@
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index f8cbb8d..f271608 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -246,6 +246,8 @@ export GRUB_DEFAULT \
GRUB_BACKGROUND \
GRUB_THEME \
GRUB_GFXPAYLOAD_LINUX \
+ GRUB_COLOR_NORMAL \
+ GRUB_COLOR_HIGHLIGHT \
GRUB_INIT_TUNE \
GRUB_SAVEDEFAULT \
GRUB_ENABLE_CRYPTODISK \
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index d2e7252..8259f45 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -125,6 +125,14 @@ cat <<EOF
EOF
+if [ x$GRUB_COLOR_NORMAL != x ] && [ x$GRUB_COLOR_HIGHLIGHT != x ] ; then
+ cat << EOF
+set menu_color_normal=$GRUB_COLOR_NORMAL
+set menu_color_highlight=$GRUB_COLOR_HIGHLIGHT
+
+EOF
+fi
+
serial=0;
gfxterm=0;
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do

View file

@ -0,0 +1,15 @@
diff -ruN a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
--- a/util/grub.d/10_linux.in 2020-12-22 17:24:17.000000000 -0600
+++ b/util/grub.d/10_linux.in 2023-01-18 13:20:46.609566912 -0600
@@ -30,6 +30,11 @@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
+# We're 'Cereus Linux' not 'Cereus GNU/Linux'
+elif [ "$(echo "$GRUB_DISTRIBUTOR" | sed 's|cereus.*|Cereus|i')" = "Cereus" ]; then
+ OS="Cereus Linux"
+ GRUB_DISTRIBUTOR="Cereus Linux"
+ CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"

View file

@ -0,0 +1,96 @@
From b98275138bf4fc250a1c362dfd2c8b1cf2421701 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Tue, 28 Sep 2021 13:50:47 +0800
Subject: build: Fix build error with binutils 2.36
The following procedure to build xen/pvgrub is broken.
git clone https://git.savannah.gnu.org/git/grub.git
cd grub
./bootstrap
mkdir build-xen
cd build-xen
../configure --with-platform=xen
make
It fails with the message:
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
section .note.gnu.property VMA [0000000000400158,0000000000400187]
overlaps section .bss VMA [000000000000f000,000000000041e1af]
The most significant factor is that new assembler (GNU as) generates the
.note.gnu.property section as default. This note section overlaps with
.bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
address of .text section is set, rather the address of .note.gnu.property
is calculated for some reason from 0x400000 where the ELF executable
defaults to start.
Using -Ttext-segment doesn't help either, though it is said to set the
address of the first byte of the text segment according to "man ld".
What it actually does is to override the default 0x400000, aka the image
base address, to something else. The entire process can be observed in
the default linker script used by gcc [1]. Therefore we can't expect it
to achieve the same thing as -Ttext given that the first segment where
.text resides is offset by SIZEOF_HEADERS plus some sections may be
preceding it within the first segment. The end result is .text always
has to start with non-zero address with -Wl,-Ttext-segment,0 if using
default linker script.
It is also worth mentioning that binutils upstream apparently doesn't
seem to consider this as a bug [2] and proposed to use -Wl,-Ttext-segment,0
which is not fruitful as what has been tested by Gentoo [3].
As long as GRUB didn't use ISA information encoded in .note.gnu.property,
we can safely drop it via -Wa,-mx86-used-note=no assembler option to
fix the linker error above.
This is considered a better approach than using custom linker script to
drop the .note.gnu.property section because object file manipulation can
also be hampered one way or the other in that linker script may not be
helpful. See also this commit removing the section in the process of objcopy.
6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
[1] In /usr/lib64/ldscripts/elf_x86_64.x or use 'gcc -Wl,--verbose ...'
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000));
. = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27377
[3] https://bugs.gentoo.org/787221
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
configure.ac | 14 ++++++++++++++
1 file changed, 14 insertions(+)
(limited to 'configure.ac')
diff --git a/configure.ac b/configure.ac
index eeb5d22..8d1c81a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -840,6 +840,20 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
fi
+if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
+ AC_CACHE_CHECK([whether -Wa,-mx86-used-note works], [grub_cv_cc_mx86_used_note], [
+ CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_mx86_used_note=yes],
+ [grub_cv_cc_mx86_used_note=no])
+ ])
+
+ if test "x$grub_cv_cc_mx86_used_note" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mx86-used-note=no"
+ fi
+fi
+
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
--
cgit v1.1

View file

@ -0,0 +1,71 @@
From 04aa0aa735f4bfa2d7a4f6593745fbe1d7fa0d0a Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Sat, 6 Sep 2014 12:20:12 +0100
Subject: grub-install: Install PV Xen binaries into the upstream specified
path
Upstream have defined a specification for where guests ought to place their
xenpv grub binaries in order to facilitate chainloading from a stage 1 grub
loaded from dom0.
http://xenbits.xen.org/docs/unstable-staging/misc/x86-xenpv-bootloader.html
The spec calls for installation into /boot/xen/pvboot-i386.elf or
/boot/xen/pvboot-x86_64.elf.
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
Bug-Debian: https://bugs.debian.org/762307
Forwarded: http://lists.gnu.org/archive/html/grub-devel/2014-10/msg00041.html
Last-Update: 2014-10-24
Patch-Name: grub-install-pvxen-paths.patch
---
v2: Respect bootdir, create /boot/xen as needed.
---
util/grub-install.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/util/grub-install.c b/util/grub-install.c
index b82c14d41..caadada98 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1962,6 +1962,28 @@ main (int argc, char *argv[])
}
break;
+ case GRUB_INSTALL_PLATFORM_I386_XEN:
+ {
+ char *path = grub_util_path_concat (2, bootdir, "xen");
+ char *dst = grub_util_path_concat (2, path, "pvboot-i386.elf");
+ grub_install_mkdir_p (path);
+ grub_install_copy_file (imgfile, dst, 1);
+ free (dst);
+ free (path);
+ }
+ break;
+
+ case GRUB_INSTALL_PLATFORM_X86_64_XEN:
+ {
+ char *path = grub_util_path_concat (2, bootdir, "xen");
+ char *dst = grub_util_path_concat (2, path, "pvboot-x86_64.elf");
+ grub_install_mkdir_p (path);
+ grub_install_copy_file (imgfile, dst, 1);
+ free (dst);
+ free (path);
+ }
+ break;
+
case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON:
case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS:
case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS:
@@ -1971,8 +1971,6 @@ main (int argc, char *argv[])
case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
case GRUB_INSTALL_PLATFORM_I386_QEMU:
- case GRUB_INSTALL_PLATFORM_I386_XEN:
- case GRUB_INSTALL_PLATFORM_X86_64_XEN:
case GRUB_INSTALL_PLATFORM_I386_XEN_PVH:
grub_util_warn ("%s",
_("WARNING: no platform-specific install was performed"));

View file

@ -0,0 +1,32 @@
From 54b741317568867fc4ad801a65397d05f3ea0f59 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Thu, 25 Sep 2014 18:41:29 -0300
Subject: Include a text attribute reset in the clear command for ppc
Always clear text attribute for clear command in order to avoid problems
after it boots.
* grub-core/term/terminfo.c: Add escape for text attribute reset
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1295255
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2014-09/msg00076.html
Last-Update: 2014-09-26
Patch-Name: ieee1275-clear-reset.patch
---
grub-core/term/terminfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
index f0d3e3deb..7cb7909c8 100644
--- a/grub-core/term/terminfo.c
+++ b/grub-core/term/terminfo.c
@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term,
/* Clear the screen. Using serial console, screen(1) only recognizes the
* ANSI escape sequence. Using video console, Apple Open Firmware
* (version 3.1.1) only recognizes the literal ^L. So use both. */
- data->cls = grub_strdup (" \e[2J");
+ data->cls = grub_strdup (" \e[2J\e[m");
data->reverse_video_on = grub_strdup ("\e[7m");
data->reverse_video_off = grub_strdup ("\e[m");
if (grub_strcmp ("ieee1275", str) == 0)

View file

@ -0,0 +1,220 @@
From 35118b5023b0d9b4e3ad82f6e15fb696ad8e2a10 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Tue, 28 Jan 2014 14:40:02 +0000
Subject: Port yaboot logic for various powerpc machine types
Some powerpc machines require not updating the NVRAM. This can be handled
by existing grub-install command-line options, but it's friendlier to detect
this automatically.
On chrp_ibm machines, use the nvram utility rather than nvsetenv. (This
is possibly suitable for other machines too, but that needs to be
verified.)
Forwarded: no
Last-Update: 2014-10-15
Patch-Name: install_powerpc_machtypes.patch
---
grub-core/osdep/basic/platform.c | 5 +++
grub-core/osdep/linux/platform.c | 72 ++++++++++++++++++++++++++++++
grub-core/osdep/unix/platform.c | 28 +++++++++---
grub-core/osdep/windows/platform.c | 6 +++
include/grub/util/install.h | 3 ++
util/grub-install.c | 11 +++++
6 files changed, 119 insertions(+), 6 deletions(-)
diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c
index 4b5502aeb..2ab907976 100644
--- a/grub-core/osdep/basic/platform.c
+++ b/grub-core/osdep/basic/platform.c
@@ -30,3 +30,8 @@ grub_install_get_default_x86_platform (void)
return "i386-pc";
}
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ return "generic";
+}
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
index 35f1bcc0e..9805c36d4 100644
--- a/grub-core/osdep/linux/platform.c
+++ b/grub-core/osdep/linux/platform.c
@@ -23,6 +23,7 @@
#include <grub/emu/misc.h>
#include <sys/types.h>
#include <dirent.h>
+#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
@@ -154,3 +154,74 @@ grub_install_get_default_x86_platform (void)
grub_util_info ("... not found");
return "i386-pc";
}
+
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ FILE *fp;
+ char *buf = NULL;
+ size_t len = 0;
+ const char *machtype = "generic";
+
+ fp = grub_util_fopen ("/proc/cpuinfo", "r");
+ if (! fp)
+ return machtype;
+
+ while (getline (&buf, &len, fp) > 0)
+ {
+ if (strncmp (buf, "pmac-generation",
+ sizeof ("pmac-generation") - 1) == 0)
+ {
+ if (strstr (buf, "NewWorld"))
+ {
+ machtype = "pmac_newworld";
+ break;
+ }
+ if (strstr (buf, "OldWorld"))
+ {
+ machtype = "pmac_oldworld";
+ break;
+ }
+ }
+
+ if (strncmp (buf, "motherboard", sizeof ("motherboard") - 1) == 0 &&
+ strstr (buf, "AAPL"))
+ {
+ machtype = "pmac_oldworld";
+ break;
+ }
+
+ if (strncmp (buf, "machine", sizeof ("machine") - 1) == 0 &&
+ strstr (buf, "CHRP IBM"))
+ {
+ if (strstr (buf, "qemu"))
+ {
+ machtype = "chrp_ibm_qemu";
+ break;
+ }
+ else
+ {
+ machtype = "chrp_ibm";
+ break;
+ }
+ }
+
+ if (strncmp (buf, "platform", sizeof ("platform") - 1) == 0)
+ {
+ if (strstr (buf, "Maple"))
+ {
+ machtype = "maple";
+ break;
+ }
+ if (strstr (buf, "Cell"))
+ {
+ machtype = "cell";
+ break;
+ }
+ }
+ }
+
+ free (buf);
+ fclose (fp);
+ return machtype;
+}
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index a3fcfcaca..28cb37e15 100644
--- a/grub-core/osdep/unix/platform.c
+++ b/grub-core/osdep/unix/platform.c
@@ -218,13 +218,29 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device,
else
boot_device = get_ofpathname (install_device);
- if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
- boot_device, NULL }))
+ if (strcmp (grub_install_get_default_powerpc_machtype (), "chrp_ibm") == 0)
{
- char *cmd = xasprintf ("setenv boot-device %s", boot_device);
- grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
- cmd);
- free (cmd);
+ char *arg = xasprintf ("boot-device=%s", boot_device);
+ if (grub_util_exec ((const char * []){ "nvram",
+ "--update-config", arg, NULL }))
+ {
+ char *cmd = xasprintf ("setenv boot-device %s", boot_device);
+ grub_util_error (_("`nvram' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
+ cmd);
+ free (cmd);
+ }
+ free (arg);
+ }
+ else
+ {
+ if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
+ boot_device, NULL }))
+ {
+ char *cmd = xasprintf ("setenv boot-device %s", boot_device);
+ grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
+ cmd);
+ free (cmd);
+ }
}
free (boot_device);
diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
index 912269191..c30025b13 100644
--- a/grub-core/osdep/windows/platform.c
+++ b/grub-core/osdep/windows/platform.c
@@ -128,6 +128,12 @@ grub_install_get_default_x86_platform (void)
return "i386-efi";
}
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ return "generic";
+}
+
static void *
get_efi_variable (const wchar_t *varname, ssize_t *len)
{
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index 5ca4811cd..9f517a1bb 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -223,6 +223,9 @@ grub_install_get_default_arm_platform (void);
const char *
grub_install_get_default_x86_platform (void);
+const char *
+grub_install_get_default_powerpc_machtype (void);
+
int
grub_install_register_efi (grub_device_t efidir_grub_dev,
const char *efifile_path,
diff --git a/util/grub-install.c b/util/grub-install.c
index e1a0202da..70b22eec4 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1179,7 +1179,18 @@ main (int argc, char *argv[])
if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
{
+ const char *machtype = grub_install_get_default_powerpc_machtype ();
int is_guess = 0;
+
+ if (strcmp (machtype, "pmac_oldworld") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "cell") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "generic") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "chrp_ibm_qemu") == 0)
+ update_nvram = 0;
+
if (!macppcdir)
{
char *d;

View file

@ -0,0 +1,16 @@
Patches OS X detection out of os-prober hook on non-x86 architectures. The
menu entries generated for those are invalid for non-x86 Mac stuff.
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -45,6 +45,11 @@ if [ -z "${OSPROBED}" ] ; then
fi
osx_entry() {
+ # GRUB won't load OS X outside of x86, no entry
+ case "x`uname -m`" in
+ xi?86|xx86_64) ;;
+ *) return ;;
+ esac
if [ x$2 = x32 ]; then
# TRANSLATORS: it refers to kernel architecture (32-bit)
bitstr="$(gettext "(32-bit)")"

View file

@ -0,0 +1,52 @@
From efc381a55124b12fc74ed8117283f11367c9372a Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Thu, 25 Sep 2014 19:33:39 -0300
Subject: Disable VSX instruction
VSX bit is enabled by default for Power7 and Power8 CPU models,
so we need to disable them in order to avoid instruction exceptions.
Kernel will activate it when necessary.
* grub-core/kern/powerpc/ieee1275/startup.S: Disable VSX.
Also-By: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Also-By: Colin Watson <cjwatson@debian.org>
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2014-09/msg00078.html
Last-Update: 2015-01-27
Patch-Name: ppc64el-disable-vsx.patch
---
grub-core/kern/powerpc/ieee1275/startup.S | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/grub-core/kern/powerpc/ieee1275/startup.S b/grub-core/kern/powerpc/ieee1275/startup.S
index 21c884b43..de9a9601a 100644
--- a/grub-core/kern/powerpc/ieee1275/startup.S
+++ b/grub-core/kern/powerpc/ieee1275/startup.S
@@ -20,6 +20,8 @@
#include <grub/symbol.h>
#include <grub/offsets.h>
+#define MSR_VSX 0x80
+
.extern __bss_start
.extern _end
@@ -28,6 +30,16 @@
.globl start, _start
start:
_start:
+ _start:
+
+ /* Disable VSX instruction */
+ mfmsr 0
+ oris 0,0,MSR_VSX
+ /* The "VSX Available" bit is in the lower half of the MSR, so we
+ don't need mtmsrd, which in any case won't work in 32-bit mode. */
+ mtmsr 0
+ isync
+
li 2, 0
li 13, 0

View file

@ -0,0 +1,225 @@
# Template file for 'grub-cereus'
pkgname=grub-cereus
version=2.06
revision=1
hostmakedepends="python3 pkg-config flex freetype-devel font-unifont-bdf help2man
automake gettext-devel-tools"
makedepends="libusb-compat-devel ncurses-devel freetype-devel
liblzma-devel device-mapper-devel fuse-devel"
depends="os-prober-cereus"
conflicts="grub"
repository="cereus-core"
conf_files="/etc/default/grub /etc/grub.d/*"
short_desc="GRand Unified Bootloader 2"
maintainer="Kevin F. <kevinfigueroart@proton.me>"
license="GPL-3.0-or-later"
homepage="https://www.gnu.org/software/grub/"
distfiles="${GNU_SITE}/grub/grub-${version}.tar.xz"
checksum=b79ea44af91b93d17cd3fe80bdae6ed43770678a9a5ae192ccea803ebb657ee1
archs="i686* x86_64* aarch64* ppc ppc-musl ppc64*"
nopie=yes
subpackages="grub-cereus-utils"
# _SUPPLEMENTARY_BUILDS is a list of <TARGET>-<PLATFORN> version of grub to build
case "$XBPS_TARGET_MACHINE" in
x86_64*)
_NATIVE_PLATFORM=pc
_SUPPLEMENTARY_BUILDS="i386-efi x86_64-efi i386-coreboot x86_64-xen"
subpackages+=" grub-cereus-i386-efi grub-cereus-x86_64-efi grub-cereus-i386-coreboot grub-cereus-xen"
;;
i686*)
CFLAGS="-D_FILE_OFFSET_BITS=64"
hostmakedepends+=" cross-x86_64-linux-musl"
configure_args+=" ac_cv_sizeof_off_t=8"
_NATIVE_PLATFORM=pc
_SUPPLEMENTARY_BUILDS="i386-efi x86_64-efi i386-coreboot i386-xen"
subpackages+=" grub-cereus-i386-efi grub-cereus-x86_64-efi grub-cereus-i386-coreboot grub-cereus-xen"
;;
aarch64*)
_NATIVE_PLATFORM=efi
subpackages+=" grub-cereus-arm64-efi"
;;
ppc*)
_NATIVE_PLATFORM=ieee1275
subpackages+=" grub-cereus-powerpc-ieee1275"
;;
esac
pre_configure() {
autoreconf -fi
}
do_configure() {
# workaround for https://savannah.gnu.org/bugs/?60458
# some more info: https://www.linuxquestions.org/questions/showthread.php?p=6257712
# grub 2.06 reboots immediately when compiled with -O2,
# only affects legacy BIOS
export CFLAGS="${CFLAGS/-O2/-Os}"
export CXXFLAGS="${CXXFLAGS/-O2/-Os}"
unset CC AS LD RANLIB CPP
local freestanding_cflags="-fno-stack-protector"
# building with altivec generates broken grub core
case "$XBPS_TARGET_MACHINE" in
ppc*) freestanding_cflags+=" -mno-altivec" ;;
esac
CFLAGS+=" $freestanding_cflags"
configure_args+=" --enable-device-mapper --enable-cache-stats --enable-nls
--enable-grub-mkfont --enable-grub-mount --disable-werror
--sbindir=/usr/bin"
# build tools
msg_normal "Configuring grub tools...\n"
mkdir $wrksrc/build
cd $wrksrc/build
../configure --host=${XBPS_TARGET_MACHINE} ${configure_args} \
${_NATIVE_PLATFORM:+--with-platform=${_NATIVE_PLATFORM}}
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_PLATFORM=${_SUPP_BUILD##*-}
msg_normal "Configuring ${_TARGET} ${_PLATFORM} grub...\n"
mkdir $wrksrc/${_PLATFORM}_${_TARGET}_build
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
if [ "$_TARGET" = x86_64 ] &&
[ "${XBPS_TARGET_MACHINE%-musl}" = i686 ]; then
_TARGET=x86_64-linux-musl
fi
CFLAGS="$freestanding_cflags" \
../configure --host=${XBPS_TARGET_MACHINE} \
--target=${_TARGET} \
--with-platform=${_PLATFORM} ${configure_args} \
--disable-efiemu \
--libdir=/usr/lib
done
}
do_build() {
# XXX remove the strip wrapper
rm ${XBPS_WRAPPERDIR}/strip
msg_normal "Building grub tools...\n"
cd $wrksrc/build
make ${makejobs}
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_PLATFORM=${_SUPP_BUILD##*-}
msg_normal "Building ${_TARGET} ${_PLATFORM} grub...\n"
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
make ${makejobs}
done
}
do_install() {
# XXX remove the strip wrapper
rm ${XBPS_WRAPPERDIR}/strip
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_GRUB_TARGET=${_TARGET}
case "${_GRUB_TARGET}" in
aarch64*)
_GRUB_TARGET=arm64
;;
esac
_PLATFORM=${_SUPP_BUILD##*-}
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
make DESTDIR=$DESTDIR/${_PLATFORM}_${_TARGET} install
# Remove non-platform specific files
rm -rf ${DESTDIR}/${_PLATFORM}_${_TARGET}/{boot,etc,usr/{share,bin}}
rm -f ${DESTDIR}/${_PLATFORM}_${_TARGET}/usr/lib/grub/${_GRUB_TARGET}-${_PLATFORM}/${_GRUB_TARGET}-*
rm -f ${DESTDIR}/${_PLATFORM}_${_TARGET}/usr/lib/grub/${_GRUB_TARGET}-${_PLATFORM}/*.{module,image}
cp -r ${DESTDIR}/${_PLATFORM}_${_TARGET}/* ${DESTDIR}
rm -rf ${DESTDIR}/${_PLATFORM}_${_TARGET}
done
cd $wrksrc/build
make DESTDIR=$DESTDIR install
# Required to compress info files.
vmkdir usr/share/info
touch -f ${DESTDIR}/usr/share/info/dir
vinstall ${FILESDIR}/grub.default 644 etc/default grub
# Kernel hooks.
vinstall ${FILESDIR}/kernel.d/grub.post 750 \
etc/kernel.d/post-install 50-grub
vinstall ${FILESDIR}/kernel.d/grub.post 750 \
etc/kernel.d/post-remove 50-grub
# update-grub for noobs.
printf "#!/bin/sh\ngrub-mkconfig -o /boot/grub/grub.cfg\nexit \$?\n" >> \
${DESTDIR}/usr/bin/update-grub
chmod 755 ${DESTDIR}/usr/bin/update-grub
vmkdir usr/share/bash-completion/completions
mv ${DESTDIR}/etc/bash_completion.d/grub \
${DESTDIR}/usr/share/bash-completion/completions
# Remove useless tools
rm ${DESTDIR}/usr/bin/grub-ofpathname
rm ${DESTDIR}/usr/bin/grub-sparc64-setup
}
grub-cereus-utils_package() {
short_desc+=" - additional utilities"
depends="grub-cereus>=${version}"
pkg_install() {
vmove usr/bin/grub-menulst2cfg
vmove usr/bin/grub-fstest
vmove usr/bin/grub-mkfont
}
}
grub-cereus-x86_64-efi_package() {
depends="grub-cereus>=$version dosfstools efibootmgr"
short_desc+=" - x86_64 EFI support"
pkg_install() {
vmove usr/lib/grub/x86_64-efi
}
}
grub-cereus-i386-efi_package() {
depends="grub-cereus>=$version dosfstools efibootmgr"
short_desc+=" - i386 EFI support"
pkg_install() {
vmove usr/lib/grub/i386-efi
}
}
grub-cereus-i386-coreboot_package() {
depends="grub-cereus>=$version"
short_desc+=" - i386 coreboot support"
pkg_install() {
vmove usr/lib/grub/i386-coreboot
}
}
grub-cereus-xen_package() {
depends="grub-cereus>=$version"
short_desc+=" - Xen PV support"
pkg_install() {
case "$XBPS_TARGET_MACHINE" in
x86_64*)
vmove usr/lib/grub/x86_64-xen
;;
i686*)
vmove usr/lib/grub/i386-xen
;;
esac
}
}
grub-cereus-arm64-efi_package() {
depends="grub-cereus>=$version dosfstools efibootmgr"
short_desc+=" - arm64 EFI support"
pkg_install() {
vmove usr/lib/grub/arm64-efi
}
}
grub-cereus-powerpc-ieee1275_package() {
depends="grub-cereus>=$version powerpc-utils"
short_desc+=" - powerpc Open Firmware support"
pkg_install() {
vmove usr/lib/grub/powerpc-ieee1275
}
}