upg syslinux
This commit is contained in:
parent
3f69da00f2
commit
bdfa1847d2
23 changed files with 2623 additions and 0 deletions
53
syslinux/0002-gfxboot-menu-label.patch
Normal file
53
syslinux/0002-gfxboot-menu-label.patch
Normal file
|
@ -0,0 +1,53 @@
|
|||
From: Colin Watson <cjwatson@ubuntu.com>
|
||||
Date: Wed, 2 Nov 2011 07:57:23 +0100
|
||||
Subject: Allow boot entry to start with label instead of menu_label.
|
||||
|
||||
menu_ptr->menu_label is human-readable (perhaps even translatable!) text if
|
||||
the MENU LABEL command is used, which isn't very convenient at the start of
|
||||
a boot entry. Allow the entry to start with menu_ptr->label (an
|
||||
identifier) as an alternative.
|
||||
---
|
||||
com32/gfxboot/gfxboot.c | 16 ++++++++++------
|
||||
1 file changed, 10 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
|
||||
index f67132c..4c76a35 100644
|
||||
--- a/com32/gfxboot/gfxboot.c
|
||||
+++ b/com32/gfxboot/gfxboot.c
|
||||
@@ -818,7 +818,7 @@ void boot(int index)
|
||||
{
|
||||
char *arg, *alt_kernel;
|
||||
menu_t *menu_ptr;
|
||||
- int i, label_len;
|
||||
+ int i, label_len, menu_label_len;
|
||||
unsigned ipapp;
|
||||
const struct syslinux_ipappend_strings *ipappend;
|
||||
char *gfxboot_cwd = (char *) gfx_config.gfxboot_cwd;
|
||||
@@ -836,18 +836,22 @@ void boot(int index)
|
||||
if(!menu_ptr || !menu_ptr->menu_label) return;
|
||||
|
||||
arg = skipspace(cmdline);
|
||||
- label_len = strlen(menu_ptr->menu_label);
|
||||
+ label_len = strlen(menu_ptr->label);
|
||||
+ menu_label_len = strlen(menu_ptr->menu_label);
|
||||
|
||||
// if it does not start with label string, assume first word is kernel name
|
||||
- if(strncmp(arg, menu_ptr->menu_label, label_len)) {
|
||||
+ if(!strncmp(arg, menu_ptr->label, label_len)) {
|
||||
+ arg += label_len;
|
||||
+ }
|
||||
+ else if(!strncmp(arg, menu_ptr->menu_label, menu_label_len)) {
|
||||
+ arg += menu_label_len;
|
||||
+ }
|
||||
+ else {
|
||||
alt_kernel = arg;
|
||||
arg = skip_nonspaces(arg);
|
||||
if(*arg) *arg++ = 0;
|
||||
if(*alt_kernel) menu_ptr->alt_kernel = alt_kernel;
|
||||
}
|
||||
- else {
|
||||
- arg += label_len;
|
||||
- }
|
||||
|
||||
arg = skipspace(arg);
|
||||
|
36
syslinux/0004-gnu-efi-from-arch.patch
Normal file
36
syslinux/0004-gnu-efi-from-arch.patch
Normal file
|
@ -0,0 +1,36 @@
|
|||
From: Lukas Schwaighofer <lukas@schwaighofer.name>
|
||||
Date: Tue, 3 Oct 2017 18:29:13 +0200
|
||||
Subject: Link against gnu-efi from Debian
|
||||
|
||||
Adjust EFIINC, LIBDIR and LIBEFI variables in mk/efi.mk to point to the
|
||||
files installed by Arch's gnu-efi package.
|
||||
|
||||
Forwarded: not-needed
|
||||
---
|
||||
mk/efi.mk | 13 ++++++++++---
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/mk/efi.mk b/mk/efi.mk
|
||||
index f097ad2..dc2b708 100644
|
||||
--- a/mk/efi.mk
|
||||
+++ b/mk/efi.mk
|
||||
@@ -8,8 +8,8 @@ core = $(topdir)/core
|
||||
# gnuefi sets up architecture specifics in ia32 or x86_64 sub directories
|
||||
# set up the LIBDIR and EFIINC for building for the appropriate architecture
|
||||
GCCOPT := $(call gcc_ok,-fno-stack-protector,)
|
||||
-EFIINC = $(objdir)/include/efi
|
||||
-LIBDIR = $(objdir)/lib
|
||||
+EFIINC = /usr/include/efi
|
||||
+LIBDIR = /usr/lib
|
||||
|
||||
ifeq ($(ARCH),i386)
|
||||
ARCHOPT = -m32 -march=i386
|
||||
@@ -44,7 +51,7 @@ SFLAGS = $(GCCOPT) $(GCCWARN) $(ARCHOPT) \
|
||||
-nostdinc -iwithprefix include \
|
||||
-I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
|
||||
|
||||
-LIBEFI = $(objdir)/lib/libefi.a
|
||||
+LIBEFI = $(LIBDIR)/libefi.a
|
||||
|
||||
$(LIBEFI):
|
||||
@echo Building gnu-efi for $(EFI_SUBARCH)
|
|
@ -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
|
||||
|
25
syslinux/0005-gnu-efi-version-compatibility.patch
Normal file
25
syslinux/0005-gnu-efi-version-compatibility.patch
Normal file
|
@ -0,0 +1,25 @@
|
|||
From: Lukas Schwaighofer <lukas@schwaighofer.name>
|
||||
Date: Mon, 3 Dec 2018 22:45:44 +0100
|
||||
Subject: Fix compatibility with new gnu-efi version
|
||||
|
||||
Allow multiple definitions when linking the syslinux binary so the
|
||||
memset and memcpy symbols which are included by gnu-efi since 3.0.8 are
|
||||
ignored (we still use the definitions from syslinux) but linking
|
||||
succeeds.
|
||||
---
|
||||
efi/Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/efi/Makefile b/efi/Makefile
|
||||
index f4501e7..0d1a673 100644
|
||||
--- a/efi/Makefile
|
||||
+++ b/efi/Makefile
|
||||
@@ -71,7 +71,7 @@ $(OBJS): | $(OBJ)/$(ARCH)
|
||||
BTARGET = syslinux.efi
|
||||
|
||||
syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS)
|
||||
- $(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi
|
||||
+ $(LD) $(LDFLAGS) -zmuldefs --strip-debug -o $@ $^ -lgnuefi -lefi
|
||||
|
||||
# We need to rename the .hash section because the EFI firmware
|
||||
# linker really doesn't like it.
|
|
@ -0,0 +1,40 @@
|
|||
From eae06bdce9468d7fde263de1c53f80f2faff0c9e Mon Sep 17 00:00:00 2001
|
||||
From: Merlin Mathesius <mmathesi@redhat.com>
|
||||
Date: Wed, 13 May 2020 11:58:37 -0500
|
||||
Subject: [PATCH] Replace builtin strlen that appears to get optimized away
|
||||
|
||||
---
|
||||
dos/string.h | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dos/string.h b/dos/string.h
|
||||
index f648de2d..407d0233 100644
|
||||
--- a/dos/string.h
|
||||
+++ b/dos/string.h
|
||||
@@ -5,12 +5,22 @@
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H
|
||||
|
||||
+#include <stddef.h>
|
||||
+
|
||||
/* Standard routines */
|
||||
#define memcpy(a,b,c) __builtin_memcpy(a,b,c)
|
||||
#define memmove(a,b,c) __builtin_memmove(a,b,c)
|
||||
#define memset(a,b,c) __builtin_memset(a,b,c)
|
||||
#define strcpy(a,b) __builtin_strcpy(a,b)
|
||||
-#define strlen(a) __builtin_strlen(a)
|
||||
+#define strlen(a) inline_strlen(a)
|
||||
+
|
||||
+/* replacement for builtin strlen that appears to get optimized away */
|
||||
+static inline size_t inline_strlen(const char *str)
|
||||
+{
|
||||
+ size_t l;
|
||||
+ for (l = 0; *str++; l++);
|
||||
+ return l;
|
||||
+}
|
||||
|
||||
/* This only returns true or false */
|
||||
static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
|
||||
--
|
||||
2.25.1
|
||||
|
43
syslinux/0016-strip-gnu-property.patch
Normal file
43
syslinux/0016-strip-gnu-property.patch
Normal file
|
@ -0,0 +1,43 @@
|
|||
From: Lukas Schwaighofer <lukas@schwaighofer.name>
|
||||
Date: Sat, 18 Aug 2018 12:48:21 +0200
|
||||
Subject: Strip the .note.gnu.property section for the mbr
|
||||
|
||||
This section is added since binutils Debian version 2.31.1-2 and causes mbr.bin
|
||||
to grow in size beyond what can fit into the master boot record.
|
||||
|
||||
Forwarded: https://www.syslinux.org/archives/2018-August/026168.html
|
||||
---
|
||||
mbr/i386/mbr.ld | 6 +++++-
|
||||
mbr/x86_64/mbr.ld | 6 +++++-
|
||||
2 files changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/mbr/i386/mbr.ld b/mbr/i386/mbr.ld
|
||||
index d14ba80..6d48990 100644
|
||||
--- a/mbr/i386/mbr.ld
|
||||
+++ b/mbr/i386/mbr.ld
|
||||
@@ -69,5 +69,9 @@ SECTIONS
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
- /DISCARD/ : { *(.note.GNU-stack) }
|
||||
+ /DISCARD/ :
|
||||
+ {
|
||||
+ *(.note.GNU-stack)
|
||||
+ *(.note.gnu.property)
|
||||
+ }
|
||||
}
|
||||
diff --git a/mbr/x86_64/mbr.ld b/mbr/x86_64/mbr.ld
|
||||
index ae27d49..5b46db6 100644
|
||||
--- a/mbr/x86_64/mbr.ld
|
||||
+++ b/mbr/x86_64/mbr.ld
|
||||
@@ -68,5 +68,9 @@ SECTIONS
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
- /DISCARD/ : { *(.note.GNU-stack) }
|
||||
+ /DISCARD/ :
|
||||
+ {
|
||||
+ *(.note.GNU-stack)
|
||||
+ *(.note.gnu.property)
|
||||
+ }
|
||||
}
|
306
syslinux/0017-single-load-segment.patch
Normal file
306
syslinux/0017-single-load-segment.patch
Normal file
|
@ -0,0 +1,306 @@
|
|||
From: Lukas Schwaighofer <lukas@schwaighofer.name>
|
||||
Date: Sat, 18 Aug 2018 16:56:35 +0200
|
||||
Subject: Force the linker to put all sections into a single PT_LOAD segment
|
||||
|
||||
This is required when using binutils >= 2.31 which writes two PT_LOAD segments
|
||||
by default. This is not supported by the wrapper.c script used to convert the
|
||||
shared object into an elf binary.
|
||||
|
||||
Forwarded: https://www.syslinux.org/archives/2018-August/026167.html
|
||||
---
|
||||
efi/i386/syslinux.ld | 37 +++++++++++++++++++++----------------
|
||||
efi/x86_64/syslinux.ld | 37 +++++++++++++++++++++----------------
|
||||
2 files changed, 42 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/efi/i386/syslinux.ld b/efi/i386/syslinux.ld
|
||||
index bab3fc7..19c1647 100644
|
||||
--- a/efi/i386/syslinux.ld
|
||||
+++ b/efi/i386/syslinux.ld
|
||||
@@ -19,6 +19,11 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
||||
OUTPUT_ARCH(i386)
|
||||
ENTRY(_start)
|
||||
|
||||
+PHDRS
|
||||
+{
|
||||
+ all PT_LOAD ;
|
||||
+}
|
||||
+
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
@@ -31,7 +36,7 @@ SECTIONS
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
__text_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
@@ -40,7 +45,7 @@ SECTIONS
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
__rodata_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -49,14 +54,14 @@ SECTIONS
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__ctors_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.dtors : {
|
||||
__dtors_start = .;
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__dtors_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4096);
|
||||
.rel : {
|
||||
@@ -64,7 +69,7 @@ SECTIONS
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.ctors)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -72,14 +77,14 @@ SECTIONS
|
||||
__gnu_hash_start = .;
|
||||
*(.gnu.hash)
|
||||
__gnu_hash_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
|
||||
.dynsym : {
|
||||
__dynsym_start = .;
|
||||
*(.dynsym)
|
||||
__dynsym_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -87,7 +92,7 @@ SECTIONS
|
||||
__dynstr_start = .;
|
||||
*(.dynstr)
|
||||
__dynstr_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -104,7 +109,7 @@ SECTIONS
|
||||
KEEP (*(.got.plt))
|
||||
KEEP (*(.got))
|
||||
__got_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -112,7 +117,7 @@ SECTIONS
|
||||
__dynamic_start = .;
|
||||
*(.dynamic)
|
||||
__dynamic_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
@@ -122,19 +127,19 @@ SECTIONS
|
||||
*(.data.*)
|
||||
*(.lowmem)
|
||||
__data_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.reloc : {
|
||||
*(.reloc)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.symtab : {
|
||||
*(.symtab)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.strtab : {
|
||||
*(.strtab)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
/* the EFI loader doesn't seem to like a .bss section,
|
||||
@@ -148,7 +153,7 @@ SECTIONS
|
||||
__bss_end = .;
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
- }
|
||||
+ } :all
|
||||
__bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start);
|
||||
__bss_dwords = (__bss_len + 3) >> 2;
|
||||
|
||||
@@ -161,7 +166,7 @@ SECTIONS
|
||||
*(.hugebss)
|
||||
*(.hugebss.*)
|
||||
__hugebss_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
_end = .;
|
||||
|
||||
diff --git a/efi/x86_64/syslinux.ld b/efi/x86_64/syslinux.ld
|
||||
index 450641c..a2c124f 100644
|
||||
--- a/efi/x86_64/syslinux.ld
|
||||
+++ b/efi/x86_64/syslinux.ld
|
||||
@@ -19,6 +19,11 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
ENTRY(_start)
|
||||
|
||||
+PHDRS
|
||||
+{
|
||||
+ all PT_LOAD ;
|
||||
+}
|
||||
+
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
@@ -31,7 +36,7 @@ SECTIONS
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
__text_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
@@ -40,7 +45,7 @@ SECTIONS
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
__rodata_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -49,14 +54,14 @@ SECTIONS
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__ctors_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.dtors : {
|
||||
__dtors_start = .;
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__dtors_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4096);
|
||||
.rel : {
|
||||
@@ -64,7 +69,7 @@ SECTIONS
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.ctors)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -72,14 +77,14 @@ SECTIONS
|
||||
__gnu_hash_start = .;
|
||||
*(.gnu.hash)
|
||||
__gnu_hash_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
|
||||
.dynsym : {
|
||||
__dynsym_start = .;
|
||||
*(.dynsym)
|
||||
__dynsym_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -87,7 +92,7 @@ SECTIONS
|
||||
__dynstr_start = .;
|
||||
*(.dynstr)
|
||||
__dynstr_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -104,7 +109,7 @@ SECTIONS
|
||||
KEEP (*(.got.plt))
|
||||
KEEP (*(.got))
|
||||
__got_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -112,7 +117,7 @@ SECTIONS
|
||||
__dynamic_start = .;
|
||||
*(.dynamic)
|
||||
__dynamic_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
@@ -122,19 +127,19 @@ SECTIONS
|
||||
*(.data.*)
|
||||
*(.lowmem)
|
||||
__data_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.reloc : {
|
||||
*(.reloc)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.symtab : {
|
||||
*(.symtab)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.strtab : {
|
||||
*(.strtab)
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
/* the EFI loader doesn't seem to like a .bss section,
|
||||
@@ -148,7 +153,7 @@ SECTIONS
|
||||
__bss_end = .;
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
- }
|
||||
+ } :all
|
||||
__bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start);
|
||||
__bss_dwords = (__bss_len + 3) >> 2;
|
||||
|
||||
@@ -161,7 +166,7 @@ SECTIONS
|
||||
*(.hugebss)
|
||||
*(.hugebss.*)
|
||||
__hugebss_end = .;
|
||||
- }
|
||||
+ } :all
|
||||
|
||||
_end = .;
|
||||
|
36
syslinux/0018-prevent-pow-optimization.patch
Normal file
36
syslinux/0018-prevent-pow-optimization.patch
Normal 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));
|
39
syslinux/0025-reproducible-build.patch
Normal file
39
syslinux/0025-reproducible-build.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
diff --git a/core/Makefile b/core/Makefile
|
||||
index 50ff35af..f1af71b7 100644
|
||||
--- a/core/Makefile
|
||||
+++ b/core/Makefile
|
||||
@@ -112,7 +112,7 @@ CFLAGS += -D__SYSLINUX_CORE__ -D__FIRMWARE_$(FIRMWARE)__ \
|
||||
# official release. Otherwise, substitute a hex string that is pretty much
|
||||
# guaranteed to be unique to be unique from build to build.
|
||||
ifndef HEXDATE
|
||||
-HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS))
|
||||
+HEXDATE := $(shell printf '0x%x\n' $(git log -1 --format=%ct)) # make the build more predictable
|
||||
endif
|
||||
ifndef DATE
|
||||
DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
|
||||
diff --git a/mk/lib.mk b/mk/lib.mk
|
||||
index f3fb07c7..bece24a0 100644
|
||||
--- a/mk/lib.mk
|
||||
+++ b/mk/lib.mk
|
||||
@@ -58,8 +58,8 @@ CFLAGS += -mregparm=3 -DREGPARM=3
|
||||
endif
|
||||
|
||||
ARCH_MATH_OBJS = \
|
||||
- $(patsubst $(com32)/lib/%.c,%.o,$(wildcard $(com32)/lib/$(ARCH)/math/*.c)) \
|
||||
- $(patsubst $(com32)/lib/%.S,%.o,$(wildcard $(com32)/lib/$(ARCH)/math/*.S))
|
||||
+ $(patsubst $(com32)/lib/%.c,%.o,$(sort $(wildcard $(com32)/lib/$(ARCH)/math/*.c))) \
|
||||
+ $(patsubst $(com32)/lib/%.S,%.o,$(sort $(wildcard $(com32)/lib/$(ARCH)/math/*.S)))
|
||||
|
||||
VPATH = $(SRC)
|
||||
LIBOTHER_OBJS = \
|
||||
@@ -130,8 +130,8 @@ LIBENTRY_OBJS = \
|
||||
exit.o
|
||||
|
||||
LIBGCC_OBJS = \
|
||||
- $(patsubst $(com32)/lib/%.c,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.c)) \
|
||||
- $(patsubst $(com32)/lib/%.S,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.S))
|
||||
+ $(patsubst $(com32)/lib/%.c,%.o,$(sort $(wildcard $(com32)/lib/$(ARCH)/libgcc/*.c))) \
|
||||
+ $(patsubst $(com32)/lib/%.S,%.o,$(sort $(wildcard $(com32)/lib/$(ARCH)/libgcc/*.S)))
|
||||
|
||||
LIBCONSOLE_OBJS = \
|
||||
\
|
122
syslinux/PKGBUILD
Normal file
122
syslinux/PKGBUILD
Normal file
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/bash
|
||||
# JOBoRun : Jwm OpenBox Obarun RUNit
|
||||
# Maintainer : Joe Bo Run <joborun@disroot.org>
|
||||
# PkgSource : url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
|
||||
# Website : https://pozol.eu
|
||||
#-----------------------------------------| DESCRIPTION |---------------------------------------
|
||||
|
||||
pkgname=syslinux
|
||||
pkgver=6.04.pre2.r11.gbf6db5b4
|
||||
#_tag=syslinux-$pkgver
|
||||
_commit=bf6db5b4
|
||||
pkgrel=04
|
||||
pkgdesc='Collection of boot loaders that boot from FAT, ext2/3/4 and btrfs filesystems, from CDs and via PXE'
|
||||
url='https://www.syslinux.org/'
|
||||
backup=(boot/syslinux/syslinux.cfg)
|
||||
install=syslinux.install
|
||||
# syslinux build system is a mess of submakes that does not work with -jN
|
||||
# efi32/com32 do not like Arch cflags/ldflags, though it would be nice to have the flags for userspace tools
|
||||
options=(!makeflags !buildflags)
|
||||
makedepends=(git python nasm upx asciidoc)
|
||||
makedepends_x86_64=(lib32-glibc) # efi32 needs it
|
||||
optdepends=('perl-crypt-passwdmd5: For md5pass'
|
||||
'perl-digest-sha1: For sha1pass'
|
||||
'mtools: For mkdiskimage and syslinux support'
|
||||
'gptfdisk: For GPT support'
|
||||
'util-linux: For isohybrid'
|
||||
'efibootmgr: For EFI support'
|
||||
'dosfstools: For EFI support')
|
||||
|
||||
# The syslinux-install_update script is maintained at https://gist.github.com/pyther/772138
|
||||
# Script not yet updated for syslinux-efi
|
||||
source=(git+https://repo.or.cz/syslinux.git#commit=$_commit
|
||||
syslinux.cfg
|
||||
syslinux-install_update
|
||||
splash.png
|
||||
0002-gfxboot-menu-label.patch
|
||||
0005-gnu-efi-version-compatibility.patch
|
||||
0017-single-load-segment.patch
|
||||
0004-gnu-efi-from-arch.patch
|
||||
0016-strip-gnu-property.patch
|
||||
0018-prevent-pow-optimization.patch
|
||||
0025-reproducible-build.patch
|
||||
0005-Workaround-multiple-definition-of-symbol-errors.patch
|
||||
0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch)
|
||||
|
||||
_targets='bios efi32 efi64'
|
||||
|
||||
pkgver() {
|
||||
cd syslinux
|
||||
git describe --long | sed 's/^syslinux-//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd syslinux
|
||||
|
||||
patch -p1 < ../0002-gfxboot-menu-label.patch
|
||||
patch -p1 < ../0017-single-load-segment.patch
|
||||
patch -p1 < ../0016-strip-gnu-property.patch
|
||||
patch -p1 < ../0018-prevent-pow-optimization.patch
|
||||
|
||||
# TODO: use 'gnu-efi-libs' package instead of embedded sources
|
||||
#patch -p1 < ../0004-gnu-efi-from-arch.patch
|
||||
#patch -p1 < ../0005-gnu-efi-version-compatibility.patch
|
||||
|
||||
patch -p1 < ../0025-reproducible-build.patch
|
||||
|
||||
patch -p1 < ../0005-Workaround-multiple-definition-of-symbol-errors.patch
|
||||
patch -p1 < ../0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch
|
||||
|
||||
# do not swallow efi compilation output to make debugging easier
|
||||
sed 's|> /dev/null 2>&1||' -i efi/check-gnu-efi.sh
|
||||
|
||||
# disable debug and development flags to reduce bootloader size
|
||||
truncate --size 0 mk/devel.mk
|
||||
}
|
||||
|
||||
build() {
|
||||
cd syslinux
|
||||
export LDFLAGS+=--no-dynamic-linker # workaround for binutils 2.28 http://www.syslinux.org/wiki/index.php?title=Building
|
||||
export EXTRA_CFLAGS=-fno-PIE # to fix gpxe build
|
||||
make PYTHON=python $_targets
|
||||
}
|
||||
|
||||
package() {
|
||||
cd syslinux
|
||||
make $_targets install INSTALLROOT="$pkgdir" SBINDIR=/usr/bin MANDIR=/usr/share/man AUXDIR=/usr/lib/syslinux
|
||||
|
||||
rm -r "$pkgdir"/usr/lib/syslinux/{com32,dosutil,syslinux.com}
|
||||
install -D -m644 COPYING "$pkgdir"/usr/share/licenses/syslinux/COPYING
|
||||
install -d "$pkgdir"/usr/share/doc
|
||||
cp -ar doc "$pkgdir"/usr/share/doc/syslinux
|
||||
|
||||
install -d "$pkgdir"/usr/lib/syslinux/bios
|
||||
mv "$pkgdir"/usr/lib/syslinux/{*.bin,*.c32,*.0,memdisk} "$pkgdir"/usr/lib/syslinux/bios
|
||||
|
||||
install -D -m0644 ../syslinux.cfg "$pkgdir"/boot/syslinux/syslinux.cfg
|
||||
install -D -m0644 ../splash.png "$pkgdir"/boot/syslinux/splash.png
|
||||
install -D -m0755 ../syslinux-install_update "$pkgdir"/usr/bin/syslinux-install_update
|
||||
}
|
||||
|
||||
#---- arch license gpg-key & sha256sums ----
|
||||
|
||||
arch=(x86_64)
|
||||
|
||||
license=(GPL2)
|
||||
|
||||
sha256sums=(SKIP
|
||||
a341c4724ce09e198c7d517418f0db1bbfa0b2f9e98499cce8543cfb7f49886a # syslinux.cfg
|
||||
093cdbca2f52b24599f414573d5e56747739c5a2185dca711bef1255dfba90b6 # syslinux-install_update
|
||||
16413f7f689155319804c1bd964ae9047d1b682b28386b2441d849fc14031da7 # splash.png
|
||||
d1fe9084ce2526619f94b8a07b89fb0194e874beef9f202f8b974879d77f2e1a # 0002-gfxboot-menu-label.patch
|
||||
8610959df6c01568ff478ca1eb4aac301f3ba1f5bd4739daaec072865e8be2d7 # 0005-gnu-efi-version-compatibility.patch
|
||||
5b017ba5eae77caa09fa5af6ecfa0df1e7e22776b2b13c8744c6cb7ecd7ad0e9 # 0017-single-load-segment.patch
|
||||
cf3c3da9300d6ea70eab5b8dca724ce03a3651bd63fb0168594dcfeb35eec11c # 0004-gnu-efi-from-arch.patch
|
||||
7facb5c2abc71c9bfe01bf4db388306ed7b7abf6654009af336262839527f962 # 0016-strip-gnu-property.patch
|
||||
755cd7062fe8495f6f62053ce664451c12ae65dba9fb5c75062a495fbe040fb1 # 0018-prevent-pow-optimization.patch
|
||||
9a76f6f75a42485bc337163ba38068b09f7889bdc1a4e191408898f10de36662 # 0025-reproducible-build.patch
|
||||
7e41e17e8cbc7287d6c3c9eb0a7b682cd8d3252030856b338050c21dff9bf05a # 0005-Workaround-multiple-definition-of-symbol-errors.patch
|
||||
d7410d0ff89a15e2a100faf1546d730e043dde15c295974564144e00a93f03a3) # 0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch)
|
||||
|
||||
## fa71cd3c73ea9b00cb441b495b17385e63074fdcdd75aaf8e700cc9c476125d5 syslinux-6.04.pre2.r11.gbf6db5b4-04-x86_64.pkg.tar.lz
|
||||
|
110
syslinux/PKGBUILD-arch
Normal file
110
syslinux/PKGBUILD-arch
Normal file
|
@ -0,0 +1,110 @@
|
|||
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
|
||||
# Maintainer: Thomas Bächler <thomas@archlinux.org>
|
||||
# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
|
||||
# Contributor: Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
|
||||
|
||||
pkgname=syslinux
|
||||
pkgver=6.04.pre2.r11.gbf6db5b4
|
||||
#_tag=syslinux-$pkgver
|
||||
_commit=bf6db5b4
|
||||
pkgrel=4
|
||||
pkgdesc='Collection of boot loaders that boot from FAT, ext2/3/4 and btrfs filesystems, from CDs and via PXE'
|
||||
url='https://www.syslinux.org/'
|
||||
arch=(x86_64)
|
||||
backup=(boot/syslinux/syslinux.cfg)
|
||||
install=syslinux.install
|
||||
license=(GPL2)
|
||||
# syslinux build system is a mess of submakes that does not work with -jN
|
||||
# efi32/com32 do not like Arch cflags/ldflags, though it would be nice to have the flags for userspace tools
|
||||
options=(!makeflags !buildflags)
|
||||
makedepends=(git python nasm upx asciidoc)
|
||||
makedepends_x86_64=(lib32-glibc) # efi32 needs it
|
||||
optdepends=('perl-crypt-passwdmd5: For md5pass'
|
||||
'perl-digest-sha1: For sha1pass'
|
||||
'mtools: For mkdiskimage and syslinux support'
|
||||
'gptfdisk: For GPT support'
|
||||
'util-linux: For isohybrid'
|
||||
'efibootmgr: For EFI support'
|
||||
'dosfstools: For EFI support')
|
||||
|
||||
# The syslinux-install_update script is maintained at https://gist.github.com/pyther/772138
|
||||
# Script not yet updated for syslinux-efi
|
||||
source=(git+https://repo.or.cz/syslinux.git#commit=$_commit
|
||||
syslinux.cfg
|
||||
syslinux-install_update
|
||||
0002-gfxboot-menu-label.patch
|
||||
0005-gnu-efi-version-compatibility.patch
|
||||
0017-single-load-segment.patch
|
||||
0004-gnu-efi-from-arch.patch
|
||||
0016-strip-gnu-property.patch
|
||||
0018-prevent-pow-optimization.patch
|
||||
0025-reproducible-build.patch
|
||||
0005-Workaround-multiple-definition-of-symbol-errors.patch
|
||||
0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch
|
||||
)
|
||||
sha256sums=('SKIP'
|
||||
'b9692be0cce43811c1b04053072ac50dd7b39bbc2ba7bcbe0e4387668af8df08'
|
||||
'5f86b5813465c48ba7bd178389aacb5149ff0b5f2467ab1772a4f862c5b15d41'
|
||||
'd1fe9084ce2526619f94b8a07b89fb0194e874beef9f202f8b974879d77f2e1a'
|
||||
'8610959df6c01568ff478ca1eb4aac301f3ba1f5bd4739daaec072865e8be2d7'
|
||||
'5b017ba5eae77caa09fa5af6ecfa0df1e7e22776b2b13c8744c6cb7ecd7ad0e9'
|
||||
'cf3c3da9300d6ea70eab5b8dca724ce03a3651bd63fb0168594dcfeb35eec11c'
|
||||
'7facb5c2abc71c9bfe01bf4db388306ed7b7abf6654009af336262839527f962'
|
||||
'755cd7062fe8495f6f62053ce664451c12ae65dba9fb5c75062a495fbe040fb1'
|
||||
'9a76f6f75a42485bc337163ba38068b09f7889bdc1a4e191408898f10de36662'
|
||||
'7e41e17e8cbc7287d6c3c9eb0a7b682cd8d3252030856b338050c21dff9bf05a'
|
||||
'd7410d0ff89a15e2a100faf1546d730e043dde15c295974564144e00a93f03a3')
|
||||
|
||||
_targets='bios efi64 efi32'
|
||||
|
||||
pkgver() {
|
||||
cd syslinux
|
||||
git describe --long | sed 's/^syslinux-//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd syslinux
|
||||
|
||||
patch -p1 < ../0002-gfxboot-menu-label.patch
|
||||
patch -p1 < ../0017-single-load-segment.patch
|
||||
patch -p1 < ../0016-strip-gnu-property.patch
|
||||
patch -p1 < ../0018-prevent-pow-optimization.patch
|
||||
|
||||
# TODO: use 'gnu-efi-libs' package instead of embedded sources
|
||||
# patch -p1 < ../0004-gnu-efi-from-arch.patch
|
||||
# patch -p1 < ../0005-gnu-efi-version-compatibility.patch
|
||||
|
||||
patch -p1 < ../0025-reproducible-build.patch
|
||||
|
||||
patch -p1 < ../0005-Workaround-multiple-definition-of-symbol-errors.patch
|
||||
patch -p1 < ../0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch
|
||||
|
||||
# do not swallow efi compilation output to make debugging easier
|
||||
sed 's|> /dev/null 2>&1||' -i efi/check-gnu-efi.sh
|
||||
|
||||
# disable debug and development flags to reduce bootloader size
|
||||
truncate --size 0 mk/devel.mk
|
||||
}
|
||||
|
||||
build() {
|
||||
cd syslinux
|
||||
export LDFLAGS+=--no-dynamic-linker # workaround for binutils 2.28 http://www.syslinux.org/wiki/index.php?title=Building
|
||||
export EXTRA_CFLAGS=-fno-PIE # to fix gpxe build
|
||||
make PYTHON=python $_targets
|
||||
}
|
||||
|
||||
package() {
|
||||
cd syslinux
|
||||
make $_targets install INSTALLROOT="$pkgdir" SBINDIR=/usr/bin MANDIR=/usr/share/man AUXDIR=/usr/lib/syslinux
|
||||
|
||||
rm -r "$pkgdir"/usr/lib/syslinux/{com32,dosutil,syslinux.com}
|
||||
install -D -m644 COPYING "$pkgdir"/usr/share/licenses/syslinux/COPYING
|
||||
install -d "$pkgdir"/usr/share/doc
|
||||
cp -ar doc "$pkgdir"/usr/share/doc/syslinux
|
||||
|
||||
install -d "$pkgdir"/usr/lib/syslinux/bios
|
||||
mv "$pkgdir"/usr/lib/syslinux/{*.bin,*.c32,*.0,memdisk} "$pkgdir"/usr/lib/syslinux/bios
|
||||
|
||||
install -D -m0644 ../syslinux.cfg "$pkgdir"/boot/syslinux/syslinux.cfg
|
||||
install -D -m0755 ../syslinux-install_update "$pkgdir"/usr/bin/syslinux-install_update
|
||||
}
|
1
syslinux/clean
Normal file
1
syslinux/clean
Normal file
|
@ -0,0 +1 @@
|
|||
rm -rf {src,pkg,syslinux}
|
8
syslinux/deps
Normal file
8
syslinux/deps
Normal file
|
@ -0,0 +1,8 @@
|
|||
git
|
||||
python
|
||||
nasm
|
||||
upx
|
||||
asciidoc
|
||||
lib32-glibc
|
||||
|
||||
|
BIN
syslinux/splash.png
Normal file
BIN
syslinux/splash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 141 KiB |
10
syslinux/sums
Normal file
10
syslinux/sums
Normal file
|
@ -0,0 +1,10 @@
|
|||
syslinux.cfg
|
||||
syslinux-install_update
|
||||
splash.png
|
||||
0002-gfxboot-menu-label.patch
|
||||
0005-gnu-efi-version-compatibility.patch
|
||||
0017-single-load-segment.patch
|
||||
0004-gnu-efi-from-arch.patch
|
||||
0016-strip-gnu-property.patch
|
||||
0018-prevent-pow-optimization.patch
|
||||
0025-reproducible-build.patch
|
465
syslinux/syslinux-install_update
Normal file
465
syslinux/syslinux-install_update
Normal file
|
@ -0,0 +1,465 @@
|
|||
#!/usr/bin/bash
|
||||
#
|
||||
# Syslinux Installer / Updater Script (for BIOS only)
|
||||
# Copyright (C) 2011-2013 Matthew Gyurgyik <pyther@pyther.net>
|
||||
# Copyright (C) 2013 Keshav Padram Amburay <(the) (ddoott) (ridikulus) (ddoott) (rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
|
||||
#
|
||||
# This program 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 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
#-----------------
|
||||
# ChangeLog:
|
||||
# 2013-10-23 : Keshav Padram Amburay : Updated script to work with Syslinux 6.02 joborun pkg
|
||||
#-----------------
|
||||
# Exit Codes:
|
||||
# 1 - get_boot_device or other function failed
|
||||
# 2 - install/update failed
|
||||
# 3 - set_active failed
|
||||
# 4 - install_mbr failed
|
||||
#-----------------
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
bios_libpath="/usr/lib/syslinux/bios"
|
||||
bios_bootpath="/boot/syslinux"
|
||||
EXTLINUX="/usr/bin/extlinux"
|
||||
|
||||
bios_autoupdate_file="/boot/syslinux/SYSLINUX_AUTOUPDATE"
|
||||
pciids_file="/usr/share/hwdata/pci.ids"
|
||||
|
||||
## Helper functions ##
|
||||
# Taken from libui-sh
|
||||
# $1 needle
|
||||
# $2 set (array) haystack
|
||||
check_is_in() {
|
||||
local needle="$1" element
|
||||
shift
|
||||
for element; do
|
||||
[[ $element = $needle ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_disk() {
|
||||
local part=$1
|
||||
if [[ ! -b "${part}" ]]; then
|
||||
echo >&2 "error: '$part' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$part" in
|
||||
*[[:digit:]]p[[:digit:]]*)
|
||||
local disk="${part%%p$partnum}" # get everything before p1
|
||||
;;
|
||||
*)
|
||||
local disk="${part%%[[:digit:]]*}"
|
||||
;;
|
||||
esac
|
||||
if [[ ! -b "${disk}" ]]; then
|
||||
echo >&2 "error: '$disk' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
echo $disk
|
||||
}
|
||||
|
||||
# return true when blockdevice is an md raid, otherwise return a unset value
|
||||
# get all devices that are part of raid device $1
|
||||
device_is_raid() {
|
||||
[[ $1 && -f /proc/mdstat ]] || return 1
|
||||
local devmajor=$(stat -c %t "$1")
|
||||
(( devmajor == 9 ))
|
||||
}
|
||||
|
||||
mdraid_all_slaves() {
|
||||
local slave slaves
|
||||
for slave in /sys/class/block/${1##*/}/slaves/*; do
|
||||
source "$slave/uevent"
|
||||
slaves="$slaves/dev/$DEVNAME "
|
||||
unset DEVNAME
|
||||
done
|
||||
echo $slaves
|
||||
}
|
||||
|
||||
# Check /sys/block to see if device is partitioned
|
||||
# If we have a partitioned block device (sda1) /sys/block/sda1/dev will not exist
|
||||
# However, if we have an unpartitioned block device (sda) /sys/block/sda/dev will exist
|
||||
dev_is_part() {
|
||||
# $1 - blockdevice
|
||||
local dev=$1
|
||||
|
||||
# If block device uevent file should be found
|
||||
# If a partition is passed in path shouldn't exist
|
||||
if [[ $dev = *cciss* ]]; then
|
||||
[[ -f /sys/block/cciss\!${dev##*/}/dev ]] && return 1
|
||||
elif [[ $dev = *ida* ]]; then
|
||||
[[ -f /sys/block/ida\!${dev##*/}/dev ]] && return 1
|
||||
else
|
||||
[[ -f /sys/block/${dev##*/}/dev ]] && return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# If EFI PART is present in the first 8 bytes then it must be a GPT disk
|
||||
device_is_gpt() {
|
||||
local partsig=$(dd if="$1" skip=64 bs=8 count=1 2>/dev/null)
|
||||
[[ $partsig = "EFI PART" ]]
|
||||
}
|
||||
|
||||
clear_gpt_attr2() {
|
||||
# $1 - Block Device, no partitions
|
||||
local disk=$1
|
||||
|
||||
# Special Exception for cciss controllers
|
||||
if [[ $disk = *cciss* ]]; then
|
||||
for part in /dev/cciss/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
# Smart 2 Controllers
|
||||
elif [[ $disk = *ida* ]]; then
|
||||
for part in /dev/ida/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
else
|
||||
for part in /sys/block/${disk##*/}/${disk##*/}*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
usage: $0 options
|
||||
|
||||
This script will install or upgrade Syslinux (for BIOS only)
|
||||
|
||||
OPTIONS:
|
||||
-h Show this message
|
||||
-i Install Syslinux
|
||||
-u Update Syslinux
|
||||
-a Set Boot flag on boot partiton
|
||||
-m Install Syslinux MBR
|
||||
-s Updates Syslinux if /boot/syslinux/SYSLINUX_AUTOUPDATE exists
|
||||
|
||||
Arguments Required:
|
||||
-c Chroot install (ex: -c /mnt)
|
||||
|
||||
Example Usage: $0 -i -a -m # (install, set boot flag, install mbr)
|
||||
$0 -u # (update)
|
||||
EOF
|
||||
}
|
||||
|
||||
# Trys to find the partition that /boot resides on
|
||||
# This will either be on /boot or / (root)
|
||||
getBoot() {
|
||||
if [[ ! -d "$bios_bootpath" ]]; then
|
||||
echo "Could not find $bios_bootpath"
|
||||
echo "Is boot mounted? Is Syslinux installed?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
syslinux_fs=(ext2 ext3 ext4 btrfs vfat xfs)
|
||||
|
||||
# Use DATA from findmnt see rc.sysint for more info
|
||||
if [[ -f /proc/self/mountinfo ]]; then
|
||||
read rootdev rootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/")
|
||||
read bootdev bootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/boot")
|
||||
else
|
||||
echo "Could not find /proc/self/mountinfo"
|
||||
echo "Are you running a kernel greater than 2.6.24?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $bootfs ]]; then
|
||||
if ! check_is_in "$bootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/boot file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="boot"
|
||||
bootpart="$(readlink -f "$bootdev")"
|
||||
elif [[ $rootfs ]]; then
|
||||
if ! check_is_in "$rootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/ (root) file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="root"
|
||||
bootpart="$(readlink -f "$rootdev")"
|
||||
else
|
||||
echo "Could not find filesystem on / (root) or /boot."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# We store the partition table type either gpt or mbr in var ptb
|
||||
# In rare cases a user could have one raid disk using mbr and another using gpt
|
||||
# In such cases we accept that the output may be incomplete
|
||||
|
||||
# Calls get_ptb() for $bootpart or for all device in RAID
|
||||
declare -A bootdevs
|
||||
get_boot_devices() {
|
||||
if device_is_raid "$bootpart"; then
|
||||
slaves=$(mdraid_all_slaves "$bootpart")
|
||||
|
||||
for slave in ${slaves[@]}; do
|
||||
local disk=$(get_disk "$slave")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$slave]="$ptb"
|
||||
done
|
||||
else
|
||||
local disk=$(get_disk "$bootpart")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$bootpart]="$ptb"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function Assumes the boot partition should be marked as active
|
||||
# All other partitions should not have the boot flag set
|
||||
set_active() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to set the boot flag on partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part $dev || { echo "$dev does not contain partition table. Aborting set_active!"; return 1; }
|
||||
done
|
||||
|
||||
# Clear BIOS Bootable Legacy Attribute for GPT drives
|
||||
# In rare cases where a RAID device has slaves on the same block device
|
||||
# Attribute 2 will be cleared for each partition multiple times
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$dev]}"
|
||||
if [[ "$ptb" = GPT ]]; then
|
||||
local disk=$(get_disk "$dev")
|
||||
clear_gpt_attr2 "$disk"
|
||||
fi
|
||||
done
|
||||
|
||||
# Set the boot flag on bootdevs (generated from get_boot_devices)
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$part]}"
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
if sfdisk "$disk" --activate "$partnum" &>/dev/null; then
|
||||
echo "Boot Flag Set - $part"
|
||||
else
|
||||
echo "FAILED to Set the boot flag on $part"
|
||||
exit 3
|
||||
fi
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
if [[ ! -e /usr/bin/sgdisk ]]; then
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable. sgdisk is not found - please install 'gptfdisk' package."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if sgdisk "$disk" --attributes="$partnum":set:2 &>/dev/null; then
|
||||
echo "Attribute Legacy Bios Bootable Set - $part"
|
||||
else
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable on $part"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_mbr() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to install the mbr to a partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part "$dev" || { echo "$dev does not contain partition table. Aborting MBR install."; return 1; }
|
||||
done
|
||||
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
local ptb="${bootdevs[$part]}"
|
||||
|
||||
# We want to install to the root of the block device
|
||||
# If the device is a partition - ABORT!
|
||||
dev_is_part "$disk" && \
|
||||
{ echo "ABORT! MBR installation to partition ($disk)!"; exit 4;}
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
mbrfile="$bios_libpath/mbr.bin"
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
mbrfile="$bios_libpath/gptmbr.bin"
|
||||
fi
|
||||
|
||||
if dd bs=440 count=1 conv=notrunc if="$mbrfile" of="$disk" &> /dev/null; then
|
||||
echo "Installed MBR ($mbrfile) to $disk"
|
||||
else
|
||||
echo "Error Installing MBR ($mbrfile) to $disk"
|
||||
exit 4
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_modules() {
|
||||
# Copy all syslinux *.c32 modules to /boot
|
||||
rm "$bios_bootpath"/*.c32 &> /dev/null
|
||||
cp "$bios_libpath"/*.c32 "$bios_bootpath"/ &> /dev/null
|
||||
|
||||
# Copy / Symlink pci.ids if pci.ids exists on the FS
|
||||
if [[ -f "$pciids_file" ]]; then
|
||||
rm "$bios_bootpath/pci.ids" &> /dev/null
|
||||
cp "$pciids_file" "$bios_bootpath/pci.ids" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
_install() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - installing Syslinux with --raid"
|
||||
"$EXTLINUX" --install "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --install "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (( $? )); then
|
||||
echo "Syslinux BIOS install failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS install successful"
|
||||
fi
|
||||
|
||||
touch "$CHROOT/$bios_autoupdate_file"
|
||||
}
|
||||
|
||||
update() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - updating Syslinux with --raid"
|
||||
"$EXTLINUX" --update "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --update "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (($?)); then
|
||||
echo "Syslinux BIOS update failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS update successful"
|
||||
fi
|
||||
}
|
||||
|
||||
if (( $# == 0 )); then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts "c:uihmas" opt; do
|
||||
case $opt in
|
||||
c)
|
||||
CHROOT=$(readlink -e "$OPTARG")
|
||||
if [[ -z $CHROOT ]]; then
|
||||
echo "error: chroot path ``$OPTARG does not exist";
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
h)
|
||||
USAGE="True"
|
||||
;;
|
||||
i)
|
||||
INSTALL="True"
|
||||
;;
|
||||
u)
|
||||
UPDATE="True"
|
||||
;;
|
||||
m)
|
||||
MBR="True"
|
||||
;;
|
||||
a)
|
||||
SET_ACTIVE="True"
|
||||
;;
|
||||
s)
|
||||
# If AUTOUPDATE_FILE does not exist exit the script
|
||||
if [[ -f $bios_autoupdate_file ]]; then
|
||||
UPDATE="True"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $USAGE ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Display Usage Information if both Install and Update are passed
|
||||
if [[ $INSTALL && $UPDATE ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure only root can run our script
|
||||
if (( $(id -u) != 0 )); then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If a chroot dir is path set variables to reflect chroot
|
||||
if [[ "$CHROOT" ]]; then
|
||||
bios_libpath="$CHROOT$bios_libpath"
|
||||
bios_bootpath="$CHROOT$bios_bootpath"
|
||||
EXTLINUX="$CHROOT$EXTLINUX"
|
||||
fi
|
||||
|
||||
# Exit if no /boot path exists
|
||||
if ( f=("$bios_bootpath"/*); (( ! ${#f[@]} )) ); then
|
||||
echo "Error: $bios_bootpath is empty!"
|
||||
echo "Is /boot mounted?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the boot device if any of these options are passed
|
||||
if [[ $INSTALL || $UPDATE || $SET_ACTIVE || $MBR ]]; then
|
||||
getBoot
|
||||
fi
|
||||
|
||||
# Install or Update
|
||||
if [[ $INSTALL ]]; then
|
||||
_install || exit
|
||||
elif [[ $UPDATE ]]; then
|
||||
update || exit
|
||||
fi
|
||||
|
||||
|
||||
# SET_ACTIVE and MBR
|
||||
if [[ $SET_ACTIVE ]] || [[ $MBR ]]; then
|
||||
get_boot_devices
|
||||
|
||||
if [[ $SET_ACTIVE ]]; then
|
||||
set_active || exit
|
||||
fi
|
||||
|
||||
if [[ $MBR ]]; then
|
||||
install_mbr || exit
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
465
syslinux/syslinux-install_update-arch
Normal file
465
syslinux/syslinux-install_update-arch
Normal file
|
@ -0,0 +1,465 @@
|
|||
#!/usr/bin/bash
|
||||
#
|
||||
# Syslinux Installer / Updater Script (for BIOS only)
|
||||
# Copyright (C) 2011-2013 Matthew Gyurgyik <pyther@pyther.net>
|
||||
# Copyright (C) 2013 Keshav Padram Amburay <(the) (ddoott) (ridikulus) (ddoott) (rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
|
||||
#
|
||||
# This program 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 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
#-----------------
|
||||
# ChangeLog:
|
||||
# 2013-10-23 : Keshav Padram Amburay : Updated script to work with Syslinux 6.02 Arch Linux pkg
|
||||
#-----------------
|
||||
# Exit Codes:
|
||||
# 1 - get_boot_device or other function failed
|
||||
# 2 - install/update failed
|
||||
# 3 - set_active failed
|
||||
# 4 - install_mbr failed
|
||||
#-----------------
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
bios_libpath="/usr/lib/syslinux/bios"
|
||||
bios_bootpath="/boot/syslinux"
|
||||
EXTLINUX="/usr/bin/extlinux"
|
||||
|
||||
bios_autoupdate_file="/boot/syslinux/SYSLINUX_AUTOUPDATE"
|
||||
pciids_file="/usr/share/hwdata/pci.ids"
|
||||
|
||||
## Helper functions ##
|
||||
# Taken from libui-sh
|
||||
# $1 needle
|
||||
# $2 set (array) haystack
|
||||
check_is_in() {
|
||||
local needle="$1" element
|
||||
shift
|
||||
for element; do
|
||||
[[ $element = $needle ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_disk() {
|
||||
local part=$1
|
||||
if [[ ! -b "${part}" ]]; then
|
||||
echo >&2 "error: '$part' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$part" in
|
||||
# catch cases like mmcblk0p1 and loop0p3
|
||||
*[[:digit:]]p[[:digit:]]*)
|
||||
local disk="${part%p[[:digit:]]}" # get everything before p1
|
||||
;;
|
||||
*)
|
||||
local disk="${part%%[[:digit:]]*}"
|
||||
;;
|
||||
esac
|
||||
if [[ ! -b "${disk}" ]]; then
|
||||
echo >&2 "error: '$disk' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
echo $disk
|
||||
}
|
||||
|
||||
# return true when blockdevice is an md raid, otherwise return a unset value
|
||||
# get all devices that are part of raid device $1
|
||||
device_is_raid() {
|
||||
[[ $1 && -f /proc/mdstat ]] || return 1
|
||||
local devmajor=$(stat -c %t "$1")
|
||||
(( devmajor == 9 ))
|
||||
}
|
||||
|
||||
mdraid_all_slaves() {
|
||||
local slave slaves
|
||||
for slave in /sys/class/block/${1##*/}/slaves/*; do
|
||||
source "$slave/uevent"
|
||||
slaves="$slaves/dev/$DEVNAME "
|
||||
unset DEVNAME
|
||||
done
|
||||
echo $slaves
|
||||
}
|
||||
|
||||
# Check /sys/block to see if device is partitioned
|
||||
# If we have a partitioned block device (sda1) /sys/block/sda1/dev will not exist
|
||||
# However, if we have an unpartitioned block device (sda) /sys/block/sda/dev will exist
|
||||
dev_is_part() {
|
||||
# $1 - blockdevice
|
||||
local dev=$1
|
||||
|
||||
# If block device uevent file should be found
|
||||
# If a partition is passed in path shouldn't exist
|
||||
if [[ $dev = *cciss* ]]; then
|
||||
[[ -f /sys/block/cciss\!${dev##*/}/dev ]] && return 1
|
||||
elif [[ $dev = *ida* ]]; then
|
||||
[[ -f /sys/block/ida\!${dev##*/}/dev ]] && return 1
|
||||
else
|
||||
[[ -f /sys/block/${dev##*/}/dev ]] && return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# If EFI PART is present in the first 8 bytes then it must be a GPT disk
|
||||
device_is_gpt() {
|
||||
local partsig=$(dd if="$1" skip=64 bs=8 count=1 2>/dev/null)
|
||||
[[ $partsig = "EFI PART" ]]
|
||||
}
|
||||
|
||||
clear_gpt_attr2() {
|
||||
# $1 - Block Device, no partitions
|
||||
local disk=$1
|
||||
|
||||
# Special Exception for cciss controllers
|
||||
if [[ $disk = *cciss* ]]; then
|
||||
for part in /dev/cciss/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
# Smart 2 Controllers
|
||||
elif [[ $disk = *ida* ]]; then
|
||||
for part in /dev/ida/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
else
|
||||
for part in /sys/block/${disk##*/}/${disk##*/}*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
usage: $0 options
|
||||
|
||||
This script will install or upgrade Syslinux (for BIOS only)
|
||||
|
||||
OPTIONS:
|
||||
-h Show this message
|
||||
-i Install Syslinux
|
||||
-u Update Syslinux
|
||||
-a Set Boot flag on boot partiton
|
||||
-m Install Syslinux MBR
|
||||
-s Updates Syslinux if /boot/syslinux/SYSLINUX_AUTOUPDATE exists
|
||||
|
||||
Arguments Required:
|
||||
-c Chroot install (ex: -c /mnt)
|
||||
|
||||
Example Usage: $0 -i -a -m # (install, set boot flag, install mbr)
|
||||
$0 -u # (update)
|
||||
EOF
|
||||
}
|
||||
|
||||
# Trys to find the partition that /boot resides on
|
||||
# This will either be on /boot or / (root)
|
||||
getBoot() {
|
||||
if [[ ! -d "$bios_bootpath" ]]; then
|
||||
echo "Could not find $bios_bootpath"
|
||||
echo "Is boot mounted? Is Syslinux installed?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
syslinux_fs=(ext2 ext3 ext4 btrfs vfat xfs)
|
||||
|
||||
# Use DATA from findmnt see rc.sysint for more info
|
||||
if [[ -f /proc/self/mountinfo ]]; then
|
||||
read rootdev rootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/")
|
||||
read bootdev bootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/boot")
|
||||
else
|
||||
echo "Could not find /proc/self/mountinfo"
|
||||
echo "Are you running a kernel greater than 2.6.24?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $bootfs ]]; then
|
||||
if ! check_is_in "$bootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/boot file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="boot"
|
||||
bootpart="$(readlink -f "$bootdev")"
|
||||
elif [[ $rootfs ]]; then
|
||||
if ! check_is_in "$rootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/ (root) file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="root"
|
||||
bootpart="$(readlink -f "$rootdev")"
|
||||
else
|
||||
echo "Could not find filesystem on / (root) or /boot."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# We store the partition table type either gpt or mbr in var ptb
|
||||
# In rare cases a user could have one raid disk using mbr and another using gpt
|
||||
# In such cases we accept that the output may be incomplete
|
||||
|
||||
# Calls get_ptb() for $bootpart or for all device in RAID
|
||||
declare -A bootdevs
|
||||
get_boot_devices() {
|
||||
if device_is_raid "$bootpart"; then
|
||||
slaves=$(mdraid_all_slaves "$bootpart")
|
||||
|
||||
for slave in ${slaves[@]}; do
|
||||
local disk=$(get_disk "$slave")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$slave]="$ptb"
|
||||
done
|
||||
else
|
||||
local disk=$(get_disk "$bootpart")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$bootpart]="$ptb"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function Assumes the boot partition should be marked as active
|
||||
# All other partitions should not have the boot flag set
|
||||
set_active() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to set the boot flag on partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part $dev || { echo "$dev does not contain partition table. Aborting set_active!"; return 1; }
|
||||
done
|
||||
|
||||
# Clear BIOS Bootable Legacy Attribute for GPT drives
|
||||
# In rare cases where a RAID device has slaves on the same block device
|
||||
# Attribute 2 will be cleared for each partition multiple times
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$dev]}"
|
||||
if [[ "$ptb" = GPT ]]; then
|
||||
local disk=$(get_disk "$dev")
|
||||
clear_gpt_attr2 "$disk"
|
||||
fi
|
||||
done
|
||||
|
||||
# Set the boot flag on bootdevs (generated from get_boot_devices)
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$part]}"
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
if sfdisk "$disk" --activate "$partnum" &>/dev/null; then
|
||||
echo "Boot Flag Set - $part"
|
||||
else
|
||||
echo "FAILED to Set the boot flag on $part"
|
||||
exit 3
|
||||
fi
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
if [[ ! -e /usr/bin/sgdisk ]]; then
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable. sgdisk is not found - please install 'gptfdisk' package."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if sgdisk "$disk" --attributes="$partnum":set:2 &>/dev/null; then
|
||||
echo "Attribute Legacy Bios Bootable Set - $part"
|
||||
else
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable on $part"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_mbr() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to install the mbr to a partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part "$dev" || { echo "$dev does not contain partition table. Aborting MBR install."; return 1; }
|
||||
done
|
||||
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
local ptb="${bootdevs[$part]}"
|
||||
|
||||
# We want to install to the root of the block device
|
||||
# If the device is a partition - ABORT!
|
||||
dev_is_part "$disk" && \
|
||||
{ echo "ABORT! MBR installation to partition ($disk)!"; exit 4;}
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
mbrfile="$bios_libpath/mbr.bin"
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
mbrfile="$bios_libpath/gptmbr.bin"
|
||||
fi
|
||||
|
||||
if dd bs=440 count=1 conv=notrunc if="$mbrfile" of="$disk" &> /dev/null; then
|
||||
echo "Installed MBR ($mbrfile) to $disk"
|
||||
else
|
||||
echo "Error Installing MBR ($mbrfile) to $disk"
|
||||
exit 4
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_modules() {
|
||||
# Copy all syslinux *.c32 modules to /boot
|
||||
rm "$bios_bootpath"/*.c32 &> /dev/null
|
||||
cp "$bios_libpath"/*.c32 "$bios_bootpath"/ &> /dev/null
|
||||
|
||||
# Copy / Symlink pci.ids if pci.ids exists on the FS
|
||||
if [[ -f "$pciids_file" ]]; then
|
||||
rm "$bios_bootpath/pci.ids" &> /dev/null
|
||||
cp "$pciids_file" "$bios_bootpath/pci.ids" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
_install() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - installing Syslinux with --raid"
|
||||
"$EXTLINUX" --install "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --install "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (( $? )); then
|
||||
echo "Syslinux BIOS install failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS install successful"
|
||||
fi
|
||||
|
||||
touch "$CHROOT/$bios_autoupdate_file"
|
||||
}
|
||||
|
||||
update() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - updating Syslinux with --raid"
|
||||
"$EXTLINUX" --update "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --update "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (($?)); then
|
||||
echo "Syslinux BIOS update failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS update successful"
|
||||
fi
|
||||
}
|
||||
|
||||
if (( $# == 0 )); then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts "c:uihmas" opt; do
|
||||
case $opt in
|
||||
c)
|
||||
CHROOT=$(readlink -e "$OPTARG")
|
||||
if [[ -z $CHROOT ]]; then
|
||||
echo "error: chroot path ``$OPTARG does not exist";
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
h)
|
||||
USAGE="True"
|
||||
;;
|
||||
i)
|
||||
INSTALL="True"
|
||||
;;
|
||||
u)
|
||||
UPDATE="True"
|
||||
;;
|
||||
m)
|
||||
MBR="True"
|
||||
;;
|
||||
a)
|
||||
SET_ACTIVE="True"
|
||||
;;
|
||||
s)
|
||||
# If AUTOUPDATE_FILE does not exist exit the script
|
||||
if [[ -f $bios_autoupdate_file ]]; then
|
||||
UPDATE="True"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $USAGE ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Display Usage Information if both Install and Update are passed
|
||||
if [[ $INSTALL && $UPDATE ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure only root can run our script
|
||||
if (( $(id -u) != 0 )); then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If a chroot dir is path set variables to reflect chroot
|
||||
if [[ "$CHROOT" ]]; then
|
||||
bios_libpath="$CHROOT$bios_libpath"
|
||||
bios_bootpath="$CHROOT$bios_bootpath"
|
||||
EXTLINUX="$CHROOT$EXTLINUX"
|
||||
fi
|
||||
|
||||
# Exit if no /boot path exists
|
||||
if ( f=("$bios_bootpath"/*); (( ! ${#f[@]} )) ); then
|
||||
echo "Error: $bios_bootpath is empty!"
|
||||
echo "Is /boot mounted?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the boot device if any of these options are passed
|
||||
if [[ $INSTALL || $UPDATE || $SET_ACTIVE || $MBR ]]; then
|
||||
getBoot
|
||||
fi
|
||||
|
||||
# Install or Update
|
||||
if [[ $INSTALL ]]; then
|
||||
_install || exit
|
||||
elif [[ $UPDATE ]]; then
|
||||
update || exit
|
||||
fi
|
||||
|
||||
|
||||
# SET_ACTIVE and MBR
|
||||
if [[ $SET_ACTIVE ]] || [[ $MBR ]]; then
|
||||
get_boot_devices
|
||||
|
||||
if [[ $SET_ACTIVE ]]; then
|
||||
set_active || exit
|
||||
fi
|
||||
|
||||
if [[ $MBR ]]; then
|
||||
install_mbr || exit
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
465
syslinux/syslinux-install_update-oba
Normal file
465
syslinux/syslinux-install_update-oba
Normal file
|
@ -0,0 +1,465 @@
|
|||
#!/usr/bin/bash
|
||||
#
|
||||
# Syslinux Installer / Updater Script (for BIOS only)
|
||||
# Copyright (C) 2011-2013 Matthew Gyurgyik <pyther@pyther.net>
|
||||
# Copyright (C) 2013 Keshav Padram Amburay <(the) (ddoott) (ridikulus) (ddoott) (rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
|
||||
#
|
||||
# This program 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 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
#-----------------
|
||||
# ChangeLog:
|
||||
# 2013-10-23 : Keshav Padram Amburay : Updated script to work with Syslinux 6.02 Obarun pkg
|
||||
#-----------------
|
||||
# Exit Codes:
|
||||
# 1 - get_boot_device or other function failed
|
||||
# 2 - install/update failed
|
||||
# 3 - set_active failed
|
||||
# 4 - install_mbr failed
|
||||
#-----------------
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
bios_libpath="/usr/lib/syslinux/bios"
|
||||
bios_bootpath="/boot/syslinux"
|
||||
EXTLINUX="/usr/bin/extlinux"
|
||||
|
||||
bios_autoupdate_file="/boot/syslinux/SYSLINUX_AUTOUPDATE"
|
||||
pciids_file="/usr/share/hwdata/pci.ids"
|
||||
|
||||
## Helper functions ##
|
||||
# Taken from libui-sh
|
||||
# $1 needle
|
||||
# $2 set (array) haystack
|
||||
check_is_in() {
|
||||
local needle="$1" element
|
||||
shift
|
||||
for element; do
|
||||
[[ $element = $needle ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_disk() {
|
||||
local part=$1
|
||||
if [[ ! -b "${part}" ]]; then
|
||||
echo >&2 "error: '$part' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$part" in
|
||||
*[[:digit:]]p[[:digit:]]*)
|
||||
local disk="${part%%p$partnum}" # get everything before p1
|
||||
;;
|
||||
*)
|
||||
local disk="${part%%[[:digit:]]*}"
|
||||
;;
|
||||
esac
|
||||
if [[ ! -b "${disk}" ]]; then
|
||||
echo >&2 "error: '$disk' is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
echo $disk
|
||||
}
|
||||
|
||||
# return true when blockdevice is an md raid, otherwise return a unset value
|
||||
# get all devices that are part of raid device $1
|
||||
device_is_raid() {
|
||||
[[ $1 && -f /proc/mdstat ]] || return 1
|
||||
local devmajor=$(stat -c %t "$1")
|
||||
(( devmajor == 9 ))
|
||||
}
|
||||
|
||||
mdraid_all_slaves() {
|
||||
local slave slaves
|
||||
for slave in /sys/class/block/${1##*/}/slaves/*; do
|
||||
source "$slave/uevent"
|
||||
slaves="$slaves/dev/$DEVNAME "
|
||||
unset DEVNAME
|
||||
done
|
||||
echo $slaves
|
||||
}
|
||||
|
||||
# Check /sys/block to see if device is partitioned
|
||||
# If we have a partitioned block device (sda1) /sys/block/sda1/dev will not exist
|
||||
# However, if we have an unpartitioned block device (sda) /sys/block/sda/dev will exist
|
||||
dev_is_part() {
|
||||
# $1 - blockdevice
|
||||
local dev=$1
|
||||
|
||||
# If block device uevent file should be found
|
||||
# If a partition is passed in path shouldn't exist
|
||||
if [[ $dev = *cciss* ]]; then
|
||||
[[ -f /sys/block/cciss\!${dev##*/}/dev ]] && return 1
|
||||
elif [[ $dev = *ida* ]]; then
|
||||
[[ -f /sys/block/ida\!${dev##*/}/dev ]] && return 1
|
||||
else
|
||||
[[ -f /sys/block/${dev##*/}/dev ]] && return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# If EFI PART is present in the first 8 bytes then it must be a GPT disk
|
||||
device_is_gpt() {
|
||||
local partsig=$(dd if="$1" skip=64 bs=8 count=1 2>/dev/null)
|
||||
[[ $partsig = "EFI PART" ]]
|
||||
}
|
||||
|
||||
clear_gpt_attr2() {
|
||||
# $1 - Block Device, no partitions
|
||||
local disk=$1
|
||||
|
||||
# Special Exception for cciss controllers
|
||||
if [[ $disk = *cciss* ]]; then
|
||||
for part in /dev/cciss/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
# Smart 2 Controllers
|
||||
elif [[ $disk = *ida* ]]; then
|
||||
for part in /dev/ida/${disk##*/}*p*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
else
|
||||
for part in /sys/block/${disk##*/}/${disk##*/}*; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
|
||||
done
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
usage: $0 options
|
||||
|
||||
This script will install or upgrade Syslinux (for BIOS only)
|
||||
|
||||
OPTIONS:
|
||||
-h Show this message
|
||||
-i Install Syslinux
|
||||
-u Update Syslinux
|
||||
-a Set Boot flag on boot partiton
|
||||
-m Install Syslinux MBR
|
||||
-s Updates Syslinux if /boot/syslinux/SYSLINUX_AUTOUPDATE exists
|
||||
|
||||
Arguments Required:
|
||||
-c Chroot install (ex: -c /mnt)
|
||||
|
||||
Example Usage: $0 -i -a -m # (install, set boot flag, install mbr)
|
||||
$0 -u # (update)
|
||||
EOF
|
||||
}
|
||||
|
||||
# Trys to find the partition that /boot resides on
|
||||
# This will either be on /boot or / (root)
|
||||
getBoot() {
|
||||
if [[ ! -d "$bios_bootpath" ]]; then
|
||||
echo "Could not find $bios_bootpath"
|
||||
echo "Is boot mounted? Is Syslinux installed?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
syslinux_fs=(ext2 ext3 ext4 btrfs vfat xfs)
|
||||
|
||||
# Use DATA from findmnt see rc.sysint for more info
|
||||
if [[ -f /proc/self/mountinfo ]]; then
|
||||
read rootdev rootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/")
|
||||
read bootdev bootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/boot")
|
||||
else
|
||||
echo "Could not find /proc/self/mountinfo"
|
||||
echo "Are you running a kernel greater than 2.6.24?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $bootfs ]]; then
|
||||
if ! check_is_in "$bootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/boot file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="boot"
|
||||
bootpart="$(readlink -f "$bootdev")"
|
||||
elif [[ $rootfs ]]; then
|
||||
if ! check_is_in "$rootfs" "${syslinux_fs[@]}"; then
|
||||
echo "/ (root) file system is not supported by Syslinux"
|
||||
exit 1
|
||||
fi
|
||||
boot="root"
|
||||
bootpart="$(readlink -f "$rootdev")"
|
||||
else
|
||||
echo "Could not find filesystem on / (root) or /boot."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# We store the partition table type either gpt or mbr in var ptb
|
||||
# In rare cases a user could have one raid disk using mbr and another using gpt
|
||||
# In such cases we accept that the output may be incomplete
|
||||
|
||||
# Calls get_ptb() for $bootpart or for all device in RAID
|
||||
declare -A bootdevs
|
||||
get_boot_devices() {
|
||||
if device_is_raid "$bootpart"; then
|
||||
slaves=$(mdraid_all_slaves "$bootpart")
|
||||
|
||||
for slave in ${slaves[@]}; do
|
||||
local disk=$(get_disk "$slave")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$slave]="$ptb"
|
||||
done
|
||||
else
|
||||
local disk=$(get_disk "$bootpart")
|
||||
device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
|
||||
bootdevs[$bootpart]="$ptb"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function Assumes the boot partition should be marked as active
|
||||
# All other partitions should not have the boot flag set
|
||||
set_active() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to set the boot flag on partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part $dev || { echo "$dev does not contain partition table. Aborting set_active!"; return 1; }
|
||||
done
|
||||
|
||||
# Clear BIOS Bootable Legacy Attribute for GPT drives
|
||||
# In rare cases where a RAID device has slaves on the same block device
|
||||
# Attribute 2 will be cleared for each partition multiple times
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$dev]}"
|
||||
if [[ "$ptb" = GPT ]]; then
|
||||
local disk=$(get_disk "$dev")
|
||||
clear_gpt_attr2 "$disk"
|
||||
fi
|
||||
done
|
||||
|
||||
# Set the boot flag on bootdevs (generated from get_boot_devices)
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local ptb="${bootdevs[$part]}"
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
if sfdisk "$disk" --activate "$partnum" &>/dev/null; then
|
||||
echo "Boot Flag Set - $part"
|
||||
else
|
||||
echo "FAILED to Set the boot flag on $part"
|
||||
exit 3
|
||||
fi
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
if [[ ! -e /usr/bin/sgdisk ]]; then
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable. sgdisk is not found - please install 'gptfdisk' package."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if sgdisk "$disk" --attributes="$partnum":set:2 &>/dev/null; then
|
||||
echo "Attribute Legacy Bios Bootable Set - $part"
|
||||
else
|
||||
echo "FAILED to set attribute Legacy BIOS Bootable on $part"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_mbr() {
|
||||
# If any bootdev is a block device without partitions bail
|
||||
# we want to install the mbr to a partitioned disk
|
||||
for dev in "${!bootdevs[@]}"; do
|
||||
dev_is_part "$dev" || { echo "$dev does not contain partition table. Aborting MBR install."; return 1; }
|
||||
done
|
||||
|
||||
for part in "${!bootdevs[@]}"; do
|
||||
local partnum="${part##*[[:alpha:]]}"
|
||||
local disk=$(get_disk "$part")
|
||||
local ptb="${bootdevs[$part]}"
|
||||
|
||||
# We want to install to the root of the block device
|
||||
# If the device is a partition - ABORT!
|
||||
dev_is_part "$disk" && \
|
||||
{ echo "ABORT! MBR installation to partition ($disk)!"; exit 4;}
|
||||
|
||||
if [[ "$ptb" = MBR ]]; then
|
||||
mbrfile="$bios_libpath/mbr.bin"
|
||||
elif [[ "$ptb" = GPT ]]; then
|
||||
mbrfile="$bios_libpath/gptmbr.bin"
|
||||
fi
|
||||
|
||||
if dd bs=440 count=1 conv=notrunc if="$mbrfile" of="$disk" &> /dev/null; then
|
||||
echo "Installed MBR ($mbrfile) to $disk"
|
||||
else
|
||||
echo "Error Installing MBR ($mbrfile) to $disk"
|
||||
exit 4
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
install_modules() {
|
||||
# Copy all syslinux *.c32 modules to /boot
|
||||
rm "$bios_bootpath"/*.c32 &> /dev/null
|
||||
cp "$bios_libpath"/*.c32 "$bios_bootpath"/ &> /dev/null
|
||||
|
||||
# Copy / Symlink pci.ids if pci.ids exists on the FS
|
||||
if [[ -f "$pciids_file" ]]; then
|
||||
rm "$bios_bootpath/pci.ids" &> /dev/null
|
||||
cp "$pciids_file" "$bios_bootpath/pci.ids" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
_install() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - installing Syslinux with --raid"
|
||||
"$EXTLINUX" --install "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --install "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (( $? )); then
|
||||
echo "Syslinux BIOS install failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS install successful"
|
||||
fi
|
||||
|
||||
touch "$CHROOT/$bios_autoupdate_file"
|
||||
}
|
||||
|
||||
update() {
|
||||
install_modules
|
||||
|
||||
if device_is_raid "$bootpart" ; then
|
||||
echo "Detected RAID on /boot - updating Syslinux with --raid"
|
||||
"$EXTLINUX" --update "$bios_bootpath" --raid &> /dev/null
|
||||
else
|
||||
"$EXTLINUX" --update "$bios_bootpath" &> /dev/null
|
||||
fi
|
||||
|
||||
if (($?)); then
|
||||
echo "Syslinux BIOS update failed"
|
||||
exit 2
|
||||
else
|
||||
echo "Syslinux BIOS update successful"
|
||||
fi
|
||||
}
|
||||
|
||||
if (( $# == 0 )); then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts "c:uihmas" opt; do
|
||||
case $opt in
|
||||
c)
|
||||
CHROOT=$(readlink -e "$OPTARG")
|
||||
if [[ -z $CHROOT ]]; then
|
||||
echo "error: chroot path ``$OPTARG does not exist";
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
h)
|
||||
USAGE="True"
|
||||
;;
|
||||
i)
|
||||
INSTALL="True"
|
||||
;;
|
||||
u)
|
||||
UPDATE="True"
|
||||
;;
|
||||
m)
|
||||
MBR="True"
|
||||
;;
|
||||
a)
|
||||
SET_ACTIVE="True"
|
||||
;;
|
||||
s)
|
||||
# If AUTOUPDATE_FILE does not exist exit the script
|
||||
if [[ -f $bios_autoupdate_file ]]; then
|
||||
UPDATE="True"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $USAGE ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Display Usage Information if both Install and Update are passed
|
||||
if [[ $INSTALL && $UPDATE ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure only root can run our script
|
||||
if (( $(id -u) != 0 )); then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If a chroot dir is path set variables to reflect chroot
|
||||
if [[ "$CHROOT" ]]; then
|
||||
bios_libpath="$CHROOT$bios_libpath"
|
||||
bios_bootpath="$CHROOT$bios_bootpath"
|
||||
EXTLINUX="$CHROOT$EXTLINUX"
|
||||
fi
|
||||
|
||||
# Exit if no /boot path exists
|
||||
if ( f=("$bios_bootpath"/*); (( ! ${#f[@]} )) ); then
|
||||
echo "Error: $bios_bootpath is empty!"
|
||||
echo "Is /boot mounted?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the boot device if any of these options are passed
|
||||
if [[ $INSTALL || $UPDATE || $SET_ACTIVE || $MBR ]]; then
|
||||
getBoot
|
||||
fi
|
||||
|
||||
# Install or Update
|
||||
if [[ $INSTALL ]]; then
|
||||
_install || exit
|
||||
elif [[ $UPDATE ]]; then
|
||||
update || exit
|
||||
fi
|
||||
|
||||
|
||||
# SET_ACTIVE and MBR
|
||||
if [[ $SET_ACTIVE ]] || [[ $MBR ]]; then
|
||||
get_boot_devices
|
||||
|
||||
if [[ $SET_ACTIVE ]]; then
|
||||
set_active || exit
|
||||
fi
|
||||
|
||||
if [[ $MBR ]]; then
|
||||
install_mbr || exit
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
87
syslinux/syslinux.cfg
Normal file
87
syslinux/syslinux.cfg
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Config file for Syslinux -
|
||||
# /boot/syslinux/syslinux.cfg
|
||||
#
|
||||
# Comboot modules:
|
||||
# * menu.c32 - provides a text menu
|
||||
# * vesamenu.c32 - provides a graphical menu
|
||||
# * chain.c32 - chainload MBRs, partition boot sectors, Windows bootloaders
|
||||
# * hdt.c32 - hardware detection tool
|
||||
# * reboot.c32 - reboots the system
|
||||
#
|
||||
# To Use: Copy the respective files from /usr/lib/syslinux to /boot/syslinux.
|
||||
# If /usr and /boot are on the same file system, symlink the files instead
|
||||
# of copying them.
|
||||
#
|
||||
# If you do not use a menu, a 'boot:' prompt will be shown and the system
|
||||
# will boot automatically after 5 seconds.
|
||||
#
|
||||
# Please review the wiki: https://wiki.archlinux.org/index.php/Syslinux
|
||||
# The wiki provides further configuration examples
|
||||
|
||||
DEFAULT joborun
|
||||
PROMPT 0 # Set to 1 if you always want to display the boot: prompt
|
||||
TIMEOUT 50
|
||||
# You can create syslinux keymaps with the keytab-lilo tool
|
||||
#KBDMAP de.ktl
|
||||
|
||||
# Menu Configuration
|
||||
# Either menu.c32 or vesamenu32.c32 must be copied to /boot/syslinux
|
||||
#UI menu.c32
|
||||
UI vesamenu.c32
|
||||
|
||||
MENU WIDTH 80
|
||||
MENU MARGIN 4
|
||||
MENU ROWS 8
|
||||
MENU VSHIFT 10
|
||||
MENU TABMSGROW 14
|
||||
MENU CMDLINEROW 16
|
||||
MENU HELPMSGROW 16
|
||||
MENU HELPMSGENDROW 30
|
||||
|
||||
# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
|
||||
MENU TITLE joborun
|
||||
MENU BACKGROUND splash.png
|
||||
MENU COLOR border 30;44 #40ffffff #a0000000 std
|
||||
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
|
||||
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
|
||||
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
|
||||
MENU COLOR help 37;40 #c0ffffff #a0000000 std
|
||||
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
|
||||
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
|
||||
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
|
||||
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
|
||||
|
||||
# boot sections follow
|
||||
#
|
||||
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
|
||||
#
|
||||
#-*
|
||||
|
||||
LABEL joborun
|
||||
MENU LABEL joborun
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 ro
|
||||
INITRD ../initramfs-linux.img
|
||||
|
||||
LABEL joborunfallback
|
||||
MENU LABEL joborun Fallback
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 ro
|
||||
INITRD ../initramfs-linux-fallback.img
|
||||
|
||||
#LABEL windows
|
||||
# MENU LABEL Windows
|
||||
# COM32 chain.c32
|
||||
# APPEND hd0 1
|
||||
|
||||
LABEL hdt
|
||||
MENU LABEL HDT (Hardware Detection Tool)
|
||||
COM32 hdt.c32
|
||||
|
||||
LABEL reboot
|
||||
MENU LABEL Reboot
|
||||
COM32 reboot.c32
|
||||
|
||||
LABEL poweroff
|
||||
MENU LABEL Poweroff
|
||||
COM32 poweroff.c32
|
78
syslinux/syslinux.cfg-arch
Normal file
78
syslinux/syslinux.cfg-arch
Normal file
|
@ -0,0 +1,78 @@
|
|||
# Config file for Syslinux -
|
||||
# /boot/syslinux/syslinux.cfg
|
||||
#
|
||||
# Comboot modules:
|
||||
# * menu.c32 - provides a text menu
|
||||
# * vesamenu.c32 - provides a graphical menu
|
||||
# * chain.c32 - chainload MBRs, partition boot sectors, Windows bootloaders
|
||||
# * hdt.c32 - hardware detection tool
|
||||
# * reboot.c32 - reboots the system
|
||||
#
|
||||
# To Use: Copy the respective files from /usr/lib/syslinux to /boot/syslinux.
|
||||
# If /usr and /boot are on the same file system, symlink the files instead
|
||||
# of copying them.
|
||||
#
|
||||
# If you do not use a menu, a 'boot:' prompt will be shown and the system
|
||||
# will boot automatically after 5 seconds.
|
||||
#
|
||||
# Please review the wiki: https://wiki.archlinux.org/index.php/Syslinux
|
||||
# The wiki provides further configuration examples
|
||||
|
||||
DEFAULT arch
|
||||
PROMPT 0 # Set to 1 if you always want to display the boot: prompt
|
||||
TIMEOUT 50
|
||||
# You can create syslinux keymaps with the keytab-lilo tool
|
||||
#KBDMAP de.ktl
|
||||
|
||||
# Menu Configuration
|
||||
# Either menu.c32 or vesamenu32.c32 must be copied to /boot/syslinux
|
||||
UI menu.c32
|
||||
#UI vesamenu.c32
|
||||
|
||||
# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
|
||||
MENU TITLE Arch Linux
|
||||
#MENU BACKGROUND splash.png
|
||||
MENU COLOR border 30;44 #40ffffff #a0000000 std
|
||||
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
|
||||
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
|
||||
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
|
||||
MENU COLOR help 37;40 #c0ffffff #a0000000 std
|
||||
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
|
||||
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
|
||||
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
|
||||
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
|
||||
|
||||
# boot sections follow
|
||||
#
|
||||
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
|
||||
#
|
||||
#-*
|
||||
|
||||
LABEL arch
|
||||
MENU LABEL Arch Linux
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 rw
|
||||
INITRD ../initramfs-linux.img
|
||||
|
||||
LABEL archfallback
|
||||
MENU LABEL Arch Linux Fallback
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 rw
|
||||
INITRD ../initramfs-linux-fallback.img
|
||||
|
||||
#LABEL windows
|
||||
# MENU LABEL Windows
|
||||
# COM32 chain.c32
|
||||
# APPEND hd0 1
|
||||
|
||||
LABEL hdt
|
||||
MENU LABEL HDT (Hardware Detection Tool)
|
||||
COM32 hdt.c32
|
||||
|
||||
LABEL reboot
|
||||
MENU LABEL Reboot
|
||||
COM32 reboot.c32
|
||||
|
||||
LABEL poweroff
|
||||
MENU LABEL Poweroff
|
||||
COM32 poweroff.c32
|
87
syslinux/syslinux.cfg-oba
Normal file
87
syslinux/syslinux.cfg-oba
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Config file for Syslinux -
|
||||
# /boot/syslinux/syslinux.cfg
|
||||
#
|
||||
# Comboot modules:
|
||||
# * menu.c32 - provides a text menu
|
||||
# * vesamenu.c32 - provides a graphical menu
|
||||
# * chain.c32 - chainload MBRs, partition boot sectors, Windows bootloaders
|
||||
# * hdt.c32 - hardware detection tool
|
||||
# * reboot.c32 - reboots the system
|
||||
#
|
||||
# To Use: Copy the respective files from /usr/lib/syslinux to /boot/syslinux.
|
||||
# If /usr and /boot are on the same file system, symlink the files instead
|
||||
# of copying them.
|
||||
#
|
||||
# If you do not use a menu, a 'boot:' prompt will be shown and the system
|
||||
# will boot automatically after 5 seconds.
|
||||
#
|
||||
# Please review the wiki: https://wiki.archlinux.org/index.php/Syslinux
|
||||
# The wiki provides further configuration examples
|
||||
|
||||
DEFAULT obarun
|
||||
PROMPT 0 # Set to 1 if you always want to display the boot: prompt
|
||||
TIMEOUT 50
|
||||
# You can create syslinux keymaps with the keytab-lilo tool
|
||||
#KBDMAP de.ktl
|
||||
|
||||
# Menu Configuration
|
||||
# Either menu.c32 or vesamenu32.c32 must be copied to /boot/syslinux
|
||||
#UI menu.c32
|
||||
UI vesamenu.c32
|
||||
|
||||
MENU WIDTH 78
|
||||
MENU MARGIN 4
|
||||
MENU ROWS 7
|
||||
MENU VSHIFT 10
|
||||
MENU TABMSGROW 14
|
||||
MENU CMDLINEROW 14
|
||||
MENU HELPMSGROW 16
|
||||
MENU HELPMSGENDROW 29
|
||||
|
||||
# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
|
||||
MENU TITLE Obarun
|
||||
MENU BACKGROUND splash.png
|
||||
MENU COLOR border 30;44 #40ffffff #a0000000 std
|
||||
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
|
||||
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
|
||||
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
|
||||
MENU COLOR help 37;40 #c0ffffff #a0000000 std
|
||||
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
|
||||
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
|
||||
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
|
||||
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
|
||||
|
||||
# boot sections follow
|
||||
#
|
||||
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
|
||||
#
|
||||
#-*
|
||||
|
||||
LABEL obarun
|
||||
MENU LABEL Obarun
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 ro
|
||||
INITRD ../initramfs-linux.img
|
||||
|
||||
LABEL obarunfallback
|
||||
MENU LABEL Obarun Fallback
|
||||
LINUX ../vmlinuz-linux
|
||||
APPEND root=/dev/sda3 ro
|
||||
INITRD ../initramfs-linux-fallback.img
|
||||
|
||||
#LABEL windows
|
||||
# MENU LABEL Windows
|
||||
# COM32 chain.c32
|
||||
# APPEND hd0 1
|
||||
|
||||
LABEL hdt
|
||||
MENU LABEL HDT (Hardware Detection Tool)
|
||||
COM32 hdt.c32
|
||||
|
||||
LABEL reboot
|
||||
MENU LABEL Reboot
|
||||
COM32 reboot.c32
|
||||
|
||||
LABEL poweroff
|
||||
MENU LABEL Poweroff
|
||||
COM32 poweroff.c32
|
32
syslinux/syslinux.install
Normal file
32
syslinux/syslinux.install
Normal file
|
@ -0,0 +1,32 @@
|
|||
show_efi_msg() {
|
||||
cat << EOF
|
||||
|
||||
==> For setting up Syslinux EFI follow
|
||||
https://wiki.archlinux.org/index.php/Syslinux#UEFI_Systems
|
||||
|
||||
==> The syslinux-install_update script does not currently support EFI install
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
show_bios_autoupdate_msg() {
|
||||
cat << EOF
|
||||
|
||||
==> For setting up Syslinux BIOS using the syslinux-install_update script follow
|
||||
https://wiki.archlinux.org/index.php/Syslinux#Automatic_Install
|
||||
EOF
|
||||
}
|
||||
|
||||
post_install() {
|
||||
[ -f /boot/syslinux/SYSLINUX_AUTOUPDATE ] || show_bios_autoupdate_msg
|
||||
[ -d /sys/firmware/efi ] && show_efi_msg
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
## auto-update syslinux if /boot/syslinux/SYSLINUX_AUTOUPDATE exists
|
||||
/usr/bin/syslinux-install_update -s
|
||||
|
||||
post_install
|
||||
}
|
6
syslinux/time
Normal file
6
syslinux/time
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
|
||||
real 3m52.922s
|
||||
user 3m10.685s
|
||||
sys 0m30.335s
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue