Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ./Docker.build command for easier building
- Loading branch information
Showing
7 changed files
with
143 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Docker.build | ||
Docker.out | ||
Dockerfile | ||
|
||
.cache | ||
.dockerignore | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Docker.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
cd "$(dirname "$0")" # jump to curdir | ||
|
||
# Take version from changelog; docker takes fewer legal chars. | ||
buildversion=$(sed -e '1!d;s/.*(//;s/).*//' changelog) | ||
upversion=$(echo "$buildversion" | sed -e 's/-.*//;s/^[0-9]*://') | ||
debepoch=$(echo "$buildversion" | sed -e '/^[0-9]*:/!d;s/:.*/:/') | ||
debversion=$(echo "$buildversion" | sed -e 's/[^-]*-//;s/+[^+]*$//') | ||
dockname=$(basename $(pwd)) | ||
dockversion=$(echo "$buildversion" | sed -e 's/^[0-9]*://;s/[^A-Za-z0-9.-]/_/g') | ||
|
||
# Build for stretch. | ||
codename=stretch # don't change unless you fix "FROM debian:stretch" | ||
|
||
# Build. | ||
docker build \ | ||
--build-arg upversion=$upversion \ | ||
--build-arg debepoch=$debepoch \ | ||
--build-arg debversion=$debversion \ | ||
-t $dockname:$dockversion -f Dockerfile . || exit 1 | ||
|
||
# Run, so we export the compiled packages. | ||
docker run -e UID=$(id -u) \ | ||
-v "$(pwd)/Docker.out/$codename:/Docker.out/$codename" \ | ||
$dockname:$dockversion || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
FROM debian:stretch | ||
MAINTAINER Walter Doekes <wjdoekes+bcg729@osso.nl> | ||
|
||
# This one should be before the From, but it's not legal for Docker 1.13 | ||
# yet. Use a hack to s/debian:stretch/debian:OTHER/g above instead. | ||
ARG oscodename=stretch | ||
ARG upname=bcg729 | ||
ARG upversion=1.0.4 | ||
ARG debepoch= | ||
ARG debversion=0osso0 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Copy debian dir, check version | ||
RUN mkdir -p /build/debian | ||
COPY ./changelog /build/debian/changelog | ||
RUN . /etc/os-release && fullversion="${upversion}-${debversion}+${ID%%[be]*}${VERSION_ID}" && \ | ||
expected="${upname} (${debepoch}${fullversion}) ${oscodename}; urgency=medium" && \ | ||
head -n1 /build/debian/changelog && \ | ||
if test "$(head -n1 /build/debian/changelog)" != "${expected}"; \ | ||
then echo "${expected} <-- mismatch" >&2; false; fi | ||
|
||
# This time no "keeping the build small". We only use this container for | ||
# building/testing and not for running, so we can keep files like apt | ||
# cache. | ||
RUN echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/01norecommends | ||
#RUN sed -i -e 's:deb.debian.org:apt.osso.nl:;s:security.debian.org:apt.osso.nl/debian-security:' /etc/apt/sources.list | ||
#RUN sed -i -e 's:security.ubuntu.com:apt.osso.nl:;s:archive.ubuntu.com:apt.osso.nl:' /etc/apt/sources.list | ||
#RUN printf 'deb http://ppa.osso.nl/ubuntu xenial acos\n\ | ||
#deb-src http://ppa.osso.nl/ubuntu xenial acos\r\n' >/etc/apt/sources.list.d/osso-ppa.list | ||
#RUN apt-key adv --keyserver pgp.mit.edu --recv-keys 0xBEAD51B6B36530F5 | ||
RUN apt-get update -q | ||
RUN apt-get install -y apt-utils | ||
RUN apt-get dist-upgrade -y | ||
RUN apt-get install -y \ | ||
bzip2 ca-certificates curl git \ | ||
build-essential dh-autoreconf devscripts dpkg-dev equivs quilt | ||
|
||
# Set up upstream source, move debian dir and jump into dir. | ||
# | ||
# Trick to allow caching of asterisk*.tar.gz files. Download them | ||
# once using the curl command below into .cache/* if you want. The COPY | ||
# is made conditional by the "[2]" "wildcard". (We need one existing | ||
# file (README.rst) so the COPY doesn't fail.) | ||
COPY ./README.rst .cache/${upname}_${upversion}.orig.tar.g[z] /build/ | ||
RUN if ! test -s /build/${upname}_${upversion}.orig.tar.gz; then \ | ||
url="https://codeload.github.com/BelledonneCommunications/bcg729/tar.gz/${upversion}" && \ | ||
echo "Fetching: ${url}" >&2 && \ | ||
curl --fail "${url}" >/build/${upname}_${upversion}.orig.tar.gz; fi | ||
RUN test $(md5sum /build/bcg729_1.0.4.orig.tar.gz | awk '{print $1}') = 0234814618a4314cb56ae0b9084d1ae1 | ||
RUN cd /build && tar zxf "${upname}_${upversion}.orig.tar.gz" && \ | ||
mv debian "${upname}-${upversion}/" | ||
WORKDIR "/build/${upname}-${upversion}" | ||
|
||
# Apt-get prerequisites according to control file. | ||
COPY ./control debian/control | ||
RUN mk-build-deps --install --remove --tool "apt-get -y" debian/control | ||
|
||
# Set up build env | ||
RUN printf "%s\n" \ | ||
QUILT_PATCHES=debian/patches \ | ||
QUILT_NO_DIFF_INDEX=1 \ | ||
QUILT_NO_DIFF_TIMESTAMPS=1 \ | ||
'QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"' \ | ||
'QUILT_DIFF_OPTS="--show-c-function"' \ | ||
>~/.quiltrc | ||
COPY . debian/ | ||
|
||
# Build! | ||
RUN DEB_BUILD_OPTIONS=parallel=6 dpkg-buildpackage -us -uc -sa | ||
|
||
# TODO: for bonus points, we could run quick tests here; | ||
# for starters dpkg -i tests? | ||
|
||
# Write output files (store build args in ENV first). | ||
ENV oscodename=$oscodename \ | ||
upname=$upname upversion=$upversion debversion=$debversion | ||
CMD . /etc/os-release && fullversion=${upversion}-${debversion}+${ID%%[be]*}${VERSION_ID} && \ | ||
dist=Docker.out && \ | ||
if ! test -d "/${dist}"; then echo "Please mount ./${dist} for output" >&2; false; fi && \ | ||
echo && . /etc/os-release && mkdir "/${dist}/${oscodename}/${upname}_${fullversion}" && \ | ||
mv /build/*${fullversion}* "/${dist}/${oscodename}/${upname}_${fullversion}/" && \ | ||
mv /build/${upname}_${upversion}.orig.tar.gz "/${dist}/${oscodename}/${upname}_${fullversion}/" && \ | ||
chown -R ${UID}:root "/${dist}/${oscodename}" && \ | ||
cd / && find "${dist}/${oscodename}/${upname}_${fullversion}" -type f && \ | ||
echo && echo 'Output files created succesfully' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters