#1072715 make it easier to change autopkgtest backends

#1072715#5
Date:
2024-06-06 22:23:16 UTC
From:
To:
Dear Maintainer,

sbuild is really great. I have a small feature request to make it easier to navigate the autopkgtest options:

In sbuild.conf i use

  $autopkgtest_root_args = '';
	$autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ];

but sometimes i need to lxc because schroot isnt enough of a container, or i need to match what happens on salsa
And now i need to use sudo, i have to remember to uncomment the following two lines

	$autopkgtest_root_args = 'sudo';
	$autopkgtest_opts = [ '--', 'lxc', 'autopkgtest-%r' ];

and then recomment after...  -- I know i can pass these on the command line, but i can never remember the syntax for each.

Could these variables be set via via hashes, so i could easily choose at run-time whether to use lxc or schroot
(or unshare etc):

I was thinking you could support a syntax like:

  $autopkgtest_backend="schroot" # default backend

	# bash of backend => "value to use"
	$autopkgtest_root_args_hash = { "schroot" => "", "lxc" => "sudo", "unshare"=>"run0" };

	# bash of backend => [args,to,use]
  $autopkgtest_opts_hash = {
	    "lxc" => [ '--', 'lxc', 'autopkgtest-%r' ],
	    "schroot" => [ '--', 'schroot', '%r-%a-sbuild' ],
	}

and then doing --autopkgtests-backend=X would simply do call

$autopkgtest_root_args=$autopkgtest_root_args_hash[X];
$autopkgtest_opts=$autopkgtest_opts_args_hash[X];

would that be possible?

#1072715#10
Date:
2024-11-16 17:26:52 UTC
From:
To:
I've been using the following in .sbuildrc -- i think it works, but
using lxc is now broken by #1078165

my %autopkgtest_root_args_hash=(
"schroot" => [''],
"lxc" => ["sudo","--"],
);

my %autopkgtest_opts_hash=(
"schroot" => [ '--', 'schroot', '%r-%a-sbuild' ],
"lxc" => [ '--', 'lxc', 'autopkgtest-%r' ],
);

my $autopkgtest_mode="schroot";  # schroot or lxc: use --mode to choose this!

my @filtered_args=();
foreach my $arg (@ARGV) {
if ($arg eq "--mode=lxc"){
$autopkgtest_mode = "lxc";
} elsif ($arg eq "--mode=schroot"){
$autopkgtest_mode = "schroot";
} else {
# pass arg through
push(@filtered_args,$arg);
}
}
print("Using autopkgtest mode: $autopkgtest_mode\n");
@ARGV=@filtered_args;
#print(@ARGV);

$autopkgtest_root_args=$autopkgtest_root_args_hash{$autopkgtest_mode};
$autopkgtest_opts=$autopkgtest_opts_hash{$autopkgtest_mode};

#1072715#13
Date:
2024-11-18 08:18:07 UTC
From:
To:
Hi Richard,

Quoting Richard Lewis (2024-06-07 00:23:16)

that's fair. You are also not supposed to type all of this out. Maybe you can
create a shell alias to do the work for you?

Yes. Patches welcome. :)

Thanks!

cheers, josch