Skip to content

Commit

Permalink
Merge pull request #4 from Magnitus-/master
Browse files Browse the repository at this point in the history
Greater Composability + Script to Retrieve Kernel Version From Repo
  • Loading branch information
DieterReuter authored Mar 19, 2018
2 parents b0a3a85 + 8901f48 commit f0ef595
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM debian:jessie

WORKDIR /workdir
ENV LINUX=/workdir/rpi64-linux
ENV LINUX=/workdir/rpi64-linux \
RPI_KERNEL_REPO=https://www.github.com/raspberrypi/linux \
RPI_KERNEL_BRANCH=rpi-4.9.y \
TIMESTAMP_OUTPUT=true

# Install build dependencies
RUN apt-get update && \
Expand All @@ -13,8 +16,8 @@ RUN mkdir -p /opt/linaro && \
ENV CROSS_COMPILE=/opt/linaro/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

# Get the Linux kernel 4.9 source
RUN git clone --single-branch --branch rpi-4.9.y --depth 1 https://www.github.com/raspberrypi/linux $LINUX
RUN git clone --single-branch --branch $RPI_KERNEL_BRANCH --depth 1 $RPI_KERNEL_REPO $LINUX

COPY defconfigs/ /defconfigs/
COPY build-kernel.sh /
COPY build-kernel.sh get-kernel-version.sh refresh-repo.sh /
CMD ["/build-kernel.sh"]
32 changes: 7 additions & 25 deletions build-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,15 @@ set -x
# Create target dir for build artefacts
WORKDIR=$PWD
BUILD_NR=${BUILD_NR:=$(date '+%Y%m%d-%H%M%S')}
BUILD_DEST=/builds/$BUILD_NR
mkdir -p $BUILD_DEST

# Get the Linux kernel 4.9 source
if [[ -z "$RPI_KERNEL_BRANCH" ]]; then
RPI_KERNEL_BRANCH=rpi-4.9.y
fi

if [ -d $LINUX ]; then
# update kernel repo
cd $LINUX
CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
if [ "$CURRENT_BRANCH" == "$RPI_KERNEL_BRANCH" ]; then
git pull
git checkout $RPI_KERNEL_BRANCH
else
cd ..
rm -rf $LINUX
mkdir -p $LINUX
git clone --single-branch --branch $RPI_KERNEL_BRANCH --depth 1 https://www.github.com/raspberrypi/linux $LINUX
cd $LINUX
fi
if [ "$TIMESTAMP_OUTPUT" == "true" ]; then
BUILD_DEST=/builds/$BUILD_NR
else
# clone kernel repo
git clone --single-branch --branch $RPI_KERNEL_BRANCH --depth 1 https://www.github.com/raspberrypi/linux $LINUX
cd $LINUX
BUILD_DEST=/builds
fi
mkdir -p $BUILD_DEST

/refresh-repo.sh;
cd $LINUX

# Accept custom defconfig
DEFCONFIG=${DEFCONFIG:="bcmrpi3_defconfig"}
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ services:
environment:
- BUILD_NR
- DEFCONFIG
- RPI_KERNEL_BRANCH
volumes:
- ./builds:/builds
24 changes: 24 additions & 0 deletions get-kernel-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

/refresh-repo.sh >/dev/null 2>/dev/null

VERSION=$(grep "^VERSION = " $LINUX/Makefile | sed -n -e 's/^VERSION\s=\s\(.*\)/\1/p')
PATCH_LEVEL=$(grep "^PATCHLEVEL = " $LINUX/Makefile | sed -n -e 's/^PATCHLEVEL\s=\s\(.*\)/\1/p')
SUB_LEVEL=$(grep "^SUBLEVEL = " $LINUX/Makefile | sed -n -e 's/^SUBLEVEL\s=\s\(.*\)/\1/p')
EXTRA_VERSION=$(grep "^EXTRAVERSION = " $LINUX/Makefile | sed -n -e 's/^EXTRAVERSION\s=\s\(.*\)/\1/p')

OUTPUT_VERSION=$VERSION

if [ ! -z "$PATCH_LEVEL" ]; then
OUTPUT_VERSION="${OUTPUT_VERSION}.${PATCH_LEVEL}"
fi

if [ ! -z "$SUB_LEVEL" ]; then
OUTPUT_VERSION="${OUTPUT_VERSION}.${SUB_LEVEL}"
fi

if [ ! -z "$EXTRA_VERSION" ]; then
OUTPUT_VERSION="${OUTPUT_VERSION}${EXTRA_VERSION}"
fi

echo $OUTPUT_VERSION
20 changes: 20 additions & 0 deletions refresh-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ -d $LINUX ]; then
# update kernel repo
cd $LINUX
CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
CURRENT_ORIGIN=$(git remote -v | grep origin | grep fetch | sed -n -e 's/^origin\s\(.*\)\s(fetch)/\1/p')
if [ "$CURRENT_BRANCH" == "$RPI_KERNEL_BRANCH" ] && [ "$CURRENT_ORIGIN" == "$RPI_KERNEL_REPO" ]; then
git pull
git checkout $RPI_KERNEL_BRANCH
else
cd ..
rm -rf $LINUX
mkdir -p $LINUX
git clone --single-branch --branch $RPI_KERNEL_BRANCH --depth 1 $RPI_KERNEL_REPO $LINUX
fi
else
# clone kernel repo
git clone --single-branch --branch $RPI_KERNEL_BRANCH --depth 1 $RPI_KERNEL_REPO $LINUX
fi

0 comments on commit f0ef595

Please sign in to comment.