Skip to content

Commit

Permalink
Build and package kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
rancher-sy-bot committed May 14, 2019
1 parent fb4ab0f commit 00d984d
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 46 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -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..."
5 changes: 3 additions & 2 deletions scripts/ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -e

source $(dirname $0)/version
cd $(dirname $0)/..

./scripts/download
./scripts/download
./scripts/build
./scripts/package
1 change: 0 additions & 1 deletion scripts/download
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
set -e

source $(dirname $0)/version
source $(dirname $0)/color
cd $(dirname $0)/..

Expand Down
55 changes: 55 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
@@ -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..."

12 changes: 12 additions & 0 deletions scripts/publish
Original file line number Diff line number Diff line change
@@ -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
28 changes: 0 additions & 28 deletions scripts/version

This file was deleted.

0 comments on commit 00d984d

Please sign in to comment.