diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 244916f..fc1605c 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -28,7 +28,7 @@ ARG DOWNLOADS_DIR=/usr/src/downloads ARG KERNEL_ARCH=arm64 ARG KERNEL_URL=https://github.com/raspberrypi/linux.git ARG KERNEL_BRANCH=rpi-4.14.y -ARG KERNEL_VERSION=v4.14.114-rancher +ARG KERNEL_VERSION=4.14.114 ARG FIRMWARE_URL=https://github.com/raspberrypi/firmware.git ARG FIRMWARE_BRANCH=master diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..ed51376 --- /dev/null +++ b/scripts/build @@ -0,0 +1,46 @@ +#!/bin/bash +set -e + +source $(dirname $0)/color +cd $(dirname $0)/.. + +DEF_CONFIG=${DEFCONFIG:="bcmrpi3_defconfig"} +MAKE_CMD="make -j $(nproc) ARCH=$KERNEL_ARCH" + +echo "`yellow [START]` build kernel and modules..." + pushd ${DOWNLOADS}/kernel + # add kernel branding for rancheros + sed -i 's/^EXTRAVERSION =.*/EXTRAVERSION = -rancheros/g' Makefile + export LOCALVERSION="" + + # configure the kernel + $MAKE_CMD $DEF_CONFIG + + # copy .config to the /source/build/kernel directory + KERNEL_RELEASE=$($MAKE_CMD kernelrelease | grep "^4") + cp .config /source/build/kernel/$KERNEL_RELEASE.config + + # build kernel and modules + $MAKE_CMD + $MAKE_CMD modules + + # install kernel modules + INSTALL_DIR=${DOWNLOADS}/kernel/$KERNEL_RELEASE + if [[ -d $INSTALL_DIR ]]; then + rm -rf $INSTALL_DIR + mkdir -p $INSTALL_DIR + fi + $MAKE_CMD INSTALL_MOD_PATH=$INSTALL_DIR modules_install + rm $INSTALL_DIR/lib/modules/$KERNEL_RELEASE/{build,source} + + # build kernel modules' dependencies + depmod -a -b $INSTALL_DIR $KERNEL_RELEASE + + # install kernel, dtb and overlays + mkdir -p $INSTALL_DIR/boot/overlays + cp arch/arm64/boot/Image $INSTALL_DIR/boot/kernel8.img + cp arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb $INSTALL_DIR/boot/ + cp arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb $INSTALL_DIR/boot/ + cp arch/arm64/boot/dts/overlays/*.dtbo $INSTALL_DIR/boot/overlays/ + popd +echo "`green [FINISHED]` build kernel and modules..." \ No newline at end of file diff --git a/scripts/ci b/scripts/ci index 4a5f226..a5dc3bf 100755 --- a/scripts/ci +++ b/scripts/ci @@ -1,7 +1,8 @@ #!/bin/bash set -e -source $(dirname $0)/version cd $(dirname $0)/.. -./scripts/download \ No newline at end of file +./scripts/download +./scripts/build +./scripts/package \ No newline at end of file diff --git a/scripts/download b/scripts/download index 8579dda..59a4c0f 100755 --- a/scripts/download +++ b/scripts/download @@ -1,7 +1,6 @@ #!/bin/bash set -e -source $(dirname $0)/version source $(dirname $0)/color cd $(dirname $0)/.. diff --git a/scripts/package b/scripts/package new file mode 100755 index 0000000..6d9a895 --- /dev/null +++ b/scripts/package @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +source $(dirname $0)/color +cd $(dirname $0)/.. + +: ${PACKAGE_KERNEL_DIR:=/source/dist/kernel} +: ${PACKAGE_FIRMWARE_DIR:=/source/dist/firmware} +: ${INSTALL_DIR:=$KERNEL_VERSION-rancheros-v8} +: ${KERNEL_CONFIG:=$KERNEL_VERSION-rancheros-v8.config} + +echo "`yellow [STARTING]` prepare package directories..." + mkdir -p $PACKAGE_KERNEL_DIR + mkdir -p $PACKAGE_FIRMWARE_DIR +echo "`green [FINISHED]` prepare package directories..." + +echo "`yellow [STARTING]` package kernel files..." + pushd ${DOWNLOADS}/kernel + tar -cvzf $KERNEL_VERSION-rancheros-v8.tar.gz -C $INSTALL_DIR . + sha256sum $KERNEL_VERSION-rancheros-v8.tar.gz > $KERNEL_VERSION-rancheros-v8.tar.gz.sha256 + popd +echo "`green [FINISHED]` package kernel files..." + +echo "`yellow [STARTING]` package boot files..." + pushd ${DOWNLOADS}/kernel + tar -cvzf bootfiles.tar.gz -C $INSTALL_DIR/boot . + sha256sum bootfiles.tar.gz > bootfiles.tar.gz.sha256 + popd +echo "`green [FINISHED]` package boot files..." + +echo "`yellow [START]` package firmware files..." + pushd ${DOWNLOADS}/firmware + FILE_LIST=" + boot/LICENCE.* + boot/bootcode.bin + boot/fixup*.dat + boot/start*.elf + " + tar -cvzf rpi-bootloader.tar.gz $FILE_LIST + sha256sum rpi-bootloader.tar.gz > rpi-bootloader.tar.gz.sha256 + popd +echo "`green [FINISHED]` build firmware files..." + +echo "`yellow [STARTING]` copy necessary files to the dest..." + pushd ${DOWNLOADS}/kernel + cp $KERNEL_VERSION-rancheros-v8.tar.gz* $PACKAGE_KERNEL_DIR + cp bootfiles.tar.gz* $PACKAGE_KERNEL_DIR + cp /source/build/kernel/$KERNEL_CONFIG $PACKAGE_KERNEL_DIR + popd + pushd ${DOWNLOADS}/firmware + cp rpi-bootloader.tar.gz* $PACKAGE_FIRMWARE_DIR + popd + echo "v$KERNEL_VERSION-rancher" > /source/dist/version +echo "`green [FINISHED]` copy necessary files to the dest..." + diff --git a/scripts/publish b/scripts/publish new file mode 100755 index 0000000..cc5c3a3 --- /dev/null +++ b/scripts/publish @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +VERSION=$(cat dist/version) + +for file in $(ls dist/kernel); do + github-release upload --user Jason-ZW --repo os-raspberrypi --tag ${VERSION} --file ./dist/kernel/${file} --name ${file} +done + +for file in $(ls dist/firmware); do + github-release upload --user Jason-ZW --repo os-raspberrypi --tag ${VERSION} --file ./dist/firmware/${file} --name ${file} +done \ No newline at end of file diff --git a/scripts/version b/scripts/version deleted file mode 100755 index fd8fe2c..0000000 --- a/scripts/version +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -e - -if [ -n "$(git status --porcelain --untracked-files=no)" ]; then - DIRTY="-dirty" -fi - -COMMIT=$(git rev-parse --short HEAD) - -GIT_TAG=$(git tag -l --contains HEAD | head -n 1) - -if [ -z "$VERSION" ]; then - if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then - VERSION=$GIT_TAG - else - VERSION="${COMMIT}${DIRTY}" - fi -fi - -INITRD=initrd-${VERSION} - -SUFFIX="" -if [ -n "${ARCH}" ] && [ "${ARCH}" != "amd64" ]; then - SUFFIX="_${ARCH}" -fi - -export VERSION COMMIT INITRD GIT_TAG DIRTY SUFFIX -