Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 1 addition & 38 deletions boot-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,7 @@
# Root of the repo
BASE=$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)

function pretty_print() {
printf "%b%s\033[0m" "${1}" "${2}"
shift 2
while ((${#})); do
printf "%b" "${1}"
shift
done
printf '\n'
}

function green() {
pretty_print "\033[01;32m" "${@}"
}

function red() {
pretty_print "\033[01;31m" "${@}"
}

# Prints an error message in bold red then exits
function die() {
red "${@}"
exit 1
}
source "${BASE}"/utils.sh

# Check that a binary is found
function checkbin() {
Expand Down Expand Up @@ -155,21 +133,6 @@ function get_default_smp_value() {
fi
}

# Expands '-k' to an absolute path to a kernel image if necessary
function get_full_kernel_path() {
# If '-k' is an path that ends in the kernel image, we can just use it directly
if [[ ${KERNEL_LOCATION##*/} = "${KIMAGE:=zImage}" ]]; then
KERNEL=${KERNEL_LOCATION}
# If not though, we need to find it based on the kernel build directory
else
# If the image is an uncompressed vmlinux, it is in the root of the build folder
# Otherwise, it is in the architecture's boot directory
[[ ${KIMAGE} == "vmlinux" ]] || BOOT_DIR=arch/${ARCH}/boot/
KERNEL=${KERNEL_LOCATION}/${BOOT_DIR}${KIMAGE}
fi
[[ -f ${KERNEL} ]] || die "${KERNEL} does not exist!"
}

# Takes a version (x.y.z) and prints a six or seven digit number
# For example, QEMU 6.2.50 would become 602050 and Linux 5.10.100
# would become 510100
Expand Down
42 changes: 42 additions & 0 deletions boot-uml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

BASE=$(dirname "$(readlink -f "$0")")
source "$BASE"/utils.sh

function parse_parameters() {
while (($#)); do
case $1 in
-i | --interactive | --shell)
kernel_args=(init=/bin/sh)
;;
-k | --kernel-location)
shift
KERNEL_LOCATION=$1
;;
esac
shift
done
}

function reality_check() {
[[ -z $KERNEL_LOCATION ]] && die "Kernel image or kernel build folder ('-k') is required but not specified!"
KIMAGE=linux get_full_kernel_path
}

function decomp_rootfs() {
rootfs=$BASE/images/x86_64/rootfs.ext4
rm -rf "$rootfs"
zstd -q -d "$rootfs".zst -o "$rootfs"
}

function execute_kernel() {
# exec is needed to avoid a "Killed" message when the kernel shuts down:
# https://github.com/ClangBuiltLinux/boot-utils/issues/60
# Nothing runs after this command so it is okay for it to replace this process.
exec "$KERNEL" ubd0="$rootfs" "${kernel_args[@]}"
}

parse_parameters "$@"
reality_check
decomp_rootfs
execute_kernel
1 change: 0 additions & 1 deletion buildroot/buildroot-2020.11.2.tar.gz.sha256

This file was deleted.

1 change: 1 addition & 0 deletions buildroot/buildroot-2022.02.tar.gz.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9aaaa1317ca1082ccdabe3f2566bba06975080a80256adf87f860bc4c3f45a9b buildroot-2022.02.tar.gz
7 changes: 3 additions & 4 deletions buildroot/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ while ((${#})); do
done

# Download latest LTS buildroot release
BUILDROOT_VERSION=2020.11.2
BUILDROOT_VERSION=2022.02
if [[ -d src ]]; then
# Make support/scripts/setlocalversion do nothing because we are in a git
# repository so it will return information about this repo, not Buildroot
Expand All @@ -53,9 +53,6 @@ if [[ -d src ]]; then
else
download_br
fi
# Patch buildroot with fakeroot fixes for newer glibc versions
[[ ! -f src/package/fakeroot/0002-libfakeroot.c-define-_STAT_VER-if-not-already-define.patch ]] &&
curl -LSs https://github.com/buildroot/buildroot/commit/f45925a951318e9e53bead80b363e004301adc6f.patch | patch -d src -p1
cd src || exit 1

# Build the images for the architectures requested
Expand Down Expand Up @@ -84,6 +81,8 @@ for CONFIG in "${CONFIGS[@]}"; do
# Copy new images
# Make sure images exist before moving them
IMAGES=("output/images/rootfs.cpio")
# For x86_64, we also build an ext4 image for UML
[[ ${ARCH} == "x86_64" ]] && IMAGES+=("output/images/rootfs.ext4")
for IMAGE in "${IMAGES[@]}"; do
[[ -f ${IMAGE} ]] || die "${IMAGE} could not be found! Did the build error?"
zstd -f -19 "${IMAGE}" -o "${IMAGES_FOLDER}/${IMAGE##*/}.zst" || die "Compressing ${IMAGE##*/} failed!"
Expand Down
2 changes: 1 addition & 1 deletion buildroot/riscv.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BR2_riscv=y
BR2_RISCV_ABI_LP64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_RISCV64_LP64D_GLIBC_STABLE=y
BR2_TARGET_GENERIC_ROOT_PASSWD="root"
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
BR2_ROOTFS_OVERLAY="../overlay-poweroff"
Expand Down
3 changes: 3 additions & 0 deletions buildroot/x86_64.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ BR2_TARGET_GENERIC_ROOT_PASSWD="root"
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
BR2_ROOTFS_OVERLAY="../overlay-poweroff"
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="10M"
# BR2_TARGET_ROOTFS_TAR is not set
1 change: 1 addition & 0 deletions images/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
debian.img
rootfs.cpio
rootfs.ext4
Binary file modified images/arm/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/arm64/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/arm64be/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/m68k/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/mips/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/mipsel/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/ppc32/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/ppc64/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/ppc64le/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/riscv/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/s390/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/x86/rootfs.cpio.zst
Binary file not shown.
Binary file modified images/x86_64/rootfs.cpio.zst
Binary file not shown.
Binary file added images/x86_64/rootfs.ext4.zst
Binary file not shown.
42 changes: 42 additions & 0 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

function pretty_print() {
printf "%b%s\033[0m" "${1}" "${2}"
shift 2
while ((${#})); do
printf "%b" "${1}"
shift
done
printf '\n'
}

function green() {
pretty_print "\033[01;32m" "${@}"
}

function red() {
pretty_print "\033[01;31m" "${@}"
}

# Prints an error message in bold red then exits
function die() {
red "${@}"
exit 1
}

# Expands '-k' to an absolute path to a kernel image if necessary
function get_full_kernel_path() {
# If '-k' is a file, we can just use it directly
if [[ -f ${KERNEL_LOCATION} ]]; then
KERNEL=${KERNEL_LOCATION}
# If not, we need to find it based on the kernel build directory
else
# If the image is an uncompressed vmlinux or a UML image, it is in the
# root of the build folder
# Otherwise, it is in the architecture's boot directory
[[ -z ${KIMAGE} ]] && KIMAGE=zImage
[[ ${KIMAGE} == "vmlinux" || ${KIMAGE} == "linux" ]] || BOOT_DIR=arch/${ARCH}/boot/
KERNEL=${KERNEL_LOCATION}/${BOOT_DIR}${KIMAGE}
fi
[[ -f ${KERNEL} ]] || die "${KERNEL} does not exist!"
}