#!/bin/bash
set -e
cd "$(dirname "$0")"
cd ..
mkdir -p ./dependencies
rootdir=$(dirname "$0")
dir=./$(dirname "$0")
cd dependencies
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
cd "$(dirname "$0")"
cd ..
echo $PWD
cp ./config/kernel_options.json ./dependencies/linux/kernel_options.json
cat ./config/build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest .
nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./dependencies/linux:/linux patronagekernel:latest
mkdir -p ./outputs/
cp ./dependencies/linux/arch/x86_64/boot/bzImage ./outputs/bzImage
