1
0
mirror of https://github.com/rancher/os-kernel.git synced 2025-09-01 12:56:25 +00:00

hello world

This commit is contained in:
Ivan Mikushin
2015-08-05 21:53:05 +05:00
commit 4fe3d1044f
14 changed files with 4411 additions and 0 deletions

8
scripts/bootstrap Executable file
View File

@@ -0,0 +1,8 @@
#!/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

151
scripts/build-common Normal file
View File

@@ -0,0 +1,151 @@
#!/bin/bash
set -e
: ${ARTIFACTS:=$(pwd)/assets}
: ${BUILD:=$(pwd)/build}
: ${CONFIG:=$(pwd)/config}
: ${DIST:=$(pwd)/dist}
DOCKER_FILE=${CONFIG}/.dockerfile
mkdir -p ${BUILD} ${DIST}
busybox_install()
{
local conf=$1
local bbconf=$2
local target=$3
if [ "$#" = "2" ]; then
target=$2
bbconf=
fi
apt-get update
apt-get install -y build-essential wget libncurses5-dev unzip bc
cd ${BUILD}
local buildroot=$(ls -1 ${ARTIFACTS}/buildroot-*.tar.bz2)
if [ ! -e "${buildroot}" ]; then
echo "Failed to find busybox archive, found : ${buildroot}" 1>&2
return 1
else
buildroot=$(basename $buildroot)
fi
rm -rf ${buildroot/.tar.bz2//}
tar xvjf ${ARTIFACTS}/${buildroot}
cd ${buildroot/.tar.bz2//}
cp $conf .config
if [ -n "$bbconf" ]; then
cp $bbconf package/busybox/
fi
make oldconfig
make
cp output/images/rootfs.tar $target
}
write_base()
{
if [ "${BASE_WRITTEN}" = "true" ]; then
return
fi
mkdir -p $(dirname ${DOCKER_FILE})
cat > ${DOCKER_FILE} << EOF
FROM ${DOCKER_BASE:=ubuntu:14.04.2}
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
}

35
scripts/build-kernel Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
cd $(dirname $0)/..
source scripts/build-common
apt-get install -y build-essential libncurses5-dev bc ccache
export CCACHE_DIR="${HOME}/.kernel-ccache"
export CC="ccache gcc"
export PATH="/usr/lib/ccache:$PATH"
KERNEL="$(cd ${ARTIFACTS}; echo Ubuntu-*.tar.*)"
DIR=linux-${KERNEL/.tar.*//}
cd ${BUILD}
if [ ! -e ${DIR} ]; then
echo Extracting ${ARTIFACTS}/Ubuntu-*.tar.*
TEMP=$(mktemp -d -p ${BUILD})
trap "rm -rf ${TEMP}" exit
tar xf ${ARTIFACTS}/Ubuntu-*.tar.* -C $TEMP
mv ${TEMP}/${DIR} ${DIR}
fi
cd ${DIR}
cp ${CONFIG}/kernel-config .config
make oldconfig
make -j$(nproc) tar-pkg
mkdir -p ${DIST}/kernel
mv linux*.tar ${DIST}/kernel
make headers_install INSTALL_HDR_PATH=${DIST}/kernel/headers

17
scripts/ci Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
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 ./config/kernel-config \
./scripts/build-kernel
run ./scripts/package
finish

5
scripts/clean Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
cd $(dirname $0)/..
rm -rf build dist

41
scripts/download Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
set -e
set -x
cd $(dirname $0)/..
: ${ARTIFACTS:=$(pwd)/assets}
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 982ecdb9d2482e06d08e6ca02d8bef8787948061 https://github.com/rancherio/linux/archive/Ubuntu-3.19.0-22.22.tar.gz

7
scripts/package Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
cd $(dirname $0)/..
. scripts/build-common
mkdir -p ${DIST}/artifacts