make_disc_trees.pl: rewrite base_components if needed

It's possible to set LOCAL=1 to enable support for local packages, which
automatically results in “local” being listed in /.disk/base_components,
which is used to build the --components parameter for debootstrap.

Users might have various sets of *.deb and/or *.udebs, be it over time,
or for various codenames, and it's possible for /dists/<CODENAME>/local
to be entirely missing in the generated image.

In this case, /.disk/base_components must not contain “local”, as that
would break debootstrap; this commit detects and fixes this possible
inconsistency.
This commit is contained in:
Cyril Brulebois 2023-01-27 05:24:03 +01:00
parent c24949141b
commit ae8490ba70
2 changed files with 12 additions and 0 deletions

View File

@ -860,6 +860,17 @@ sub finish_disc {
my $hook;
my $error = 0;
# Fix possible inconsistency (LOCAL enabled, no packages getting included in the
# local component, breaking debootstrap which is passed --components=main,local):
if (! -d "$cddir/dists/$codename/local") {
my $base_components = "$cddir/.disk/base_components";
my @components = read_file($base_components);
if (grep { $_ eq "local\n" } @components) {
print " Removing local from base_components (no such component under $codename)\n";
write_file($base_components, grep { $_ ne "local\n" } @components);
}
}
if (defined($ENV{'DISC_FINISH_HOOK'})) {
$hook = $ENV{'DISC_FINISH_HOOK'};
print " Calling disc_finish hook: $hook\n";

View File

@ -182,6 +182,7 @@ if [ $DISKNUM = 1 ] ; then
echo " Adding .disk/base_components"
echo "main" > $CDDIR/.disk/base_components
if [ -n "$LOCAL" ] ; then
# This might be reverted by finish_disc in the end:
echo "local" >> $CDDIR/.disk/base_components
fi