For the record,

This is to publish my coping strategies for this feature being missing from 
dpkg.

This is what I've been doing in debootstrap,
to purge packages unavoidably installed BEFORE localepurge, but
still benefit from path-exclude (MUCH faster) for packages installs AFTER 
localpurge:

    debootstrap --variant=minbase ... $t
    ...
    chroot $t apt-get install locales localepurge
    chroot $t sed -i /etc/locale.nopurge -e 's/^USE_DPKG/#ARGH#&/'
    chroot $t localepurge
    chroot $t sed -i /etc/locale.nopurge -e 's/^#ARGH#//'
    chroot $t apt-get install <everything else>

This is more annoying in mmdebstrap, which
for speed reasons tries to do only 2 rounds of apt-get
(one for apt, one for everything else).

    <run --setup-hooks>
    <install apt & Essential: yes packages, like deboostrap>
    <run --essential-hooks>
    <install everything else>
    <run --customize-hooks>

This shows & measures some strategies for "doing" localepurge for what is 
approximately Debian Live XFCE:

    ROW SIZE  REAL   USER   SYS    COMMAND
      1 282M  2m41s  9m07s  0m13s  ./tmp.sh  # baseline, no localepurge
      2 290M  2m49s  9m32s  0m14s  ./tmp.sh --include=localepurge
      3 290M  2m50s  9m32s  0m13s  ./tmp.sh --include=localepurge 
--essential-hook='echo localepurge localepurge/use-dpkg-feature boolean false | 
chroot $1 debconf-set-selections'
      4 266M  2m38s  8m57s  0m13s  ./tmp.sh --include=localepurge 
--essential-hook='echo localepurge localepurge/use-dpkg-feature boolean false | 
chroot $1 debconf-set-selections' --customize-hook='chroot $1 localepurge'
      5 275M  2m40s  9m12s  0m13s  ./tmp.sh --essential-hook='chroot $1 apt-get 
install -y localepurge'
      6 265M  2m35s  8m52s  0m12s  ./tmp.sh --essential-hook='chroot $1 apt-get 
install -y localepurge&&chroot $1 sed -i /etc/locale.nopurge -e 
"s/^USE_DPKG/#ARGH#&/"&&chroot $1 localepurge&&chroot $1 sed -i 
/etc/locale.nopurge -e "s/^#ARGH#//"'
      7 267M  2m34s  8m44s  0m12s  ./tmp.sh --setup-hook='mkdir -p 
$1/etc/dpkg/dpkg.cfg.d' --setup-hook='copy-in 
/etc/dpkg/dpkg.cfg.d/50localepurge /etc/dpkg/dpkg.cfg.d'
        ====  =====
          6%     4%  SAVINGS FROM LOCALEPURGE
        ====  =====

>From past experience, when localepurge is working correctly,
the image should build 8%-12% faster AND be 8%-12% smaller.

You can see that the intuitive approach (2) doesn't work at all.
Oddly, nor does simply telling localepurge to use its pre-path-exclude code. (3)
Manually firing localepurge afterwards mostly works. (4)

We get the best results by fully preserving the original debootstrap workaround 
(6),
i.e. an entire separate apt-get process, just for localepurge & its 
dependencies,
AND doing a manual localepurge, then allowing <everything else> packages to 
install using path-excludes.

Finally, we can "cheat" by inserting a localepurge generated ahead of time on 
another system. (7)
This works well but assumes the build system and built system have identical 
locales configuration.


PS: I can't explain why the "working" cases (4,6,7) have varying sizes 
(265/266/267M).




APPENDIX: tmp.sh
================

#!/bin/bash
# NOTE: aptopt/dpkgopt are optional "go faster" racing stripes.
# NOTE: Without --variant=apt, "chroot $1 apt-get" is failing for reasons I 
don't understand.
time mmdebstrap bullseye delete-me.squashfs \
    --variant=apt \
    --logfile=delete-me.log \
    --include=linux-image-generic,live-boot,live-config,task-xfce-desktop \
    --include=locales \
    --essential-hook='echo locales locales/default_environment_locale   select 
en_AU.UTF-8       | chroot $1 debconf-set-selections' \
    --essential-hook='echo locales locales/locales_to_be_generated multiselect 
en_AU.UTF-8 UTF-8 | chroot $1 debconf-set-selections' \
    --aptopt='Acquire::http::Proxy "http://odin:3142";' \
    --dpkgopt=force-unsafe-io \
    "$@" &&
du -shx delete-me.squashfs

Reply via email to