Skip to content

Commit

Permalink
Add ./Docker.build command for easier building
Browse files Browse the repository at this point in the history
  • Loading branch information
wdoekes committed Sep 17, 2018
1 parent 61d4ee8 commit cffd014
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
@@ -0,0 +1,7 @@
Docker.build
Docker.out
Dockerfile

.cache
.dockerignore
.git
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/Docker.out
25 changes: 25 additions & 0 deletions Docker.build
@@ -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
86 changes: 86 additions & 0 deletions Dockerfile
@@ -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'
16 changes: 14 additions & 2 deletions README.rst
@@ -1,5 +1,17 @@
OSSO build of the Bcg729 G729 speech codec
==========================================
OSSO build of the Bcg729 shared library (G729 speech codec)
===========================================================

Using Docker::

./Docker.build

If the build succeeds, the built Debian packages are placed inside (a
subdirectory of) ``Docker.out/``.


------------
Manual build
------------

Get source::

Expand Down
8 changes: 8 additions & 0 deletions changelog
@@ -1,3 +1,11 @@
bcg729 (1.0.4-0osso2+d9) stretch; urgency=medium

* Rename from +deb9 to +d9.
* Add ./Docker.build to build instructions.
* Add missing wget/unzip to control file (required by tests).

-- Walter Doekes <wjdoekes+bcg729@osso.nl> Mon, 17 Sep 2018 17:37:29 +0200

bcg729 (1.0.4-0osso1+deb9) stretch; urgency=medium

* Bump bcg729 lib to 1.0.4; fix version in configure.ac.
Expand Down
3 changes: 2 additions & 1 deletion control
Expand Up @@ -6,7 +6,8 @@ Build-Depends:
debhelper (>= 9),
autotools-dev,
dh-autoreconf,
pkg-config
pkg-config,
unzip, wget
Standards-Version: 3.9.6
Section: libs
Homepage: http://www.linphone.org/technical-corner/bcg729/overview
Expand Down

0 comments on commit cffd014

Please sign in to comment.