]> git.proxmox.com Git - aab.git/commitdiff
split out writing (host-side) pacman.conf
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 2 Dec 2021 12:15:47 +0000 (13:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 2 Dec 2021 12:15:47 +0000 (13:15 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/AAB.pm

index 2de341cc1cf81ff7099fbe0f585db3abf3f57541..ccac7f2e00ea50a90b8412feab5777031c567aee 100644 (file)
@@ -231,17 +231,27 @@ sub initialize {
        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->{mirror} //= [];
 
-    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)
+        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};
     $arch = 'x86_64' if $arch eq 'amd64';
+
     print $fh <<"EOF";
 [options]
 HoldPkg = pacman glibc
@@ -257,11 +267,9 @@ $servers
 $servers
 EOF
 
-    if ($config->{architecture} eq 'x86_64') {
-       print $fh "[multilib]\n$servers\n";
-    }
+    print $fh "[multilib]\n$servers\n" if $config->{architecture} eq 'x86_64';
 
-    $self->logmsg("configured VE $self->{veid}\n");
+    close($fh);
 }
 
 sub ve_status {