mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-18 20:47:55 +00:00
Build initrd tools with musl-libc (issue #77).
This adds compilations modules for musl-libc and kernel-headers. The entire initrd (busybox, cryptsetup, gpgv, kexec, etc) can be built with the much smaller libc and it appears to work with chroot. Library paths are not set correctly and files are installed into heads/install to make them accessible to other modules. This prevents the initrd from working without manual fixup; need to fix before merging into master. Build times have gone up since everything is being rebuilt more often for some reason.
This commit is contained in:
parent
177dede4ca
commit
9273e252f6
18
Makefile
18
Makefile
@ -8,6 +8,11 @@ INSTALL := $(pwd)/install
|
||||
# Currently supported targets are x230, chell and qemu
|
||||
BOARD ?= qemu
|
||||
|
||||
# If musl-libc is being used in the initrd, set the heads_cc
|
||||
# variable to point to it.
|
||||
musl_dep := musl
|
||||
heads_cc := $(INSTALL)/bin/musl-gcc
|
||||
|
||||
all: $(BOARD).rom
|
||||
|
||||
# Disable all built in rules
|
||||
@ -68,7 +73,8 @@ define define_module =
|
||||
$(build)/$($1_dir)/.canary: $(packages)/.$1_verify
|
||||
tar -xf "$(packages)/$($1_tar)" -C "$(build)"
|
||||
if [ -r patches/$1-$($1_version).patch ]; then \
|
||||
( cd $(build)/$($1_dir) ; patch -p1 ) < patches/$1-$($1_version).patch; \
|
||||
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
||||
< patches/$1-$($1_version).patch; \
|
||||
fi
|
||||
touch "$$@"
|
||||
endif
|
||||
@ -100,6 +106,7 @@ define define_module =
|
||||
# Target for all of the outputs, which depend on their dependent modules
|
||||
$1.intermediate: \
|
||||
$(foreach d,$($1_depends),$(call outputs,$d)) \
|
||||
$(foreach d,$($1_depends),$d.intermediate) \
|
||||
$(build)/$($1_dir)/.configured
|
||||
make -C "$(build)/$($1_dir)" $($1_target)
|
||||
|
||||
@ -163,16 +170,21 @@ initrd/bin/busybox: $(build)/$(busybox_dir)/busybox
|
||||
cmp --quiet "$@" "$^" || \
|
||||
make \
|
||||
-C $(build)/$(busybox_dir) \
|
||||
CC="$(heads_cc)" \
|
||||
CONFIG_PREFIX="$(pwd)/initrd" \
|
||||
-j 8 \
|
||||
install
|
||||
|
||||
# hack to build cbmem from coreboot
|
||||
# this must be built *AFTER* musl
|
||||
initrd_bins += initrd/bin/cbmem
|
||||
initrd/bin/cbmem: $(build)/$(coreboot_dir)/util/cbmem/cbmem
|
||||
cmp --quiet "$^" "$@" \
|
||||
|| cp "$^" "$@"
|
||||
$(build)/$(coreboot_dir)/util/cbmem/cbmem: $(build)/$(coreboot_dir)/.canary
|
||||
make -C "$(dir $@)"
|
||||
$(build)/$(coreboot_dir)/util/cbmem/cbmem: \
|
||||
$(build)/$(coreboot_dir)/.canary \
|
||||
musl.intermediate
|
||||
make -C "$(dir $@)" CC="$(heads_cc)"
|
||||
|
||||
|
||||
# Update all of the libraries in the initrd based on the executables
|
||||
|
@ -6,7 +6,13 @@ busybox_tar := busybox-$(busybox_version).tar.bz2
|
||||
busybox_url := https://busybox.net/downloads/$(busybox_tar)
|
||||
busybox_hash := 5a0fe06885ee1b805fb459ab6aaa023fe4f2eccee4fb8c0fd9a6c17c0daca2fc
|
||||
|
||||
busybox_configure := make oldconfig
|
||||
busybox_configure := make CC=$(heads_cc) oldconfig
|
||||
busybox_config := busybox.config
|
||||
busybox_output := busybox
|
||||
busybox_target := \
|
||||
CC="$(heads_cc)" \
|
||||
CONFIG_PREFIX="$(INSTALL)" \
|
||||
-j 8 \
|
||||
install
|
||||
|
||||
busybox_depends := $(musl_dep)
|
||||
|
@ -1,6 +1,6 @@
|
||||
modules += cryptsetup
|
||||
|
||||
cryptsetup_depends := libuuid popt lvm2
|
||||
cryptsetup_depends := libuuid popt lvm2 $(musl_dep)
|
||||
|
||||
cryptsetup_version := 1.7.3
|
||||
cryptsetup_dir := cryptsetup-$(cryptsetup_version)
|
||||
@ -9,6 +9,7 @@ cryptsetup_url := https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/cryptse
|
||||
cryptsetup_hash := af2b04e8475cf40b8d9ffd97a1acfa73aa787c890430afd89804fb544d6adc02
|
||||
|
||||
cryptsetup_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
CFLAGS="-I$(INSTALL)/include" \
|
||||
LDFLAGS="-L$(INSTALL)/lib" \
|
||||
--prefix "$(INSTALL)" \
|
||||
|
@ -9,6 +9,7 @@ gpg_url := https://www.gnupg.org/ftp/gcrypt/gnupg/$(gpg_tar)
|
||||
gpg_hash := 6b47a3100c857dcab3c60e6152e56a997f2c7862c1b8b2b25adf3884a1ae2276
|
||||
|
||||
gpg_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
CFLAGS="-I$(INSTALL)/include" \
|
||||
LDFLAGS="-L$(INSTALL)/lib" \
|
||||
--prefix $(INSTALL) \
|
||||
@ -35,3 +36,4 @@ gpg_target := -j 8 install
|
||||
|
||||
gpg_output := g10/gpgv
|
||||
|
||||
gpg_depends := $(musl_dep)
|
||||
|
18
modules/kernel-headers
Normal file
18
modules/kernel-headers
Normal file
@ -0,0 +1,18 @@
|
||||
modules += kernel-headers
|
||||
|
||||
# we install kernel-headers from sabotage linux, a musl-libc based
|
||||
# distribution, that works well with busybox and other tools.
|
||||
|
||||
kernel-headers_version := 3.12.6-5
|
||||
kernel-headers_dir := kernel-headers-$(kernel-headers_version)
|
||||
kernel-headers_tar := kernel-headers-$(kernel-headers_version).tar.gz
|
||||
kernel-headers_url := https://github.com/sabotage-linux/kernel-headers/archive/v$(kernel-headers_version).tar.gz
|
||||
kernel-headers_hash := ecf4db8781dc50a21cbc4cb17b039f96aede53f9da13435a3201373abb49b96b
|
||||
|
||||
kernel-headers_configure :=
|
||||
|
||||
kernel-headers_target := \
|
||||
ARCH=x86_64 \
|
||||
prefix="$(INSTALL)" \
|
||||
install
|
||||
|
@ -7,15 +7,20 @@ kexec_url := https://kernel.org/pub/linux/utils/kernel/kexec/$(kexec_tar)
|
||||
kexec_hash := cc7b60dad0da202004048a6179d8a53606943062dd627a2edba45a8ea3a85135
|
||||
|
||||
kexec_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
CFLAGS="-I$(INSTALL)/include" \
|
||||
LDFLAGS="-L$(INSTALL)/lib" \
|
||||
--prefix="$(INSTALL)" \
|
||||
--without-zlib \
|
||||
--without-lzma \
|
||||
|
||||
kexec_target := -j 8 install
|
||||
kexec_target := \
|
||||
CC="$(heads_cc)" \
|
||||
-j 8 \
|
||||
install \
|
||||
|
||||
kexec_output := build/sbin/kexec
|
||||
|
||||
# if we don't need zlib, don't built it
|
||||
#kexec_depends := zlib
|
||||
kexec_depends := $(musl_dep)
|
||||
|
@ -7,8 +7,10 @@ libuuid_url := http://downloads.sourceforge.net/project/libuuid/$(libuuid_tar)
|
||||
libuuid_hash := 46af3275291091009ad7f1b899de3d0cea0252737550e7919d17237997db5644
|
||||
|
||||
libuuid_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
--prefix $(INSTALL) \
|
||||
|
||||
libuuid_target := install
|
||||
|
||||
libuuid_libraries := .libs/libuuid.so
|
||||
libuuid_depends := $(musl_dep)
|
||||
|
@ -7,6 +7,7 @@ lvm2_url := http://mirrors.kernel.org/sourceware/lvm2/$(lvm2_tar)
|
||||
lvm2_hash := 23a3d1cddd41b3ef51812ebf83e9fa491f502fe74130d4263be327a91914660d
|
||||
|
||||
lvm2_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
--prefix $(INSTALL) \
|
||||
--disable-selinux \
|
||||
--disable-udev-systemd-background-jobs \
|
||||
@ -17,3 +18,5 @@ lvm2_target := -j 8 install_device-mapper
|
||||
lvm2_libraries := libdm/libdevmapper.so
|
||||
|
||||
lvm2_output := tools/dmsetup
|
||||
|
||||
lvm2_depends := $(musl_dep)
|
||||
|
@ -10,4 +10,11 @@ mbedtls_libraries := \
|
||||
library/libmbedcrypto.so.0 \
|
||||
|
||||
mbedtls_configure :=
|
||||
mbedtls_target := SHARED=1 DESTDIR=$(INSTALL) -j 8 install
|
||||
mbedtls_target := \
|
||||
SHARED=1 \
|
||||
DESTDIR=$(INSTALL) \
|
||||
CC="$(heads_cc)" \
|
||||
-j 8 \
|
||||
install
|
||||
|
||||
mbedtls_depends := $(musl_dep)
|
||||
|
17
modules/musl
Normal file
17
modules/musl
Normal file
@ -0,0 +1,17 @@
|
||||
modules += musl
|
||||
|
||||
musl_version := 1.1.15
|
||||
musl_dir := musl-$(musl_version)
|
||||
musl_tar := musl-$(musl_version).tar.gz
|
||||
musl_url := https://www.musl-libc.org/releases/$(musl_tar)
|
||||
musl_hash := 97e447c7ee2a7f613186ec54a93054fe15469fe34d7d323080f7ef38f5ecb0fa
|
||||
|
||||
musl_output := $(INSTALL)/bin/musl-gcc
|
||||
|
||||
musl_configure := ./configure \
|
||||
--prefix="$(INSTALL)" \
|
||||
--syslibdir="$(INSTALL)/lib" \
|
||||
|
||||
musl_target := -j 8 install
|
||||
|
||||
musl_depends := kernel-headers
|
@ -7,8 +7,10 @@ popt_url := http://rpm5.org/files/popt/$(popt_tar)
|
||||
popt_hash := e728ed296fe9f069a0e005003c3d6b2dde3d9cad453422a10d6558616d304cc8
|
||||
|
||||
popt_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
--prefix $(INSTALL) \
|
||||
|
||||
popt_target := install
|
||||
|
||||
popt_libraries := ./libs/libpopt.so
|
||||
popt_depends := $(musl_dep)
|
||||
|
@ -9,8 +9,10 @@ qrencode_hash := e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a7
|
||||
qrencode_output := .libs/libqrencode.so.$(qrencode_version)
|
||||
|
||||
qrencode_configure := ./configure \
|
||||
CC="$(heads_cc)" \
|
||||
--prefix $(INSTALL) \
|
||||
--without-tools \
|
||||
|
||||
qrencode_target := install
|
||||
|
||||
qrencode_depends := $(musl_dep)
|
||||
|
@ -1,6 +1,6 @@
|
||||
modules += tpmtotp
|
||||
|
||||
tpmtotp_depends := mbedtls qrencode
|
||||
tpmtotp_depends := mbedtls qrencode $(musl_dep)
|
||||
|
||||
tpmtotp_version := git
|
||||
tpmtotp_repo := https://github.com/osresearch/tpmtotp
|
||||
@ -11,6 +11,7 @@ tpmtotp_dir := tpmtotp-$(tpmtotp_version)
|
||||
#tpmtotp_url := https://github.com/osresearch/tpmtotp/archive/v0.0.1.tar.gz
|
||||
#tpmtotp_hash := 8bf2380248fea540a96ad0ff8a4f170b8d93b6bb5fe49b958f9f1926f994823f
|
||||
|
||||
tpmtotp_target := CC="$(heads_cc)"
|
||||
|
||||
tpmtotp_output := \
|
||||
totp \
|
||||
|
Loading…
Reference in New Issue
Block a user