#1088652 FR: UNSHARE_MMDEBSTRAP_EXTRA_ARGS used for appending instead of overwriting

#1088652#5
Date:
2024-11-29 00:53:56 UTC
From:
To:
The option UNSHARE_MMDEBSTRAP_EXTRA_ARGS behaves a bit differently than one
would expect for an "extra_args" type of option.

The manpage mentions there is a default value for this, which means that if an
user wants to, for example, make sure apt-cacher-ng is always used, the user
needs to copy the current default + apt-cacher-ng changes to their confs.

It becomes harder to maintain, as the user needs to periodically check if the
default changed and update it in their confs.

I would like for a solution which lets users set extra flags without overriding
the defaults.

Regards,

#1088652#8
Date:
2024-11-29 09:17:31 UTC
From:
To:
Hi Samuel,

Quoting Samuel Henrique (2024-11-29 01:53:56)

do you have an example of other software which uses something similar to
"extra_args" in the way you expect?

This feature is marked as experimental for a reason. We can definitely change
this. I wonder what the best interface would be?

Is what you want a "append to defaults" option?

The problem with an "append to default" option is, that now you need
another option to change the default. And you also still need to periodically
check what the current default is because your appending to the default
will change depending on what the default actually is.

Do you have a proposal in mind?

Thanks!

cheers, josch

#1088652#13
Date:
2024-11-29 10:59:02 UTC
From:
To:
Hi,
Just adding my two cents, I exploit the fact that .sbuildrc is
essentially a Perl script, and do the following to have a bunch of
common default options for mmdebstrap:

my @common_mmdebstrap_args = (
	'--variant=apt',
	'--include=build-essential,ccache',
	'--chrooted-customize-hook=update-ccache-symlinks',
	'--customize-hook=rm "$1/etc/resolv.conf"',
	'--customize-hook=rm "$1/etc/hostname"',
	'--aptopt=Acquire::http::Proxy "http://localhost:3456"',
	'--dpkgopt=path-exclude=/usr/share/man/*',
	'--dpkgopt=path-include=/usr/share/man/man[1-9]/*',
	'--dpkgopt=path-exclude=/usr/share/locale/*',
	'--dpkgopt=path-include=/usr/share/locale/locale.alias',
	'--dpkgopt=path-exclude=/usr/share/doc/*',
	'--dpkgopt=path-include=/usr/share/doc/*/copyright',
	'--dpkgopt=path-include=/usr/share/doc/*/changelog.Debian.*',
);
$unshare_mmdebstrap_extra_args = {
	'*' => [ @common_mmdebstrap_args ],
	"$1/etc/apt/sources.list.d/experimental.list"'],
	'focal' => [ @common_mmdebstrap_args, '--include=adduser,ca-certificates', '--components=main,universe' ],
	'jammy' => [ @common_mmdebstrap_args, '--include=adduser,ca-certificates', '--components=main,universe' ],
	'noble' => [ @common_mmdebstrap_args, '--include=adduser,ca-certificates', '--components=main,universe' ],
};


If the default options were somehow exposed as predefined variable
to the config script, this could be used in a similar way to append
options (and it would be explicit, which is always nice for
readability).

I'm not enough of a Perl expert to gauge how easily this could be
implemented, though.


Cheers
Timo

#1088652#18
Date:
2024-12-01 09:39:56 UTC
From:
To:
Hello Johannes,

Nothing comes to mind specifically, I thought this expectation would be a
consensus, but if you're asking me, it means that's not the case, and thus I
would understand keeping it the way it is.

Just to clarify what I mean, I only "extra_args" type of variables to
append-only if they are exposed as configurations or flags to the user, if they
are used internally, for eg..: a specific Makefile flag, then I would not
expect that to be empty.

Yes.

Yes, I mean, that would be rare, right? It's a similar type of issue as
breaking other types of user settings.If we have to overwrite, I need to keep
an eye on the changes to make sure I don't miss new features, if I append, I
only need to worry about breakages (less likely to happen).

I didn't have one, but I like Timo's idea of exposing the default as a
variable, that way the default behavior is still to override the value of
"unshare_mmdebstrap_extra_args", but lets the user perform an append by using a
variable that contains the defaults.

This way the user doesn't have to keep an eye on changes (at least not as
frequently), and we allow users to replace the default without complex changes
to sbuild.

What do you think? Does sbuild have a precedence for exposing variables like
that for sbuildrc?

Cheers,

#1088652#21
Date:
2024-12-02 23:59:59 UTC
From:
To:
Hi,

Quoting Timo Röhling (2024-11-29 11:59:02)

that's a good idea!

This is already possible today. Try this:

$unshare_mmdebstrap_extra_args = $conf->_get('UNSHARE_MMDEBSTRAP_EXTRA_ARGS');
push @{$unshare_mmdebstrap_extra_args->{"experimental"}}, @common_mmdebstrap_args;

The $conf->_get() function gets the configuration default without processing
percent escapes, which is what you want here. The above would first set
$unshare_mmdebstrap_extra_args to the default and then append something to an
existing entry.

Thanks!

cheers, josch