Add syslinux recipe

master
Karchnu 2021-04-23 03:21:29 +02:00
parent 8b344d3a93
commit 82e49fdc6d
9 changed files with 608 additions and 0 deletions

View File

@ -0,0 +1,36 @@
From: Lukas Schwaighofer <lukas@schwaighofer.name>
Date: Tue, 26 Feb 2019 23:13:58 +0100
Subject: Prevent optimizing the pow() function
With the current GCC 8.2.0 from Debian, a section of code calling pow() in
zzjson_parse.c is turned into a sequence calling exp(). Since no exp()
implementation is available in syslinux those optimizations need to be
disabled.
---
com32/gpllib/zzjson/zzjson_parse.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/com32/gpllib/zzjson/zzjson_parse.c b/com32/gpllib/zzjson/zzjson_parse.c
index ecb6f61..e66a9d8 100644
--- a/com32/gpllib/zzjson/zzjson_parse.c
+++ b/com32/gpllib/zzjson/zzjson_parse.c
@@ -138,6 +138,10 @@ static ZZJSON *parse_string2(ZZJSON_CONFIG *config) {
return zzjson;
}
+static double __attribute__((optimize("O0"))) pow_noopt(double x, double y) {
+ return pow(x, y);
+}
+
static ZZJSON *parse_number(ZZJSON_CONFIG *config) {
ZZJSON *zzjson;
unsigned long long ival = 0, expo = 0;
@@ -213,7 +217,7 @@ skipexpo:
if (dbl) {
dval = sign * (long long) ival;
dval += sign * frac;
- dval *= pow(10.0, (double) signexpo * expo);
+ dval *= pow_noopt(10.0, (double) signexpo * expo);
}
zzjson = config->calloc(1, sizeof(ZZJSON));

1
recipes/syslinux/FIXME Normal file
View File

@ -0,0 +1 @@
For now, some applications are installed in /usr/bin.

50
recipes/syslinux/Makefile Normal file
View File

@ -0,0 +1,50 @@
name = syslinux
#version = 6.03
#URL = https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/$(name)-$(version).tar.gz
version_abbr = 6.04
version = $(version_abbr)-pre1
URL = https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/$(version_abbr)/syslinux-$(version).tar.xz
patches != ls *.patch
dependencies = util-linux
build-dependencies = nasm linux-dev util-linux-dev
loaderarch_ = efi64
ifeq ($(ARCH),x86)
loaderarch_ = efi32
endif
loaderarch ?= $(loaderarch_)
build_backend = build_custom
build_custom:
$(Q)cd $(bdir); LDFLAGS= make $(loaderarch) installer
MAKE_INSTALL_OPTIONS_USER = -j1 \
INSTALLROOT="$(pkg_fake_root_dir)" \
DATADIR=$(PREFIX) \
BINDIR=$(BINDIR) \
SBINDIR=$(SBINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCLUDEDIR) \
MANDIR=$(MANDIR) \
TFTPBOOT=$(PREFIX)/tftpboot \
bios $(loaderarch)
post_fake_root_install:
mkdir -p "$(pkg_fake_root_dir)"/etc/update-extlinux.d
cp update-extlinux.conf "$(pkg_fake_root_dir)"/etc/
sed "/^version=/s/=.*/=$(version)-r$(release)/" update-extlinux \
> "$(pkg_fake_root_dir)"/sbin/update-extlinux
chmod 755 "$(pkg_fake_root_dir)"/sbin/update-extlinux
#build_custom:
# cd $(bdir) ; \
# (echo '#include <sys/sysmacros.h>'; cat extlinux/main.c) > main.c.new && \
# mv main.c.new extlinux/main.c ; \
# make efi32 efi64 bios installer
#MAKE_INSTALL_OPTIONS_USER = INSTALLROOT="$(pkg_fake_root_dir)" EXTLINUXDIR=/boot/extlinux
SYSCONF ?= ../../
include $(SYSCONF)/package.mk

View File

@ -0,0 +1,12 @@
diff --git a/extlinux/main.c b/extlinux/main.c
index a7ebd49..69bb164 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/vfs.h>
+#include <sys/sysmacros.h>
#include "linuxioctl.h"

View File

@ -0,0 +1,109 @@
From 951928f2cad5682c2844e6bd0f7201236c5d9b66 Mon Sep 17 00:00:00 2001
From: Merlin Mathesius <mmathesi@redhat.com>
Date: Wed, 13 May 2020 08:02:27 -0500
Subject: [PATCH] Workaround multiple definition of symbol errors
---
com32/cmenu/Makefile | 2 +-
com32/elflink/ldlinux/Makefile | 2 +-
com32/gpllib/Makefile | 2 +-
com32/hdt/Makefile | 2 +-
core/Makefile | 2 +-
dos/Makefile | 2 +-
efi/Makefile | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile
index b81b68ed..2ae989c4 100644
--- a/com32/cmenu/Makefile
+++ b/com32/cmenu/Makefile
@@ -49,7 +49,7 @@ makeoutputdirs:
@mkdir -p $(OBJ)/libmenu
libmenu/libmenu.elf: $(LIBMENU)
- $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) \
+ $(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) \
-o $@ $^
tidy dist:
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 87c0d362..2be2a01a 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -33,7 +33,7 @@ endif
all: $(BTARGET) ldlinux_lnx.a
ldlinux.elf : $(OBJS)
- $(LD) $(LDFLAGS) -soname $(SONAME) -o $@ $^ $(LIBS)
+ $(LD) $(LDFLAGS) -z muldefs -soname $(SONAME) -o $@ $^ $(LIBS)
LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile
index 1fec9145..2d764d0b 100644
--- a/com32/gpllib/Makefile
+++ b/com32/gpllib/Makefile
@@ -24,7 +24,7 @@ makeoutputdirs:
$(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))
libgpl.elf : $(LIBOBJS)
- $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
+ $(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
tidy dist clean:
find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index 61736d05..1d947857 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -52,7 +52,7 @@ QEMU ?= qemu-kvm
all: $(MODULES) $(TESTFILES)
hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
+ $(LD) $(LDFLAGS) -z muldefs -o $@ $^
memtest:
-[ ! -f $(FLOPPY_DIR)/$(MEMTEST) ] && $(WGET) $(MEMTEST_URL) -O $(FLOPPY_DIR)/$(MEMTEST)
diff --git a/core/Makefile b/core/Makefile
index 46cb037c..f0cfcbe9 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -156,7 +156,7 @@ LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
NASM_ELF = elf
%.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
- $(LD) $(LDFLAGS) -pie -Bsymbolic \
+ $(LD) $(LDFLAGS) -z muldefs -pie -Bsymbolic \
-T $(LDSCRIPT) \
--unresolved-symbols=report-all \
-E --hash-style=gnu -M -o $@ $< \
diff --git a/dos/Makefile b/dos/Makefile
index 4c930d19..5d1c72ca 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -19,7 +19,7 @@ include $(MAKEDIR)/embedded.mk
CFLAGS += -D__MSDOS__ -mregparm=3 -DREGPARM=3
# CFLAGS += -DDEBUG
-LDFLAGS = -T $(SRC)/dosexe.ld
+LDFLAGS = -T $(SRC)/dosexe.ld -z muldefs
OPTFLAGS = -g
INCLUDES = -include code16.h -nostdinc -iwithprefix include \
-I$(SRC) -I$(SRC)/.. -I$(SRC)/../libfat \
diff --git a/efi/Makefile b/efi/Makefile
index bbf23f24..3dd922d5 100644
--- a/efi/Makefile
+++ b/efi/Makefile
@@ -69,7 +69,7 @@ $(OBJS): | $(OBJ)/$(ARCH)
BTARGET = syslinux.efi
syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS)
- $(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi
+ $(LD) $(LDFLAGS) -z muldefs --strip-debug -o $@ $^ -lgnuefi -lefi
# We need to rename the .hash section because the EFI firmware
# linker really doesn't like it.
--
2.25.1

View File

@ -0,0 +1,61 @@
#!/bin/sh
# find given append opt
get_append_opt() {
awk -v search="$1" '
$1 == "append" || $1 == "APPEND" {
split($0, a);
for (i in a) {
if (index(a[i], search) == 1) {
print a[i];
}
}
}' /boot/extlinux.conf | sort | uniq
}
# print default kernel options
get_default_opts() {
awk '
$1 == "append" || $1 == "APPEND" {
opts="";
space="";
split($0, a);
for (i in a) {
if (i != 1 \
&& (index(a[i], "root=") != 1) \
&& (index(a[i], "initrd=") != 1) \
&& (index(a[i], "modules=") != 1)) {
opts = opts space a[i];
space = " ";
}
}
print opts;
}
' /boot/extlinux.conf | sort | uniq
}
if ! [ -f /boot/extlinux.conf ]; then
exit 0
fi
# check if we already have a generated extlinux.conf
if grep -q '^# Generated by update-extlinux' /boot/extlinux.conf; then
exit 0
fi
# try fish out the kernel opts from extlinuix.conf's append line
root=$(get_append_opt 'root=' | head -n 1)
modules=$(get_append_opt 'modules=' | head -n 1)
opts=$(get_default_opts | head -n 1)
# populate update-extlinux.conf with the info we know
if [ -n "$root" ]; then
sed -i -e "/^root=/s|.*|$root|g" /etc/update-extlinux.conf
fi
if [ -n "$modules" ]; then
sed -i -e "/^modules=/s|.*|$modules|g" /etc/update-extlinux.conf
fi
if [ -n "$opts" ]; then
sed -i -e "/^default_kernel_opts=/s|.*|default_kernel_opts=\"$opts\"|g" /etc/update-extlinux.conf
fi

View File

@ -0,0 +1,3 @@
#!/bin/sh
update-extlinux --warn-only

262
recipes/syslinux/update-extlinux Executable file
View File

@ -0,0 +1,262 @@
#!/bin/sh
version=
default=0
timeout=5
verbose=0
conf=/boot/extlinux.conf
myconf=/etc/update-extlinux.conf
# read in extlinux settings
if [ -f "$myconf" ]; then
. $myconf
fi
everbose() {
if [ "$verbose" = "0" ]; then
return
fi
echo $*
}
ewarn() {
echo "WARNING:" $@ >&2
}
eerror() {
echo "ERROR:" $@ >&2
return 1
}
usage() {
echo "usage: $0 [-v|--verbose] [--warn-only]"
}
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
-v|--verbose)
verbose=1
;;
--warn-only)
warn_only=1
;;
--)
break
;;
-*)
usage
exit 1
;;
esac
done
everbose "Updating extlinux configuration."
if [ "x$root" = "x" ]; then
ewarn "Root device is not specified in $myconf."
blkid_export=$(blkid -o export /dev/root)
if [ -n "$blkid_export" ]; then
export $blkid_export
fi
if [ -z "$UUID" ]; then
# try parse /proc/mount for mounted /
dev=$(awk '$2 == "/" {dev=$1} END {print dev}' /proc/mounts)
if [ -n "$dev" ]; then
blkid_export=$(blkid -o export $dev)
if [ -n "$blkid_export" ]; then
export "$blkid_export"
fi
fi
fi
if [ -z "$UUID" ]; then
if [ -z "$dev" ]; then
if [ -n "$warn_only" ]; then
ewarn "Failed to detect root device. extlinux.conf is not updated"
exit 0
else
eerror "Failed to detect root device"
exit 1
fi
else
root=$dev
fi
else
root=UUID=$UUID
fi
everbose "Root device is: $root"
fi
rtimeout=$(( ${timeout} * 10 ))
syslinux_menu=menu.c32
menu_hidden=
# vesa menu has been requested?
if [ "$vesa_menu" = "1" ]; then
syslinux_menu=vesamenu.c32
fi
umask 0022
rm -f $conf.new
echo "# Generated by update-extlinux $version" > $conf.new
if [ -n "$serial_port" ]; then
echo "SERIAL $serial_port ${serial_baud:-115200}" >> $conf.new
fi
echo "DEFAULT $syslinux_menu" >> $conf.new
echo "PROMPT 0" >> $conf.new
echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> $conf.new
if [ "$hidden" = "1" ]; then
echo "MENU HIDDEN" >> $conf.new
fi
echo "MENU AUTOBOOT Alpine will be booted automatically in # seconds." >> $conf.new
echo "TIMEOUT $rtimeout" >> $conf.new
lst=0
if [ -f "/boot/xen.gz" ]; then
for kernel in $(find /boot -name "vmlinuz-*" -type f); do
tag=$(basename $kernel | cut -b9-)
everbose "Found Xen hypervisor: /boot/xen.gz, kernel: $kernel"
if [ -f "/boot/initramfs-$tag" ]; then
everbose "Found initramfs: /boot/initramfs-$tag"
initramfs="initramfs-$tag"
else
initramfs=
fi
label=xen-$(grep -w -l $tag /usr/share/kernel/*/kernel.release \
| cut -d/ -f5)
if [ "$label" = "xen-" ]; then
label=xen-$lst
fi
echo "LABEL $label" >> $conf.new
if [ "$label" = "$default" ]; then
echo " MENU DEFAULT" >> $conf.new
fi
echo " MENU LABEL Xen + Linux $tag" >> $conf.new
echo " COM32 mboot.c32" >> $conf.new
echo " APPEND xen.gz $xen_opts --- $(basename $kernel) root=$root modules=${modules}${TYPE:+,$TYPE} $default_kernel_opts --- $initramfs" >> $conf.new
echo "" >> $conf.new
lst=$(($lst + 1))
done
fi
for kernel in $(find /boot -name "vmlinuz*" -type f); do
case $kernel in
*vmlinuz) tag=vanilla;;
*vmlinuz-*) tag=$(basename $kernel | cut -b9-);;
*) continue;;
esac
everbose "Found kernel: $kernel"
label=$(grep -w -l $tag /usr/share/kernel/*/kernel.release | cut -d/ -f5)
if [ -z "$label" ]; then
if [ "$tag" = vanilla ]; then
label="vanilla"
else
label=$lst
fi
fi
echo "LABEL $label" >> $conf.new
if [ "$label" = "$default" ]; then
echo " MENU DEFAULT" >> $conf.new
fi
echo " MENU LABEL Linux $tag" >> $conf.new
echo " LINUX $(basename $kernel)" >> $conf.new
initrd=
if [ -f "/boot/initramfs-$tag" ]; then
everbose "Found initramfs: /boot/initramfs-$tag"
initrd="initramfs-$tag"
fi
if [ -f "/boot/amd-ucode.img" ]; then
everbose "Found microcode for AMD CPUs: /boot/amd-ucode.img"
initrd="amd-ucode.img${initrd:+,}${initrd}"
fi
if [ -f "/boot/intel-ucode.img" ]; then
everbose "Found microcode for Intel CPUs: /boot/intel-ucode.img"
initrd="intel-ucode.img${initrd:+,}${initrd}"
fi
echo " INITRD ${initrd}" >> $conf.new
echo " APPEND root=$root modules=${modules}${TYPE:+,$TYPE} $default_kernel_opts" >> $conf.new
echo "" >> $conf.new
lst=$(($lst + 1))
done
if [ -n "$password" ]; then
echo "NOESCAPE 1" >> $conf.new
echo "MENU MASTER PASSWD $password" >> $conf.new
echo "" >> $conf.new
chmod o-r $conf.new
fi
everbose "$lst entries found."
for entry in /etc/update-extlinux.d/*; do
[ -f "$entry" ] && { cat $entry; echo ""; } >> $conf.new
done
echo "MENU SEPARATOR" >> $conf.new
echo "" >> $conf.new
if [ -f "/boot/hdt.c32" ]; then
everbose "Found Hardware Detection Tool: /boot/hdt.c32"
echo "LABEL hdt" >> $conf.new
echo " MENU LABEL Hardware info" >> $conf.new
if [ -n "$password" ]; then
echo " MENU PASSWD" >> $conf.new
fi
echo " COM32 hdt.c32" >> $conf.new
if [ -f "/boot/memtest" ]; then
everbose "Found memtest86+: /boot/memtest"
echo " APPEND memtest=memtest" >> $conf.new
fi
echo "" >> $conf.new
elif [ -f "/boot/memtest" ]; then
everbose "Found memtest86+: /boot/memtest"
echo "LABEL memtest" >> $conf.new
echo " MENU LABEL Memtest86+" >> $conf.new
echo " KERNEL memtest" >> $conf.new
echo "" >> $conf.new
fi
for i in reboot poweroff; do
[ -f "/boot/$i.c32" ] || continue
everbose "Found $i"
# make first char capital
cap=$( echo $i | awk '{sub(".", substr(toupper($0),1,1), $0); print}' )
echo "LABEL $i" >> $conf.new
echo " MENU LABEL $cap" >> $conf.new
echo " COM32 $i.c32" >> $conf.new
echo "" >> $conf.new
done
if cmp -s $conf.new $conf; then
everbose "Configuration unchanged."
rm $conf.new
fi
if [ "$overwrite" != "1" ]; then
exit 0
elif [ -f "$conf.new" ]; then
# keep a backup just in case
if [ -f "$conf" ]; then
mv $conf $conf.old
fi
mv $conf.new $conf
fi
everbose "Installing libutil.c32 libcom32.c32 mboot.c32 menu.c32 vesamenu.c32 to /boot."
cp /usr/share/syslinux/libutil.c32 \
/usr/share/syslinux/libcom32.c32 \
/usr/share/syslinux/mboot.c32 \
/usr/share/syslinux/menu.c32 \
/usr/share/syslinux/vesamenu.c32 \
/boot
case "$(stat -f -c '%T' /boot)" in
ext*) extlinux --update /boot || [ -n "$warn_only" ];;
esac

View File

@ -0,0 +1,74 @@
# configuration for extlinux config builder
# overwrite
# Overwrite current /boot/extlinux.conf. If this is not '1' we will only
# write to /boot/extlinux.conf.new
overwrite=1
# vesa_menu
# use fancy vesa menu (vesamenu.c32) menus, won't work with serial
vesa_menu=0
# default_kernel_opts
# default kernel options
default_kernel_opts=quiet
# modules
# modules which should be loaded before pivot_root
modules=sd-mod,usb-storage,ext4
# root
# root device - if not specified, will be guessed using
# blkid -o export /dev/root
root=
# verbose
# if set to non-zero, update-extlinux will be a lot more verbose.
verbose=0
# hidden
# if set to non-zero, the boot menu will be hidden by default.
hidden=1
# timeout
# number of seconds to wait before booting default
timeout=3
# default
# default kernel to boot
default=lts
# serial_port
# serial port number - if not specified, serial console will be disabled
serial_port=
# serial_baud
# the baudrate for the serial port. Will use 115200 if unset
serial_baud=115200
# xen_opts
# options to hand to xen hypervisor, useful ones are:
# dom0_mem=384M (give domain-0 environment 384M ram)
xen_opts=dom0_mem=384M
# if you copy /usr/share/syslinux/reboot.c32 to /boot/, a menu entry
# will be auto-generated for it
# if you copy hdt.c32, libgpl.c32, and libmenu.c32 from /usr/share/syslinux/
# to /boot/, a menu entry will be auto-generated for HDT
# if you download and install /boot/memtest, then if HDT is present it
# will use it, else a separate menu entry will be auto-generated for
# memtest
# optional password
# you can generate a SHA512 password using: mkpasswd
#
# if you assign a password, you should make this file world-unreadable
#
# if a password is assigned, the menu entries can't be edited at boot
# time, and HDT if present is password-protected
#
# you can also include "MENU PASSWD" in any custom entries you have in
# /etc/update-extlinux.d/
password=''