mirror of
https://github.com/rancher/os-kernel.git
synced 2025-08-31 12:26:37 +00:00
Merge pull request #6 from imikushin/dapperize
Use dapper to build in container
This commit is contained in:
12
Dockerfile.dapper
Normal file
12
Dockerfile.dapper
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM ubuntu:14.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y build-essential wget libncurses5-dev unzip bc curl python rsync ccache git vim
|
||||
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ENV LANG en_US.UTF-8
|
||||
|
||||
ENV DAPPER_SOURCE /source
|
||||
ENV DAPPER_OUTPUT ./dist
|
||||
ENV SHELL /bin/bash
|
||||
WORKDIR ${DAPPER_SOURCE}
|
14
build.sh
14
build.sh
@@ -3,18 +3,6 @@ set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
export DOCKER_IMAGE=rancher-os-kernel-build
|
||||
|
||||
./scripts/ci
|
||||
|
||||
rm -rf dist
|
||||
|
||||
echo "Build complete. Copying artifacts..."
|
||||
|
||||
DIST_CONTAINER=$(docker create ${DOCKER_IMAGE})
|
||||
trap "docker rm -v ${DIST_CONTAINER}" EXIT
|
||||
|
||||
mkdir -p dist
|
||||
docker cp ${DIST_CONTAINER}:/source/dist/kernel dist/
|
||||
dapper ./scripts/ci
|
||||
|
||||
ls -lh dist/kernel
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
apt-get update
|
||||
apt-get install -y build-essential wget libncurses5-dev unzip bc curl python rsync ccache git
|
@@ -8,109 +8,6 @@ set -e
|
||||
: ${CONFIG:=$(pwd)/config}
|
||||
: ${DIST:=$(pwd)/dist}
|
||||
|
||||
DOCKER_FILE=${CONFIG}/.dockerfile
|
||||
|
||||
write_base()
|
||||
{
|
||||
if [ "${BASE_WRITTEN}" = "true" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p $(dirname ${DOCKER_FILE})
|
||||
|
||||
cat > ${DOCKER_FILE} << EOF
|
||||
FROM ${DOCKER_BASE:=ubuntu:14.04.3}
|
||||
ENV TERM xterm
|
||||
WORKDIR /source
|
||||
EOF
|
||||
|
||||
BASE_WRITTEN=true
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
local content
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
case $1 in
|
||||
--assets)
|
||||
shift 1
|
||||
if [ -e "$1" ]; then
|
||||
content="$content\nCOPY $1 /source/$1"
|
||||
else
|
||||
content="$content\nCOPY $1 /source/"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
shift 1
|
||||
done
|
||||
|
||||
write_base
|
||||
if [ -n "$content" ]; then
|
||||
echo -e "$content" >> ${DOCKER_FILE}
|
||||
fi
|
||||
if [ -n "$1" ]; then
|
||||
echo -e "\nCOPY $1 /source/$1" >> ${DOCKER_FILE}
|
||||
echo -e "RUN /source/$1" >> ${DOCKER_FILE}
|
||||
fi
|
||||
|
||||
if [ "$RUN_EXEC" = "true" ]; then
|
||||
$1
|
||||
fi
|
||||
}
|
||||
|
||||
finish()
|
||||
{
|
||||
if [ "$RUN_EXEC" = true ]; then
|
||||
return 0
|
||||
fi
|
||||
local cmd="docker build -t ${DOCKER_IMAGE} -f ${DOCKER_FILE} ."
|
||||
echo Running $cmd
|
||||
echo Pwd $(pwd)
|
||||
|
||||
cat ${DOCKER_FILE}
|
||||
|
||||
$cmd
|
||||
}
|
||||
|
||||
reset_docker_build()
|
||||
{
|
||||
BASE_WRITTEN=false
|
||||
}
|
||||
|
||||
check()
|
||||
{
|
||||
local hash=$1
|
||||
local file=$2
|
||||
|
||||
if [ ! -e "$file" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
CURRENT=$(sha1sum $file | awk '{print $1}')
|
||||
|
||||
[ "$hash" = "$CURRENT" ]
|
||||
}
|
||||
|
||||
download()
|
||||
{
|
||||
mkdir -p ${ARTIFACTS}
|
||||
|
||||
local url=$2
|
||||
local file=${ARTIFACTS}/$(basename $2)
|
||||
local hash=$1
|
||||
|
||||
if ! check $hash $file; then
|
||||
curl -sL $url > $file
|
||||
fi
|
||||
|
||||
if ! check $hash $file; then
|
||||
echo "ERROR: $file does not match checksum $hash, got $CURRENT" 1>&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
list_build_files() {
|
||||
find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl
|
||||
find $(find ./arch/${SRCARCH} -name include -o -name scripts -type d) ./include ./scripts -type f
|
||||
|
@@ -29,6 +29,7 @@ fi
|
||||
cd ${DIR}
|
||||
cp ${CONFIG}/kernel-config .config
|
||||
|
||||
# TODO update config/kernel-config for the latest kernel
|
||||
make oldconfig
|
||||
make -j$(nproc) tar-pkg
|
||||
|
||||
|
14
scripts/ci
14
scripts/ci
@@ -3,15 +3,5 @@ set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
DOCKER_IMAGE=${DOCKER_IMAGE:=rancher-os-kernel-build}
|
||||
|
||||
source scripts/build-common
|
||||
|
||||
run --assets ./scripts/build-common \
|
||||
./scripts/bootstrap
|
||||
run ./scripts/download
|
||||
run --assets ./scripts/firmware
|
||||
run --assets ./config/kernel-config \
|
||||
./scripts/build-kernel
|
||||
|
||||
finish
|
||||
./scripts/download
|
||||
./scripts/build-kernel
|
||||
|
@@ -6,4 +6,36 @@ cd $(dirname $0)/..
|
||||
|
||||
source scripts/build-common
|
||||
|
||||
check()
|
||||
{
|
||||
local hash=$1
|
||||
local file=$2
|
||||
|
||||
if [ ! -e "$file" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
CURRENT=$(sha1sum $file | awk '{print $1}')
|
||||
|
||||
[ "$hash" = "$CURRENT" ]
|
||||
}
|
||||
|
||||
download()
|
||||
{
|
||||
mkdir -p ${ARTIFACTS}
|
||||
|
||||
local url=$2
|
||||
local file=${ARTIFACTS}/$(basename $2)
|
||||
local hash=$1
|
||||
|
||||
if ! check $hash $file; then
|
||||
curl -sL $url > $file
|
||||
fi
|
||||
|
||||
if ! check $hash $file; then
|
||||
echo "ERROR: $file does not match checksum $hash, got $CURRENT" 1>&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
download ${KERNEL_SHA1} ${KERNEL_URL}
|
||||
|
Reference in New Issue
Block a user