cross/systemd-boot-x86: new aport
fixes #3711 Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6506
This commit is contained in:
parent
22d18cc39b
commit
f80528b498
4 changed files with 328 additions and 0 deletions
119
cross/systemd-boot-x86/0001-patch-wchar_t-for-musl.patch
Normal file
119
cross/systemd-boot-x86/0001-patch-wchar_t-for-musl.patch
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
From 87e8a19b2a9a15352d849918d995cea92ba287bb Mon Sep 17 00:00:00 2001
|
||||
From: Struan Robertson <contact@struanrobertson.co.uk>
|
||||
Date: Mon, 16 Dec 2024 13:48:25 +0000
|
||||
Subject: [PATCH] patch wchar_t for musl
|
||||
|
||||
---
|
||||
src/boot/efi-string.c | 10 +++++-----
|
||||
src/boot/efi.h | 6 +++---
|
||||
src/boot/fuzz-efi-printf.c | 2 +-
|
||||
src/boot/test-efi-string.c | 2 +-
|
||||
4 files changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/boot/efi-string.c b/src/boot/efi-string.c
|
||||
index aee98a8..314d14d 100644
|
||||
--- a/src/boot/efi-string.c
|
||||
+++ b/src/boot/efi-string.c
|
||||
@@ -570,7 +570,7 @@ typedef struct {
|
||||
bool have_field_width;
|
||||
|
||||
const char *str;
|
||||
- const wchar_t *wstr;
|
||||
+ const uint16_t *wstr;
|
||||
|
||||
/* For numbers. */
|
||||
bool is_signed;
|
||||
@@ -631,7 +631,7 @@ static bool push_str(FormatContext *ctx, SpecifierContext *sp) {
|
||||
push_padding(ctx, ' ', sp->padded_len);
|
||||
|
||||
/* In userspace unit tests we cannot just memcpy() the wide string. */
|
||||
- if (sp->wstr && sizeof(wchar_t) == sizeof(char16_t)) {
|
||||
+ if (sp->wstr && sizeof(uint16_t) == sizeof(char16_t)) {
|
||||
memcpy(ctx->buf + ctx->n, sp->wstr, sp->len * sizeof(*sp->wstr));
|
||||
ctx->n += sp->len;
|
||||
} else {
|
||||
@@ -725,7 +725,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) {
|
||||
* int in vararg functions, which is why we fetch only ints for any such types. The compiler would
|
||||
* otherwise warn about fetching smaller types. */
|
||||
assert_cc(sizeof(int) == 4);
|
||||
- assert_cc(sizeof(wchar_t) <= sizeof(int));
|
||||
+ assert_cc(sizeof(uint16_t) <= sizeof(int));
|
||||
assert_cc(sizeof(intmax_t) <= sizeof(long long));
|
||||
|
||||
assert(ctx);
|
||||
@@ -820,13 +820,13 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) {
|
||||
return push_str(ctx, sp);
|
||||
|
||||
case 'c':
|
||||
- sp->wstr = &(wchar_t){ va_arg(ctx->ap, int) };
|
||||
+ sp->wstr = &(uint16_t){ va_arg(ctx->ap, int) };
|
||||
sp->len = 1;
|
||||
return push_str(ctx, sp);
|
||||
|
||||
case 's':
|
||||
if (sp->long_arg) {
|
||||
- sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)";
|
||||
+ sp->wstr = va_arg(ctx->ap, const uint16_t *) ?: L"(null)";
|
||||
sp->len = wcsnlen(sp->wstr, sp->len);
|
||||
} else {
|
||||
sp->str = va_arg(ctx->ap, const char *) ?: "(null)";
|
||||
diff --git a/src/boot/efi.h b/src/boot/efi.h
|
||||
index e104263..d6c1aa4 100644
|
||||
--- a/src/boot/efi.h
|
||||
+++ b/src/boot/efi.h
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#if SD_BOOT
|
||||
/* uchar.h/wchar.h are not suitable for freestanding environments. */
|
||||
-typedef __WCHAR_TYPE__ wchar_t;
|
||||
+typedef __WCHAR_TYPE__ uint16_t;
|
||||
typedef __CHAR16_TYPE__ char16_t;
|
||||
typedef __CHAR32_TYPE__ char32_t;
|
||||
|
||||
@@ -22,7 +22,7 @@ assert_cc(sizeof(uint8_t) == 1);
|
||||
assert_cc(sizeof(uint16_t) == 2);
|
||||
assert_cc(sizeof(uint32_t) == 4);
|
||||
assert_cc(sizeof(uint64_t) == 8);
|
||||
-assert_cc(sizeof(wchar_t) == 2);
|
||||
+assert_cc(sizeof(uint16_t) == 2);
|
||||
assert_cc(sizeof(char16_t) == 2);
|
||||
assert_cc(sizeof(char32_t) == 4);
|
||||
assert_cc(sizeof(size_t) == sizeof(void *));
|
||||
@@ -32,7 +32,7 @@ assert_cc(alignof(uint8_t) == 1);
|
||||
assert_cc(alignof(uint16_t) == 2);
|
||||
assert_cc(alignof(uint32_t) == 4);
|
||||
assert_cc(alignof(uint64_t) == 8);
|
||||
-assert_cc(alignof(wchar_t) == 2);
|
||||
+assert_cc(alignof(uint16_t) == 2);
|
||||
assert_cc(alignof(char16_t) == 2);
|
||||
assert_cc(alignof(char32_t) == 4);
|
||||
|
||||
diff --git a/src/boot/fuzz-efi-printf.c b/src/boot/fuzz-efi-printf.c
|
||||
index 6dee830..75017cc 100644
|
||||
--- a/src/boot/fuzz-efi-printf.c
|
||||
+++ b/src/boot/fuzz-efi-printf.c
|
||||
@@ -45,7 +45,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
fuzz_setup_logging();
|
||||
|
||||
PRINTF_ONE(i->status, "%*.*s", i->field_width, (int) len, i->str);
|
||||
- PRINTF_ONE(i->status, "%*.*ls", i->field_width, (int) (len / sizeof(wchar_t)), (const wchar_t *) i->str);
|
||||
+ PRINTF_ONE(i->status, "%*.*ls", i->field_width, (int) (len / sizeof(uint16_t)), (const uint16_t *) i->str);
|
||||
|
||||
PRINTF_ONE(i->status, "%% %*.*m", i->field_width, i->precision);
|
||||
PRINTF_ONE(i->status, "%*p", i->field_width, i->ptr);
|
||||
diff --git a/src/boot/test-efi-string.c b/src/boot/test-efi-string.c
|
||||
index b71a0c3..d2d1020 100644
|
||||
--- a/src/boot/test-efi-string.c
|
||||
+++ b/src/boot/test-efi-string.c
|
||||
@@ -649,7 +649,7 @@ TEST(xvasprintf_status) {
|
||||
test_printf_one("%-14ls %-10.0ls %-10.3ls", L"left", L"", L"chopped");
|
||||
|
||||
test_printf_one("%.6s", (char[]){ 'n', 'o', ' ', 'n', 'u', 'l' });
|
||||
- test_printf_one("%.6ls", (wchar_t[]){ 'n', 'o', ' ', 'n', 'u', 'l' });
|
||||
+ test_printf_one("%.6ls", (uint16_t[]){ 'n', 'o', ' ', 'n', 'u', 'l' });
|
||||
|
||||
test_printf_one("%u %u %u", 0U, 42U, 1234567890U);
|
||||
test_printf_one("%i %i %i", 0, -42, -1234567890);
|
||||
--
|
||||
2.47.1
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
From f214e955b853d87aa1a34dfbb44b5d8edff3962c Mon Sep 17 00:00:00 2001
|
||||
From: Clayton Craft <clayton@craftyguy.net>
|
||||
Date: Tue, 7 Jan 2025 20:19:51 -0800
|
||||
Subject: [PATCH 1/2] meson: minimal configure for building systemd-boot
|
||||
|
||||
Notes:
|
||||
- toggling all ENABLED_* things off saves a ton of configure
|
||||
time
|
||||
- Removing capability.h, so that cross compiling doesn't fail
|
||||
because that header isn't installed
|
||||
- Set libcap and libmount to required=false, they aren't needed for
|
||||
building the bootloader, and they complicate cross compilation
|
||||
|
||||
IMPORTANT: some of these dependencies don't exist for the target arch
|
||||
(x86) and since they aren't actually required by sd-boot it's easier
|
||||
to just disable/remove them from meson.build!!!
|
||||
|
||||
---
|
||||
meson.build | 16 +++++++++++-----
|
||||
1 file changed, 11 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index bffda86845..b5a27de305 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -766,9 +766,6 @@ conf.set('GPERF_LEN_TYPE', gperf_len_type,
|
||||
|
||||
#####################################################################
|
||||
|
||||
-if not cc.has_header('sys/capability.h')
|
||||
- error('POSIX caps headers not found')
|
||||
-endif
|
||||
foreach header : ['crypt.h',
|
||||
'linux/ioprio.h',
|
||||
'linux/memfd.h',
|
||||
@@ -1052,7 +1049,7 @@ if not libcrypt.found()
|
||||
# fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
|
||||
libcrypt = cc.find_library('crypt')
|
||||
endif
|
||||
-libcap = dependency('libcap')
|
||||
+libcap = dependency('libcap', required : false)
|
||||
|
||||
# On some architectures, libatomic is required. But on some installations,
|
||||
# it is found, but actual linking fails. So let's try to use it opportunistically.
|
||||
@@ -1164,7 +1161,7 @@ else
|
||||
endif
|
||||
|
||||
libmount = dependency('mount',
|
||||
- version : fuzzer_build ? '>= 0' : '>= 2.30')
|
||||
+ version : fuzzer_build ? '>= 0' : '>= 2.30', required : false)
|
||||
|
||||
libfdisk = dependency('fdisk',
|
||||
version : '>= 2.32',
|
||||
@@ -1931,6 +1928,15 @@ pefile = pymod.find_installation('python3', required: false, modules : ['pefile'
|
||||
want_ukify = get_option('ukify').require(python_39 and (want_tests != 'true' or pefile.found()), error_message : 'Python >= 3.9 and pefile required').allowed()
|
||||
conf.set10('ENABLE_UKIFY', want_ukify)
|
||||
|
||||
+foreach key : conf.keys()
|
||||
+ if key.startswith('ENABLE_')
|
||||
+ conf.set10(key, false)
|
||||
+ endif
|
||||
+endforeach
|
||||
+
|
||||
+conf.set10('ENABLE_EFI', true)
|
||||
+conf.set10('ENABLE_BOOTLOADER', true)
|
||||
+
|
||||
#####################################################################
|
||||
|
||||
check_efi_alignment_py = find_program('tools/check-efi-alignment.py')
|
||||
--
|
||||
2.47.1
|
||||
|
||||
126
cross/systemd-boot-x86/APKBUILD
Normal file
126
cross/systemd-boot-x86/APKBUILD
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
# Forked from Alpine to cross compile for x86_64 systems that have x86 EFI
|
||||
|
||||
pkgname=systemd-boot-x86
|
||||
_pkgname=systemd-boot # for monitoring
|
||||
pkgver=257.5
|
||||
pkgrel=0
|
||||
pkgdesc="systemd's EFI boot manager for x86 EFI on x86_64."
|
||||
url="https://systemd.io/"
|
||||
# riscv64: I have no way to test this currently
|
||||
arch="x86_64"
|
||||
license="LGPL-2.1-or-later"
|
||||
makedepends="
|
||||
bash
|
||||
coreutils
|
||||
gcc-x86
|
||||
gperf
|
||||
libcap-dev
|
||||
meson
|
||||
musl-dev-x86
|
||||
py3-elftools
|
||||
py3-jinja2
|
||||
util-linux-dev
|
||||
"
|
||||
source="
|
||||
systemd-$pkgver.tar.gz::https://github.com/systemd/systemd/archive/refs/tags/v$pkgver.tar.gz
|
||||
0001-patch-wchar_t-for-musl.patch
|
||||
0002-meson-minimal-configure-for-building-systemd-boot.patch
|
||||
cross-x86.meson
|
||||
"
|
||||
# check: no tests
|
||||
# archcheck: provides platform-specific EFI binary
|
||||
options="!check !archcheck"
|
||||
subpackages="
|
||||
systemd-x86-efistub:efistub
|
||||
"
|
||||
builddir="$srcdir/systemd-$pkgver"
|
||||
|
||||
build() {
|
||||
abuild-meson \
|
||||
-Dsbat-distro="alpine" \
|
||||
-Dsbat-distro-summary="Alpine Linux" \
|
||||
-Dsbat-distro-pkgname="$pkgname" \
|
||||
-Dsbat-distro-version="$pkgver" \
|
||||
-Dsbat-distro-url="https://alpinelinux.org/" \
|
||||
-Dadm-group=false \
|
||||
-Danalyze=false \
|
||||
-Dbacklight=false \
|
||||
-Dbinfmt=false \
|
||||
-Dbootloader=enabled \
|
||||
-Dcompat-mutable-uid-boundaries=false \
|
||||
-Dcoredump=false \
|
||||
-Ddns-over-tls=false \
|
||||
-Defi=true \
|
||||
-Denvironment-d=false \
|
||||
-Dfexecve=false \
|
||||
-Dfirstboot=false \
|
||||
-Dfirst-boot-full-preset=false \
|
||||
-Dgshadow=false \
|
||||
-Dhibernate=false \
|
||||
-Dhomed=disabled \
|
||||
-Dhostnamed=false \
|
||||
-Dhwdb=false \
|
||||
-Didn=false \
|
||||
-Dima=false \
|
||||
-Dimportd=disabled \
|
||||
-Dinitrd=false \
|
||||
-Dkernel-install=false \
|
||||
-Dldconfig=false \
|
||||
-Dlocaled=false \
|
||||
-Dlogind=false \
|
||||
-Dmachined=false \
|
||||
-Dnetworkd=false \
|
||||
-Dnscd=false \
|
||||
-Dnss-myhostname=false \
|
||||
-Dnss-mymachines=disabled \
|
||||
-Dnss-resolve=disabled \
|
||||
-Dnss-systemd=false \
|
||||
-Doomd=false \
|
||||
-Dpolkit=disabled \
|
||||
-Dportabled=false \
|
||||
-Dpstore=false \
|
||||
-Dquotacheck=false \
|
||||
-Drandomseed=false \
|
||||
-Dremote=disabled \
|
||||
-Drepart=disabled \
|
||||
-Dresolve=false \
|
||||
-Drfkill=false \
|
||||
-Dsmack=false \
|
||||
-Dstoragetm=false \
|
||||
-Dsysext=false \
|
||||
-Dsysupdate=disabled \
|
||||
-Dsysusers=false \
|
||||
-Dtimedated=false \
|
||||
-Dtimesyncd=false \
|
||||
-Dtmpfiles=false \
|
||||
-Dtpm=false \
|
||||
-Dukify=disabled \
|
||||
-Durlify=false \
|
||||
-Duserdb=false \
|
||||
-Dutmp=false \
|
||||
-Dvconsole=false \
|
||||
-Dvmspawn=disabled \
|
||||
-Dwheel-group=false \
|
||||
-Dxdg-autostart=false \
|
||||
--cross-file "$srcdir"/cross-x86.meson \
|
||||
. output
|
||||
meson compile -C output systemd-boot
|
||||
}
|
||||
|
||||
package() {
|
||||
find "$builddir/output/src/boot/" -name 'systemd*.efi' -exec \
|
||||
install -Dm 644 {} -t "$pkgdir/usr/lib/systemd/boot/efi" \;
|
||||
}
|
||||
|
||||
efistub() {
|
||||
pkgdesc="systemd's EFI boot stub for x86 EFI on x86_64."
|
||||
find "$builddir/output/src/boot/" -name '*.stub' -exec \
|
||||
install -Dm 644 {} -t "$subpkgdir/usr/lib/systemd/boot/efi" \;
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
9e5352c20c9edac53f302a534532035185139998628ed0a85411f440df47f1dd7cce6651aec787484809bb1aa2825008d062714c37936cbfd08451fbe29a998f systemd-257.5.tar.gz
|
||||
81e6f311d567ef8b1f8957f25f019e7fa995f640659381757d1abdd7295434810b79a09367d274c5755f1ed1f6d37d7d98e9c93645578daca34acdeca0ba3965 0001-patch-wchar_t-for-musl.patch
|
||||
2c028d35c85a042582f668fd9ba1145134168e79e9137c90a2ea572c79124952b86114dc304dafa710a433b13aedc8251f5669aafffee9ddf42a32c2592bf5df 0002-meson-minimal-configure-for-building-systemd-boot.patch
|
||||
ad54e2c7e7a21bfa9b5f9e8db1b6af6a6d78a3e5dfe2dafcec77488f6224865ab4d4c8a8c8ee1c54c99d1741361e9fb3a51e5d36bcbc7a1c3fdcc4d0c1672132 cross-x86.meson
|
||||
"
|
||||
11
cross/systemd-boot-x86/cross-x86.meson
Normal file
11
cross/systemd-boot-x86/cross-x86.meson
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[binaries]
|
||||
c = 'i586-alpine-linux-musl-gcc'
|
||||
ar = 'i586-alpine-linux-musl-ar'
|
||||
strip = 'i586-alpine-linux-musl-strip'
|
||||
ld = 'i586-alpine-linux-musl-ld'
|
||||
|
||||
[host_machine]
|
||||
system = 'linux'
|
||||
cpu_family = 'x86'
|
||||
cpu = 'i586'
|
||||
endian = 'little'
|
||||
Loading…
Add table
Add a link
Reference in a new issue