Adding templating to support multiple Ubuntu versions

Renaming images to be more generic and not tied to Trusty

Have both pkgbuilder and kernelbuilder support multiple versions of Ubuntu
master
gdm85 9 years ago
parent db73573b58
commit e7eacc9d2e

@ -1,13 +1,12 @@
#!/bin/bash
## @author gdm85
##
## build a base Ubuntu Trusty
## build a base Ubuntu image, can be Trusty, Wily etc
#
BASENAME=$(dirname $(readlink -m $0))
## the distro we are going to use
DISTNAME=trusty
REPOSRC=http://archive.ubuntu.com/ubuntu/
if [ ! $UID -eq 0 ]; then
@ -15,9 +14,16 @@ if [ ! $UID -eq 0 ]; then
exit 1
fi
if [ ! $# -eq 1 ]; then
echo "Usage: build-ubuntu-image.sh release-name" 1>&2
exit 2
fi
DISTNAME="$1"
## check for prerequisites
if ! type -P debootstrap >/dev/null; then
echo "You need to install debootstrap" 1&2
echo "You need to install debootstrap" 1>&2
exit 2
fi
@ -50,7 +56,6 @@ else
fi
echo "Will use $KEYRING"
exit 0
## NOTE: a temporary directory under /tmp is not used because can't be mounted dev/exec
mkdir $DISTNAME || exit $?

@ -1,7 +0,0 @@
FROM trusty-pkgbuilder
RUN apt-get build-dep -y --no-install-recommends linux-image-$(uname -r) && \
apt-get install -y git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev ## specific for kernel building
## add script for getting source
COPY build-kernel.sh /home/rdeckard/

@ -1,16 +0,0 @@
#!/bin/bash
set -e
apt-get source linux-image-$(uname -r)
cd linux-*
## will fail here if no patches are available
## why are you recompiling kernel if no custom patches are there?
for MYP in $(ls ../patches); do
patch -p1 < ../patches/$MYP
done
fakeroot debian/rules clean
DEB_BUILD_OPTIONS=parallel=3 AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic

@ -1,11 +0,0 @@
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

@ -0,0 +1,14 @@
FROM %IMAGE%-pkgbuilder
ENV KERNEL_VERSION %KERNEL_VERSION%
RUN apt-get build-dep -y --no-install-recommends linux-image-$KERNEL_VERSION && \
apt-get install -y git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev
USER rdeckard
## fetch source
RUN mkdir build && cd build && apt-get source linux-image-$KERNEL_VERSION
## add build script
COPY build-kernel.sh /home/rdeckard/

@ -0,0 +1,15 @@
ifeq ($(KERNEL_VERSION),)
KERNEL_VERSION := $(shell uname -r)
endif
linux-image-%:
mkdir -p packages
docker run -e KERNEL_VERSION=$(KERNEL_VERSION) -v $(CURDIR)/packages:/home/rdeckard/packages -v $(CURDIR)/patches:/home/rdeckard/patches:ro $*-kernelbuilder ./build-kernel.sh $(KERNEL_VERSION)
## supports any Ubuntu version (trusty, wily etc)
%:
TMPD=`mktemp -d` && cp build-kernel.sh "$$TMPD/" && \
sed -e 's~%IMAGE%~$*~g' -e 's~%KERNEL_VERSION%~$(KERNEL_VERSION)~' Dockerfile.tpl > "$$TMPD/Dockerfile" && cd "$$TMPD" && \
docker build --tag='$*-kernelbuilder' . && cd && rm -rf "$TMPD"
.DEFAULT: trusty

@ -0,0 +1,17 @@
#!/bin/bash
set -e
## enter the source-unpacked location
cd build/linux-*
## will fail here if no patches are available
for MYP in $(ls ../../patches); do
patch -p1 < ../../patches/$MYP
done
fakeroot debian/rules clean
DEB_BUILD_OPTIONS=parallel=4 AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic
mv ../*.deb $HOME/packages/

@ -1,13 +1,12 @@
## trusty-pkgbuilder
## ubuntu-pkgbuilder
##
## VERSION 0.1.0
## VERSION 0.1.1
##
## Trusty image to build kernel
## Ubuntu image to build a .deb package
##
#
## NOTE: this image must be debootstrapped with build-trusty.sh
FROM gdm85/trusty
FROM %IMAGE%
MAINTAINER Giuseppe Mazzotta "gdm85@users.noreply.github.com"
@ -24,3 +23,5 @@ RUN apt-get remove -y logrotate
## user that will make the compilation
RUN useradd -m -s /bin/bash rdeckard && mkdir /home/rdeckard/patches && chown rdeckard.rdeckard /home/rdeckard/patches
WORKDIR /home/rdeckard

@ -0,0 +1,7 @@
.DEFAULT: trusty
## supports any base Ubuntu image (gdm85/trusty, gdm85/wily etc)
## they should be generated with make-ubuntu-image.sh
%:
TMPD=`mktemp -d` && sed 's~%IMAGE%~gdm85/$@~g' Dockerfile.tpl > "$$TMPD/Dockerfile" && sed 's~%DIST%~$@~g' sources.list.tpl > "$$TMPD/sources.list" && cd "$$TMPD" && \
docker build --tag='$@-pkgbuilder' . && cd && rm -rf "$TMPD"

@ -0,0 +1,11 @@
deb http://archive.ubuntu.com/ubuntu/ %DIST% main restricted
deb-src http://archive.ubuntu.com/ubuntu/ %DIST% main restricted
deb http://archive.ubuntu.com/ubuntu/ %DIST%-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ %DIST%-updates main restricted
deb http://security.ubuntu.com/ubuntu %DIST%-security main restricted
deb-src http://security.ubuntu.com/ubuntu %DIST%-security main restricted
deb http://security.ubuntu.com/ubuntu %DIST%-security universe
deb-src http://security.ubuntu.com/ubuntu %DIST%-security universe
deb http://security.ubuntu.com/ubuntu %DIST%-security multiverse
deb-src http://security.ubuntu.com/ubuntu %DIST%-security multiverse
Loading…
Cancel
Save