Skip to content

Commit f9722fa

Browse files
committed
Initial import to Github.
0 parents  commit f9722fa

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DOCKER_NAME := madworx/debian-archive
2+
3+
all: build test
4+
5+
build:
6+
./build-archived-debian-image.sh $(DEBIAN_VERSION)
7+
8+
test:
9+
shellcheck -s ksh ./build-archived-debian-image.sh
10+
docker run $(DOCKER_NAME):$(DEBIAN_VERSION) -c 'echo `cat /etc/os-version.txt` ok'
11+
12+
push:
13+
docker push $(DOCKER_NAME):$(DEBIAN_VERSION)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Docker images for old (archived) Debian releases

build-archived-debian-image.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
set -eE
4+
set -o pipefail
5+
6+
export DIST=${1:-etch}
7+
export DOCKER_NAME=${2:-madworx/debian-archive}
8+
export DEBIAN_MIRROR=${DEBIAN_MIRROR:="http://ftp.hosteurope.de/mirror/archive.debian.org/debian/"}
9+
10+
# Check if rebuild is needed:
11+
LASTMOD=$(curl -sI "${DEBIAN_MIRROR}/dists/${DIST}/main/binary-i386/Packages.gz" | \
12+
sed -n 's#^last-modified: *##pi' | \
13+
sed -e 's#[^a-zA-Z0-9: -]##g')
14+
15+
echo "Last modification of source: ${LASTMOD}"
16+
17+
docker pull "${DOCKER_NAME}:${DIST}" 2>/dev/null 1>&2 || true
18+
CURRENTLAST="$(docker inspect --format='{{ index .Config.Labels "last_modified_src"}}' \
19+
"${DOCKER_NAME}:${DIST}" 2>/dev/null||echo 'non-existent')"
20+
21+
if [ "x${CURRENTLAST}" == "x${LASTMOD}" ] ; then
22+
echo "Rebuild not needed - upstream has last modification ${LASTMOD}."
23+
else
24+
#
25+
# We cannot build in one step, since the debootstrap process needs
26+
# --privilege.
27+
#
28+
docker build -t debian-archived-builder . -f - <<EOF
29+
FROM debian:stretch-slim
30+
RUN apt-get update && \
31+
apt-get install -y debootstrap
32+
ENTRYPOINT [ "/bin/bash", "-c" ]
33+
EOF
34+
35+
rm -f cif || true
36+
docker run \
37+
--privileged \
38+
--cidfile=cif \
39+
debian-archived-builder \
40+
"mkdir '/debian-${DIST}' \
41+
&& debootstrap --no-check-gpg \
42+
'${DIST}' '/debian-${DIST}' \
43+
'${DEBIAN_MIRROR}'"
44+
45+
STAGE1_ID="$(cat cif ; rm cif)"
46+
STAGE2_ID="$(docker commit "${STAGE1_ID}")"
47+
48+
docker build \
49+
-t "${DOCKER_NAME}:${DIST}" \
50+
--label "last_modified_src=${LASTMOD}" \
51+
. \
52+
-f - <<EOF
53+
FROM ${STAGE2_ID} AS build
54+
FROM scratch
55+
COPY --from=build /debian-${DIST} /
56+
RUN echo "debian:${DIST}" > /etc/os-version.txt
57+
ENTRYPOINT [ "/bin/sh" ]
58+
EOF
59+
docker rm "${STAGE1_ID}"
60+
fi
61+
62+

0 commit comments

Comments
 (0)