pacman: allow overriding config file and siglevel

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-12-02 14:43:57 +01:00
parent 034835001d
commit fbec3675cc
1 changed files with 14 additions and 9 deletions

View File

@ -237,16 +237,19 @@ sub initialize {
} }
sub write_pacman_conf { sub write_pacman_conf {
my ($self) = @_; my ($self, $config_fn, $siglevel) = @_;
my $config = $self->{config}; my $config = $self->{config};
$config->{source} //= []; $config->{source} //= [];
$config->{mirror} //= []; $config->{mirror} //= [];
$siglevel ||= "Never";
$config_fn ||= $self->{'pacman.conf'};
my $servers = "Server = ".join("\nServer = ", @{$config->{source}}, @{$config->{mirror}}) ."\n"; my $servers = "Server = ".join("\nServer = ", @{$config->{source}}, @{$config->{mirror}}) ."\n";
my $fh = IO::File->new($self->{'pacman.conf'}, O_WRONLY | O_CREAT | O_EXCL) my $fh = IO::File->new($config_fn, O_WRONLY | O_CREAT | O_EXCL)
or die "unable to write pacman config file $self->{'pacman.conf'} - $!"; or die "unable to write pacman config file $self->{'pacman.conf'} - $!";
my $arch = $config->{architecture}; my $arch = $config->{architecture};
@ -257,7 +260,7 @@ sub write_pacman_conf {
HoldPkg = pacman glibc HoldPkg = pacman glibc
Architecture = $arch Architecture = $arch
CheckSpace CheckSpace
SigLevel = Never SigLevel = $siglevel
[core] [core]
$servers $servers
@ -447,13 +450,15 @@ sub stop_container {
} }
sub pacman_command { sub pacman_command {
my ($self) = @_; my ($self, $config_fn) = @_;
my $root = $self->{rootfs}; my $root = $self->{rootfs};
return ('/usr/bin/pacman', return (
'--root', $root, '/usr/bin/pacman',
'--config', $self->{'pacman.conf'}, '--root', $root,
'--cachedir', $self->{pkgcache}, '--config', $config_fn || $self->{'pacman.conf'},
'--noconfirm'); '--cachedir', $self->{pkgcache},
'--noconfirm',
);
} }
sub cache_packages { sub cache_packages {