Last active
September 7, 2015 19:13
-
-
Save tianon/7ade2c1eda367f0a320c to your computer and use it in GitHub Desktop.
backport-criu; usage: ./build.sh
This file contains hidden or 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
#!/bin/bash | |
set -eo pipefail | |
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" | |
img='backport-criu' | |
rm -rf *.orig.tar.* */ Dockerfile.* *.deb | |
docker build -t "$img" . | |
docker run -i --rm "$img" sh -c 'tar -c *.orig.tar.* */' | tar -x | |
for suite in */; do | |
suite="${suite%/}" | |
from='' | |
for base in debian ubuntu; do | |
if docker inspect "$base:$suite" &> /dev/null; then | |
from="$base:$suite" | |
break | |
fi | |
done | |
if [ -z "$from" ]; then | |
echo >&2 "ERROR: cannot determine whether $suite is Ubuntu or Debian" | |
echo >&2 ' try: docker pull -a debian && docker pull -a ubuntu' | |
exit 1 | |
fi | |
dockerfile="Dockerfile.$suite" | |
cat > "$dockerfile" <<-EOF | |
FROM $from | |
RUN apt-get update && apt-get install -y --no-install-recommends build-essential devscripts equivs fakeroot | |
EOF | |
case "$suite" in | |
trusty) | |
echo 'RUN apt-get update && apt-get install -y --no-install-recommends wget' >> "$dockerfile" | |
dscs=( | |
'protobuf-c_1.0.2-1' | |
) | |
for dsc in "${dscs[@]}"; do | |
url="http://httpredir.debian.org/debian/pool/main/${dsc:0:1}/${dsc%_*}/$dsc.dsc" | |
cat >> "$dockerfile" <<-EOF | |
RUN set -x \ | |
&& cd /tmp \ | |
&& dget -du '$url' \ | |
&& dpkg-source -x '$dsc.dsc' '$dsc' \ | |
&& cd '$dsc' \ | |
&& dch --distribution '$suite' --local '~$suite' 'Backport to $suite.' \ | |
&& mk-build-deps -irt'apt-get --no-install-recommends -yV' debian/control && dpkg-checkbuilddeps \ | |
&& dpkg-buildpackage -uc -us \ | |
&& cd .. \ | |
&& dpkg -i *.deb \ | |
&& mv *.deb /usr/src/ \ | |
&& rm -rf '${dsc%_*}_'* | |
EOF | |
done | |
;; | |
esac | |
cat >> "$dockerfile" <<-EOF | |
WORKDIR /usr/src/pkg | |
COPY $suite/debian/control /usr/src/pkg/debian/ | |
RUN mk-build-deps -irt'apt-get --no-install-recommends -yV' debian/control && dpkg-checkbuilddeps | |
COPY *.orig.tar.* /usr/src/ | |
COPY $suite /usr/src/pkg | |
RUN chown -R nobody:nogroup /usr/src | |
USER nobody:nogroup | |
RUN dpkg-buildpackage -uc -us | |
EOF | |
docker build -t "$img:$suite" -f "$dockerfile" . | |
rm -rf "$dockerfile" "$suite/" | |
docker run -i --rm "$img:$suite" sh -c 'tar -c ../*.deb' | tar -xv | |
done |
This file contains hidden or 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
FROM debian:sid | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
debian-keyring \ | |
devscripts \ | |
dpkg-dev \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
ENV DEBFULLNAME Docker | |
ENV DEBEMAIL [email protected] | |
RUN mkdir -p /usr/src && chown -R nobody:nogroup /usr/src | |
USER nobody:nogroup | |
WORKDIR /usr/src | |
ENV CRIU_VERSION 1.6-2 | |
ENV CRIU_DSC http://httpredir.debian.org/debian/pool/main/c/criu/criu_${CRIU_VERSION}.dsc | |
RUN dget -d "${CRIU_DSC}" | |
# TODO revisit whether wheezy is worth backporting the universe for :/ | |
ENV BACKPORT_SUITES \ | |
jessie \ | |
trusty vivid | |
RUN set -ex \ | |
&& for suite in $BACKPORT_SUITES; do \ | |
dpkg-source -x *.dsc "$suite"; \ | |
( \ | |
cd "$suite"; \ | |
dch --distribution "$suite" --local "~$suite" "Backport to $suite."; \ | |
) \ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment