diff --git a/bootstrap.sh b/bootstrap.sh index 05a0211..16b7eec 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -14,5 +14,9 @@ rootfs=/devuan/rootfs debootstrap --variant=minbase jessie $rootfs -find $rootfs/var/cache/apt/ -type f -delete -find $rootfs/var/lib/apt/ -type f -delete +bindir=usr/local/bin +cp -a scripts/* $rootfs/$bindir + +for script in $(ls $rootfs/$bindir); do + chroot $rootfs /$bindir/$script +done diff --git a/scripts/docker-apt-clean b/scripts/docker-apt-clean new file mode 100755 index 0000000..95b970a --- /dev/null +++ b/scripts/docker-apt-clean @@ -0,0 +1,20 @@ +#!/bin/sh +# docker-apt-clean -- to keep Docker image size small +# Copyright (C) 2017 Olaf Meeuwissen +# +# License: GPL-3.0+ + +# Running `apt-get clean` from within apt-get causes deadlock due to +# the locking mechanism used by apt-get. This script has a similar +# effect as running `apt-get clean` but circumvents the deadlock. + +DIR=/ +STATE=var/lib/apt/ +CACHE=var/cache/apt/ + +eval $(apt-config shell DIR Dir) +eval $(apt-config shell STATE Dir::State) +eval $(apt-config shell CACHE Dir::Cache) + +find $DIR$STATE -type f -delete +find $DIR$CACHE -type f -delete diff --git a/scripts/tweak-apt-config b/scripts/tweak-apt-config new file mode 100755 index 0000000..20c8bf0 --- /dev/null +++ b/scripts/tweak-apt-config @@ -0,0 +1,24 @@ +#!/bin/sh -eu +# tweak-apt-config -- for use in a Docker image +# Copyright (C) 2017 Olaf Meeuwissen +# +# License: GPL-3.0+ + +DIR=/ +ETC=etc/apt +PARTS=apt.conf.d + +eval $(apt-config shell DIR Dir) +eval $(apt-config shell ETC Dir::Etc) +eval $(apt-config shell PARTS Dir::Etc::Parts) + +cfg=$DIR$ETC$PARTS + +cmd=$(dirname $0)/docker-apt-clean +cat > $cfg/docker-clean <<- EOF +DPkg::Post-Invoke { "if test -x $cmd; then $cmd; fi"; }; +APT::Update::Post-Invoke { "if test -x $cmd; then $cmd; fi"; }; +EOF +chmod 0644 $cfg/docker-clean + +rm $0