mirror of
https://github.com/systemd/systemd
synced 2024-09-16 06:43:18 +00:00
Merge pull request #22252 from medhefgo/boot-build
meson: Boot build/test changes
This commit is contained in:
commit
9d3bb25b2d
|
@ -599,10 +599,8 @@ env = find_program('env')
|
|||
perl = find_program('perl', required : false)
|
||||
rsync = find_program('rsync', required : false)
|
||||
meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
|
||||
test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
|
||||
|
||||
mkdir_p = 'mkdir -p $DESTDIR/@0@'
|
||||
splash_bmp = files('test/splash.bmp')
|
||||
|
||||
# If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
|
||||
# /usr/sbin, /sbin, and fall back to the default from middle column.
|
||||
|
|
|
@ -256,17 +256,11 @@ else
|
|||
endif
|
||||
|
||||
if efi_arch[1] == 'arm'
|
||||
# On arm, the compiler (correctly) gives us the following warning:
|
||||
# libgcc.a(_popcountsi2.o) uses 4-byte wchar_t yet the output is to
|
||||
# use 2-byte wchar_t; use of wchar_t values across objects may fail
|
||||
#
|
||||
# libgcc does not have any occurrences of wchar_t in its sources or the
|
||||
# documentation, so it's safe to assume that we can ignore this warning.
|
||||
#
|
||||
# So far, this only happens with arm due to popcount even though x86 and
|
||||
# x86_64 also have to rely on libgcc's popcount. Therefore, we only disable
|
||||
# this for arm to make sure this doesn't mask other issues in the future.
|
||||
efi_ldflags += ['-Wl,--no-warn-mismatch']
|
||||
# On arm, the compiler (correctly) warns about wchar_t size mismatch. This
|
||||
# is because libgcc is not compiled with -fshort-wchar, but it does not
|
||||
# have any occurrences of wchar_t in its sources or the documentation, so
|
||||
# it is safe to assume that we can ignore this warning.
|
||||
efi_ldflags += ['-Wl,--no-wchar-size-warning']
|
||||
endif
|
||||
|
||||
if run_command('grep', '-q', '__CTOR_LIST__', efi_lds, check: false).returncode() == 0
|
||||
|
@ -397,17 +391,12 @@ foreach file : fundamental_source_paths + common_sources + systemd_boot_sources
|
|||
endif
|
||||
endforeach
|
||||
|
||||
systemd_boot_efi_name = 'systemd-boot@0@.efi'.format(efi_arch[0])
|
||||
stub_elf_name = 'linux@0@.elf.stub'.format(efi_arch[0])
|
||||
stub_efi_name = 'linux@0@.efi.stub'.format(efi_arch[0])
|
||||
|
||||
efi_stubs = []
|
||||
foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects, false],
|
||||
[stub_elf_name, stub_efi_name, stub_objects, true]]
|
||||
so = custom_target(
|
||||
tuple[0],
|
||||
input : tuple[2],
|
||||
output : tuple[0],
|
||||
foreach tuple : [['systemd-boot@0@.@1@', systemd_boot_objects, false],
|
||||
['linux@0@.@1@.stub', stub_objects, true]]
|
||||
elf = custom_target(
|
||||
tuple[0].format(efi_arch[0], 'elf'),
|
||||
input : tuple[1],
|
||||
output : tuple[0].format(efi_arch[0], 'elf'),
|
||||
command : [cc.cmd_array(),
|
||||
'-o', '@OUTPUT@',
|
||||
efi_cflags,
|
||||
|
@ -416,13 +405,13 @@ foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects
|
|||
'-lefi',
|
||||
'-lgnuefi',
|
||||
'-lgcc'],
|
||||
install : tuple[3],
|
||||
install : tuple[2],
|
||||
install_dir : bootlibdir)
|
||||
|
||||
stub = custom_target(
|
||||
tuple[1],
|
||||
input : so,
|
||||
output : tuple[1],
|
||||
custom_target(
|
||||
tuple[0].format(efi_arch[0], 'efi'),
|
||||
input : elf,
|
||||
output : tuple[0].format(efi_arch[0], 'efi'),
|
||||
command : [objcopy,
|
||||
'-j', '.bss*',
|
||||
'-j', '.data',
|
||||
|
@ -439,14 +428,4 @@ foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects
|
|||
'@INPUT@', '@OUTPUT@'],
|
||||
install : true,
|
||||
install_dir : bootlibdir)
|
||||
|
||||
efi_stubs += [[so, stub]]
|
||||
endforeach
|
||||
|
||||
############################################################
|
||||
|
||||
test_efi_disk_img = custom_target(
|
||||
'test-efi-disk.img',
|
||||
input : [efi_stubs[0][0], efi_stubs[1][1]],
|
||||
output : 'test-efi-disk.img',
|
||||
command : [test_efi_create_disk_sh, '@OUTPUT@','@INPUT@', splash_bmp])
|
||||
|
|
BIN
test/splash.bmp
BIN
test/splash.bmp
Binary file not shown.
Before Width: | Height: | Size: 282 KiB |
|
@ -1,54 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eo pipefail
|
||||
|
||||
out="${1:?}"
|
||||
systemd_efi="${2:?}"
|
||||
boot_stub="${3:?}"
|
||||
splash_bmp="${4:?}"
|
||||
|
||||
efi_dir="$(bootctl -p)"
|
||||
entry_dir="${efi_dir}/$(cat /etc/machine-id)/$(uname -r)"
|
||||
|
||||
# create GPT table with EFI System Partition
|
||||
rm -f "$out"
|
||||
dd if=/dev/null of="$out" bs=1M seek=512 count=1 status=none
|
||||
parted --script "$out" "mklabel gpt" "mkpart ESP fat32 1MiB 511MiB" "set 1 boot on"
|
||||
|
||||
# create FAT32 file system
|
||||
LOOP="$(losetup --show -f -P "$out")"
|
||||
mkfs.vfat -F32 "${LOOP}p1"
|
||||
mkdir -p mnt
|
||||
mount "${LOOP}p1" mnt
|
||||
|
||||
mkdir -p mnt/EFI/{BOOT,systemd}
|
||||
cp "$systemd_efi" mnt/EFI/BOOT/BOOTX64.efi
|
||||
|
||||
if [ -e /boot/shellx64.efi ]; then
|
||||
cp /boot/shellx64.efi mnt/
|
||||
fi
|
||||
|
||||
mkdir mnt/EFI/Linux
|
||||
echo -n "foo=yes bar=no root=/dev/fakeroot debug rd.break=initqueue" >mnt/cmdline.txt
|
||||
objcopy \
|
||||
--add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
|
||||
--add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \
|
||||
--add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \
|
||||
--add-section .linux="${entry_dir}/linux" --change-section-vma .linux=0x2000000 \
|
||||
--add-section .initrd="${entry_dir}/initrd" --change-section-vma .initrd=0x3000000 \
|
||||
"$boot_stub" mnt/EFI/Linux/linux-test.efi
|
||||
|
||||
# install entries
|
||||
mkdir -p mnt/loader/entries
|
||||
echo -e "timeout 3\n" > mnt/loader/loader.conf
|
||||
echo -e "title Test\nefi /test\n" > mnt/loader/entries/test.conf
|
||||
echo -e "title Test2\nlinux /test2\noptions option=yes word number=1000 more\n" > mnt/loader/entries/test2.conf
|
||||
echo -e "title Test3\nlinux /test3\n" > mnt/loader/entries/test3.conf
|
||||
echo -e "title Test4\nlinux /test4\n" > mnt/loader/entries/test4.conf
|
||||
echo -e "title Test5\nefi /test5\n" > mnt/loader/entries/test5.conf
|
||||
echo -e "title Test6\nlinux /test6\n" > mnt/loader/entries/test6.conf
|
||||
|
||||
sync
|
||||
umount mnt
|
||||
rmdir mnt
|
||||
losetup -d "$LOOP"
|
|
@ -32,10 +32,10 @@ fi
|
|||
binary=$(realpath "${1}")
|
||||
if [[ "${1}" =~ systemd-boot([[:alnum:]]+).efi ]]; then
|
||||
target="systemd-boot"
|
||||
symbols=$(realpath "$(dirname "${1}")/systemd_boot.so")
|
||||
symbols=$(realpath "${1%efi}elf")
|
||||
elif [[ "${1}" =~ linux([[:alnum:]]+).efi.stub ]]; then
|
||||
target="systemd-stub"
|
||||
symbols=$(realpath "$(dirname "${1}")/linux${BASH_REMATCH[1]}.elf.stub")
|
||||
symbols=$(realpath "${1%efi.stub}elf.stub")
|
||||
else
|
||||
echo "Cannot detect EFI binary '${1}'."
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue