Skip to content

Commit f86df9a

Browse files
committed
chore(base): add debian source mirrors
1 parent d44ba1a commit f86df9a

20 files changed

Lines changed: 243 additions & 14 deletions

File tree

.woodpecker/build-linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ steps:
1515
- echo $CONTAINER_PASSWORD | podman login $DRYCC_REGISTRY --username $CONTAINER_USERNAME --password-stdin > /dev/null 2>&1
1616
- make clean build publish clean
1717
environment:
18+
SOURCES:
19+
from_secret: sources
1820
CODENAME:
1921
from_secret: codename
2022
DEV_REGISTRY:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clean:
1313
@rm -rf "${WORK_DIR}" "${WORK_DIR}".tar.gz
1414

1515
mkimage:
16-
./scripts/mkimage.sh minbase "${CODENAME}"
16+
./scripts/mkimage.sh minbase "${CODENAME}" "${SOURCES}"
1717

1818
podman-import:
1919
@podman import ${WORK_DIR}.tar.gz ${BASE_LAYER}

debootstrap/bookworm/rootfs/usr/bin/install-stack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function main() {
4949
echo "Extract data to a temporary directory: ${TMP_DIR}"
5050
tar --directory "${TMP_DIR}" --extract --gunzip --file "${TMP_DIR}"/"${stack_filename}" --no-same-owner
5151

52-
packages=$(grep -vE '^\s*(#|$)' "${TMP_DIR}"/meta/dependencies)
52+
packages=$(tr '\t\n' ' ' < "${TMP_DIR}/meta/dependencies" | tr -s ' ')
5353
if [[ -n "${packages:+x}" ]]; then
5454
echo "Install system packages: ${packages}"
5555
install-packages "$packages"

debootstrap/bookworm/rootfs/usr/sbin/install-packages

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function main {
99
until [ $n -gt $max ]; do
1010
set +e
1111
(
12-
apt-get update &&
13-
apt-get install -y --no-install-recommends "$@"
12+
eval "apt-get update; apt-get install -y --no-install-recommends $*"
1413
)
1514
CODE=$?
1615
set -e

debootstrap/bullseye/rootfs/usr/bin/install-stack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function main() {
4949
echo "Extract data to a temporary directory: ${TMP_DIR}"
5050
tar --directory "${TMP_DIR}" --extract --gunzip --file "${TMP_DIR}"/"${stack_filename}" --no-same-owner
5151

52-
packages=$(grep -vE '^\s*(#|$)' "${TMP_DIR}"/meta/dependencies)
52+
packages=$(tr '\t\n' ' ' < "${TMP_DIR}/meta/dependencies" | tr -s ' ')
5353
if [[ -n "${packages:+x}" ]]; then
5454
echo "Install system packages: ${packages}"
5555
install-packages "$packages"

debootstrap/bullseye/rootfs/usr/sbin/install-packages

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function main {
99
until [ $n -gt $max ]; do
1010
set +e
1111
(
12-
apt-get update &&
13-
apt-get install -y --no-install-recommends "$@"
12+
eval "apt-get update; apt-get install -y --no-install-recommends $*"
1413
)
1514
CODE=$?
1615
set -e
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Retry apt failures 3 times. See here for more information: https://linux.die.net/man/5/apt.conf
2+
Acquire::Retries 3;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Since Container users are looking for the smallest possible final images, the
2+
# following emerges as a very common pattern:
3+
4+
# RUN apt-get update \
5+
# && apt-get install -y <packages> \
6+
# && <do some compilation work> \
7+
# && apt-get purge -y --auto-remove <packages>
8+
9+
# By default, APT will actually _keep_ packages installed via Recommends or
10+
# Depends if another package Suggests them, even and including if the package
11+
# that originally caused them to be installed is removed. Setting this to
12+
# "false" ensures that APT is appropriately aggressive about removing the
13+
# packages it added.
14+
15+
# https://aptitude.alioth.debian.org/doc/en/ch02s05s05.html#configApt-AutoRemove-SuggestsImportant
16+
Apt::AutoRemove::SuggestsImportant "false";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Since for most Container users, package installs happen in "podman build" steps,
2+
# they essentially become individual layers due to the way Container handles
3+
# layering, especially using CoW filesystems. What this means for us is that
4+
# the caches that APT keeps end up just wasting space in those layers, making
5+
# our layers unnecessarily large (especially since we'll normally never use
6+
# these caches again and will instead just "podman build" again and make a brand
7+
# new image).
8+
9+
# Ideally, these would just be invoking "apt-get clean", but in our testing,
10+
# that ended up being cyclic and we got stuck on APT's lock, so we get this fun
11+
# creation that's essentially just "apt-get clean".
12+
DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
13+
APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
14+
15+
Dir::Cache::pkgcache "";
16+
Dir::Cache::srcpkgcache "";
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Since Container users using "RUN apt-get update && apt-get install -y ..." in
2+
# their Dockerfiles don't go delete the lists files afterwards, we want them to
3+
# be as small as possible on-disk, so we explicitly request "gz" versions and
4+
# tell Apt to keep them gzipped on-disk.
5+
6+
# For comparison, an "apt-get update" layer without this on a pristine
7+
# "debian:wheezy" base image was "29.88 MB", where with this it was only
8+
# "8.273 MB".
9+
10+
Acquire::GzipIndexes "true";
11+
Acquire::CompressionTypes::Order:: "gz";

0 commit comments

Comments
 (0)