working baseline local emulation target with busybox shell

This commit is contained in:
Lance Vick 2022-07-08 17:37:00 -07:00
parent 1cb4d565f8
commit 49bfc9dcd1
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
6 changed files with 3410 additions and 152 deletions

View File

@ -10,4 +10,8 @@ RUN apt update && \
bison \ bison \
libncurses-dev \ libncurses-dev \
bc \ bc \
libelf-dev libelf-dev \
libarchive-tools \
libssl-dev \
fakeroot \
cpio

View File

@ -1,11 +1,13 @@
NAME := qos NAME := qos
DEBUG := false DEBUG := true
OUT_DIR := out OUT_DIR := out
KEY_DIR := keys KEY_DIR := keys
TARGET := local TARGET := local
CACHE_DIR := cache CACHE_DIR := cache
CONFIG_DIR := targets/$(TARGET) CONFIG_DIR := targets/$(TARGET)
SCRIPTS_DIR := scripts
CPUS := $(shell nproc) CPUS := $(shell nproc)
ARCH := x86_64
include $(PWD)/config.env include $(PWD)/config.env
include $(PWD)/make/keys.mk include $(PWD)/make/keys.mk
@ -19,7 +21,7 @@ default: $(OUT_DIR)/bzImage
$(CONFIG_DIR)/busybox.config: $(CONFIG_DIR)/busybox.config:
$(toolchain) " \ $(toolchain) " \
cd /cache/busybox-$(BUSYBOX_VERSION) && \ cd /cache/busybox-$(BUSYBOX_VERSION) && \
make menuconfig && \ KCONFIG_NOTIMESTAMP=1 make menuconfig && \
cp .config /config/busybox.config; \ cp .config /config/busybox.config; \
" "
@ -29,6 +31,34 @@ $(CONFIG_DIR)/linux.config:
make menuconfig && \ make menuconfig && \
cp .config /config/linux.config; \ cp .config /config/linux.config; \
" "
$(OUT_DIR)/rootfs.cpio: $(OUT_DIR)/busybox
mkdir -p $(CACHE_DIR)/rootfs/bin
ifdef DEBUG
cp $(OUT_DIR)/busybox $(CACHE_DIR)/rootfs/bin;
cp $(SCRIPTS_DIR)/busybox_init $(CACHE_DIR)/rootfs/init;
chmod +x $(CACHE_DIR)/rootfs/init;
endif
$(toolchain) " \
cd /cache/rootfs \
&& find . \
| cpio -o -H newc \
| gzip -f - > /out/rootfs.cpio \
"
# Currently broken determinism attempt
# $(toolchain) " \
# cd /cache/rootfs \
# && mkdir -p dev \
# && fakeroot mknod -m 0622 dev/console c 5 1 \
# && find . -mindepth 1 -execdir touch -hcd "@0" "{}" + \
# && find . -mindepth 1 -printf '%P\0' \
# | sort -z \
# | LANG=C bsdtar --uid 0 --gid 0 --null -cnf - -T - \
# | LANG=C bsdtar --null -cf - --format=newc @- \
# " > $@
$(OUT_DIR)/busybox: extract $(OUT_DIR)/busybox: extract
$(toolchain) " \ $(toolchain) " \
cd /cache/busybox-$(BUSYBOX_VERSION) && \ cd /cache/busybox-$(BUSYBOX_VERSION) && \
@ -37,10 +67,19 @@ $(OUT_DIR)/busybox: extract
cp busybox /out/; \ cp busybox /out/; \
" "
$(OUT_DIR)/bzImage: extract $(OUT_DIR)/busybox $(OUT_DIR)/bzImage: extract $(OUT_DIR)/rootfs.cpio
$(toolchain) " \ $(toolchain) " \
cd /cache/linux-$(LINUX_VERSION) && \ cd /cache/linux-$(LINUX_VERSION) && \
cp /config/linux.config .config && \ cp /config/linux.config .config && \
make -j$(CPUS) bzImage && \ make olddefconfig && \
make -j$(CPUS) ARCH=$(ARCH) bzImage && \
cp arch/x86_64/boot/bzImage /out/; \ cp arch/x86_64/boot/bzImage /out/; \
" "
.PHONY: run
run:
qemu-system-x86_64 \
-m 512M \
-nographic \
-initrd $(OUT_DIR)/rootfs.cpio \
-kernel $(OUT_DIR)/bzImage

View File

@ -1,6 +1,6 @@
.PHONY: toolchain-shell .PHONY: toolchain-shell
build-shell: toolchain build-shell: toolchain
docker run -it local/$(NAME)-build bash $(toolchain)
.PHONY: toolchain .PHONY: toolchain
toolchain: toolchain:

35
scripts/busybox_init Executable file
View File

@ -0,0 +1,35 @@
#!/bin/busybox sh
echo "booted"
/bin/busybox --install
function halt {
echo "Something failed: $1"
echo "Will reboot in 10 seconds"
umount /eos
umount /main
umount /boot
umount /extra
sleep 10
reboot -f
}
/usr/bin/busybox --install
mount -t proc none /proc
mount -t devtmpfs none /dev
mount -t sysfs none /sys
mount -t securityfs none /sys/kernel/security
mkdir /dev/pts
mount -t devpts none /dev/pts
echo -n 3 > /proc/sys/kernel/yama/ptrace_scope
echo -n 2 > /proc/sys/kernel/kptr_restrict
touch /etc/hosts
touch /etc/fstab
/bin/busybox sh

View File

@ -1,14 +1,13 @@
# #
# Automatically generated make config: don't edit # Automatically generated make config: don't edit
# Busybox version: 1.33.2 # Busybox version: 1.33.2
# Fri Jun 24 04:18:01 2022
# #
CONFIG_HAVE_DOT_CONFIG=y CONFIG_HAVE_DOT_CONFIG=y
# #
# Settings # Settings
# #
CONFIG_DESKTOP=y # CONFIG_DESKTOP is not set
# CONFIG_EXTRA_COMPAT is not set # CONFIG_EXTRA_COMPAT is not set
# CONFIG_FEDORA_COMPAT is not set # CONFIG_FEDORA_COMPAT is not set
CONFIG_INCLUDE_SUSv2=y CONFIG_INCLUDE_SUSv2=y
@ -40,7 +39,7 @@ CONFIG_FEATURE_SYSLOG=y
# #
# Build Options # Build Options
# #
# CONFIG_STATIC is not set CONFIG_STATIC=y
# CONFIG_PIE is not set # CONFIG_PIE is not set
# CONFIG_NOMMU is not set # CONFIG_NOMMU is not set
# CONFIG_BUILD_LIBBUSYBOX is not set # CONFIG_BUILD_LIBBUSYBOX is not set
@ -189,9 +188,9 @@ CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
# CONFIG_FEATURE_TAR_SELINUX is not set # CONFIG_FEATURE_TAR_SELINUX is not set
CONFIG_UNZIP=y CONFIG_UNZIP=y
CONFIG_FEATURE_UNZIP_CDF=y CONFIG_FEATURE_UNZIP_CDF=y
CONFIG_FEATURE_UNZIP_BZIP2=y # CONFIG_FEATURE_UNZIP_BZIP2 is not set
CONFIG_FEATURE_UNZIP_LZMA=y # CONFIG_FEATURE_UNZIP_LZMA is not set
CONFIG_FEATURE_UNZIP_XZ=y # CONFIG_FEATURE_UNZIP_XZ is not set
# CONFIG_FEATURE_LZMA_FAST is not set # CONFIG_FEATURE_LZMA_FAST is not set
# #
@ -1047,11 +1046,11 @@ CONFIG_PMAP=y
CONFIG_POWERTOP=y CONFIG_POWERTOP=y
CONFIG_FEATURE_POWERTOP_INTERACTIVE=y CONFIG_FEATURE_POWERTOP_INTERACTIVE=y
CONFIG_PS=y CONFIG_PS=y
# CONFIG_FEATURE_PS_WIDE is not set CONFIG_FEATURE_PS_WIDE=y
# CONFIG_FEATURE_PS_LONG is not set CONFIG_FEATURE_PS_LONG=y
CONFIG_FEATURE_PS_TIME=y # CONFIG_FEATURE_PS_TIME is not set
# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y # CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
CONFIG_PSTREE=y CONFIG_PSTREE=y
CONFIG_PWDX=y CONFIG_PWDX=y
CONFIG_SMEMCAP=y CONFIG_SMEMCAP=y

File diff suppressed because it is too large Load Diff