From 33fe9ed78d0cf5b8585a9c83a061334155de7657 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 6 Oct 2018 17:47:13 +0000 Subject: [PATCH] Generate kernels.toml in kernel-factory bootstrap --- README.md | 4 ++++ tools/kernel-factory/bootstrap.sh | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 27cdea0..5e4aa18 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,7 @@ out-of-tree kernel {module, exploit} development tool Read [Qemu API](qemu/README.md). +### Generate kernels + + cd $GOPATH/src/github.com/jollheef/out-of-tree/tools/kernel-factory + ./bootstrap.sh # more than 6-8 hours for all kernels diff --git a/tools/kernel-factory/bootstrap.sh b/tools/kernel-factory/bootstrap.sh index ee0a159..aa2714f 100755 --- a/tools/kernel-factory/bootstrap.sh +++ b/tools/kernel-factory/bootstrap.sh @@ -1,10 +1,28 @@ #!/bin/sh mkdir output +echo > output/kernels.toml find | grep Docker | sed 's/Dockerfile//' | while read DOCKER; do CONTAINER_NAME=$(echo $DOCKER | sed -e 's;/;;g' -e 's;\.;;g' -e 's;\(.*\);\L\1;') docker build -t ${CONTAINER_NAME} ${DOCKER} CONTAINER_ID=$(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}' | head -n 1) docker cp ${CONTAINER_ID}:/boot/. output/ + DISTRO_NAME=$(echo $DOCKER | cut -d '/' -f 2) + DISTRO_VER=$(echo $DOCKER | cut -d '/' -f 3) + + BOOT_FILES="$(docker run $CONTAINER_NAME ls /boot)" + for KERNEL_RELEASE in $(docker run $CONTAINER_NAME ls /lib/modules); do + echo '[[Kernels]]' >> output/kernels.toml + echo 'distro_type =' $DISTRO_NAME >> output/kernels.toml + echo 'distro_release =' $DISTRO_VER >> output/kernels.toml + echo 'kernel_release =' $KERNEL_RELEASE >> output/kernels.toml + echo 'container_name =' $CONTAINER_NAME >> output/kernels.toml + KERNEL_PATH=$(echo $BOOT_FILES | sed 's/ /\n/g' | grep $KERNEL_RELEASE | grep vmlinuz) + echo 'kernel_path =' $(realpath output/$KERNEL_PATH) >> output/kernels.toml + INITRD_PATH=$(echo $BOOT_FILES | sed 's/ /\n/g' | grep $KERNEL_RELEASE | grep init) + echo 'initrd_path =' $(realpath output/$INITRD_PATH) >> output/kernels.toml + echo 'root_f_s =' $ROOTFS_PATH >> output/kernels.toml + echo >> output/kernels.toml + done done -find output -type f | grep -v init | grep -v '/vmlinuz' | xargs rm +find output -type f | grep -v init | grep -v '/vmlinuz' | grep -v kernels.toml | xargs rm find output/* -type d | xargs rm -rf