#!/usr/bin/env bash # Copyright 2021 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. # This script builds a buildroot-based Linux image. # It should be run from a buildroot checkout (git://git.buildroot.net/buildroot) as: # TARGETARCH={amd64,arm64,arm,riscv64,s390x,mips64le,ppc64le} [NOMAKE=yes] create-buildroot-image.sh # If no NOMAKE=yes is specified, then it will just prepare the buildroot config, # but will not run the final make. # For amd64 and arm64 it creates a bootable image with root partition # on /dev/sda1 in output/images/disk.img file. # For other architectures it creates a non-bootable disk # suitable qemu injected boot with root partition on /dev/sda # in output/images/rootfs.ext4 file. # Note: the image requires at least kernel v4.19 # (otherwise glibc complains about unsupported kernel version). set -eux NOMAKE="${NOMAKE:-}" TARGETARCH="${TARGETARCH:-amd64}" case "$TARGETARCH" in amd64) DEFCONFIG="pc_x86_64_bios_defconfig";; arm64) DEFCONFIG="aarch64_efi_defconfig";; arm) DEFCONFIG="qemu_arm_vexpress_defconfig";; riscv64) DEFCONFIG="qemu_riscv64_virt_defconfig";; s390x) DEFCONFIG="qemu_s390x_defconfig";; mips64le) DEFCONFIG="qemu_mips64r6el_malta_defconfig";; ppc64le) DEFCONFIG="qemu_ppc64le_pseries_defconfig";; *) echo "unsupported TARGETARCH=${TARGETARCH}" exit 1;; esac git fetch origin git checkout 2025.02.1 make "${DEFCONFIG}" # Common configs for all architectures. cat >>.config <>.config <>.config <>.config <>.config <>.config <>.config <>.config <> package/dhcpcd/dhcpcd.hash fi # This script modifies the target root filesystem # before it's packed into the final image. # This part is common for all architectures. cat >rootfs_script.sh <<'EOFEOF' set -eux # Mount /dev right after / is mounted. sed -Ei '/\/dev\/pts/i ::sysinit:/bin/mount -t devtmpfs devtmpfs /dev' $1/etc/inittab # Mount debugfs for KCOV and other filesystems. cat >>$1/etc/fstab <$1/etc/ssh/sshd_config <>rootfs_script.sh <<'EOFEOF' # Write udev rules. cat >$1/etc/udev/rules.d/50-syzkaller.rules <$1/boot/grub/grub.cfg <post_image_script.sh <<'EOFEOF' cat >${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg <