diff --git a/Dockerfile b/Dockerfile index 291e510..6715a78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,13 +12,10 @@ RUN apt update \ bash \ git \ ca-certificates \ - curl \ - gpg \ - dirmngr libssl-dev COPY docker/entrypoint.sh /tmp COPY src/ /tmp WORKDIR /tmp CMD /tmp/entrypoint.sh -CMD bash +#CMD bash diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8dd93b7..049580f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,11 +1,8 @@ #!/bin/bash # Entrypoint for reform-build-kernel docker image -OUTPUT="/output/$KERNEL_VERSION" -[[ -d "$OUTPUT" ]] || mkdir "$OUTPUT" - -if [ -f "$OUTPUT/Image" ] +if [ -f /output/Image ] then printf "Kernel image exist in destination aborting compilation.\n" exit 0 @@ -13,9 +10,9 @@ fi if ./make_kernel.sh then - cp linux/arch/arm64/boot/Image "$OUTPUT" - cp linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2.dtb "$OUTPUT/imx8mq-mnt-reform2-single-display.dtb" - cp linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dtb "$OUTPUT/imx8mq-mnt-reform2-dual-display.dtb" + cp linux/arch/arm64/boot/Image /output/ + cp linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2.dtb /output/imx8mq-mnt-reform2-single-display.dtb + cp linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dtb /output/imx8mq-mnt-reform2-dual-display.dtb else printf "Error when building Kernel\n" 1>&2 exit 10 diff --git a/src/make_kernel.sh b/src/make_kernel.sh index c1a085b..2f52094 100755 --- a/src/make_kernel.sh +++ b/src/make_kernel.sh @@ -23,42 +23,10 @@ function error { >&2 printf "\e[31mE\e[0m %s\n" "$1" } -function download { - - local filename url http_response - filename="$1" - url="$2" - - printf "Downloading %s: " "$filename" - http_response=$(curl -o /dev/null -s -L -I -w "%{http_code}\n" "$url") - if [ "$http_response" -eq 200 ] - then - if curl -o "$filename" "$url" -s >/dev/null 2>&1 - then - printf " done\n" - else - printf "unknown error\n" - return 1 - fi - else - printf "error 404\n" - return 1 - fi - return 0 -} - export ARCH=arm64 #export LOADADDR=0x40480000 export CROSS_COMPILE=aarch64-linux-gnu- - -for c in curl gunzip tar gpg git -do - if ! command -v "$c" >/dev/null - then - error "This script need $c to work properly" - exit 5 - fi -done +GIT_URL="https://github.com/torvalds/linux/" if [ ! -z $1 ] then @@ -69,49 +37,20 @@ if [ -z "$KERNEL_VERSION" ] then error "You need to define KERNEL_VERSION env variable" usage - exit 1 + exit 10 fi -major_version=$(echo "$KERNEL_VERSION" | awk -F "." '{print $1}') -url="https://cdn.kernel.org/pub/linux/kernel/v${major_version}.x/linux-${KERNEL_VERSION}.tar.xz" -url_sign="https://cdn.kernel.org/pub/linux/kernel/v${major_version}.x/linux-${KERNEL_VERSION}.tar.sign" - if [ ! -d linux ] then - - printf "Get Linux source file for version %s\n" "${KERNEL_VERSION}" - if ! gpg --locate-keys torvalds@kernel.org gregkh@kernel.org >/dev/null + printf "Cloning Linux...\n" + # temporary linux 5.11rc7 commit + if ! git clone --depth 1 --branch=v${KERNEL_VERSION} $GIT_URL then - error "Can't get gpg pubkey for Linux Torvald and Greg Kroah-Hartman" - exit 10 - fi - - if ! download linux.tar.xz "$url" - then - error "Can't get linux tarball, check version" + error "Can't clone Linux, check version" exit 11 fi - - if ! download linux.tar.sign "$url_sign" - then - error "Can't get linux tarball, check version" - exit 11 - fi - - # verify signature - if ! xz -cd linux.tar.xz | gpg --trust-model tofu --verify linux.tar.sign - >/dev/null - then - error "problem with signature" - exit 12 - fi - if ! xz -cd linux.tar.xz | tar -x - then - error "Cant extract linux tarball" - exit 13 - fi - mv "linux-${KERNEL_VERSION}" linux fi -exit 0 + cp ./dts/*.dts ./linux/arch/arm64/boot/dts/freescale/ cp ./kernel-config ./linux/.config