split out writing (host-side) pacman.conf

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-12-02 13:15:47 +01:00
parent b867882aee
commit ae71b49f69
1 changed files with 17 additions and 9 deletions

View File

@ -231,17 +231,27 @@ sub initialize {
die "no sources/mirrors specified"; die "no sources/mirrors specified";
} }
$self->write_pacman_conf();
$self->logmsg("configured VE $self->{veid}\n");
}
sub write_pacman_conf {
my ($self) = @_;
my $config = $self->{config};
$config->{source} //= []; $config->{source} //= [];
$config->{mirror} //= []; $config->{mirror} //= [];
my $servers = "Server = " my $servers = "Server = ".join("\nServer = ", @{$config->{source}}, @{$config->{mirror}}) ."\n";
. join("\nServer = ", @{$config->{source}}, @{$config->{mirror}})
. "\n"; my $fh = IO::File->new($self->{'pacman.conf'}, O_WRONLY | O_CREAT | O_EXCL)
or die "unable to write pacman config file $self->{'pacman.conf'} - $!";
$fh = IO::File->new($self->{'pacman.conf'}, O_WRONLY|O_CREAT|O_EXCL) ||
die "unable to write pacman config file $self->{'pacman.conf'} - $!";
my $arch = $config->{architecture}; my $arch = $config->{architecture};
$arch = 'x86_64' if $arch eq 'amd64'; $arch = 'x86_64' if $arch eq 'amd64';
print $fh <<"EOF"; print $fh <<"EOF";
[options] [options]
HoldPkg = pacman glibc HoldPkg = pacman glibc
@ -257,11 +267,9 @@ $servers
$servers $servers
EOF EOF
if ($config->{architecture} eq 'x86_64') { print $fh "[multilib]\n$servers\n" if $config->{architecture} eq 'x86_64';
print $fh "[multilib]\n$servers\n";
}
$self->logmsg("configured VE $self->{veid}\n"); close($fh);
} }
sub ve_status { sub ve_status {