One use-case are the proxmox-mail-gateway container templates, which
ship the correct enterprise-repsitory entry.

Currently the used entry is removed via `sed` during container
creation. With deb822 sources the `sed` command would become a bit
unwieldy, so just add the option to define sources which are only
used for the container preparation

Signed-off-by: Stoiko Ivanov <[email protected]>
---
 PVE/DAB.pm | 31 ++++++++++++++++++++++++++++---
 dab        |  6 ++++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/PVE/DAB.pm b/PVE/DAB.pm
index f74d363..59397f2 100644
--- a/PVE/DAB.pm
+++ b/PVE/DAB.pm
@@ -222,7 +222,7 @@ sub read_config {
            chomp $res->{description};      
        } elsif ($rec =~ s/^([^:]+):\s*(.*\S)\s*\n//) {
            my ($key, $value) = (lc ($1), $2);
-           if ($key eq 'source' || $key eq 'mirror') {
+           if ($key eq 'source' || $key eq 'mirror' || $key eq 
'install-source') {
                push @{$res->{$key}}, $value;
            } else {
                die "duplicate key '$key'\n" if defined ($res->{$key});
@@ -507,9 +507,33 @@ sub new {
                source => $url,
                comp => $ca,
                suite => $su,
+               keep => 1,
            };
        } else {
-           die "syntax error in source spezification '$s'\n";
+           die "syntax error in source specification '$s'\n";
+       }
+    }
+
+    foreach my $is (@{$config->{'install-source'}}) {
+       if ($is =~ m@^\s*((https?|ftp)://\S+)\s+(\S+)((\s+(\S+))+)$@) {
+           my ($url, $su, $components) = ($1, $3, $4);
+           $su =~ s/SUITE/$suite/;
+           $components =~ s/^\s+//;
+           $components =~ s/\s+$//;
+           my $ca;
+           foreach my $co (split (/\s+/, $components)) {
+               push @$ca, $co;
+           }
+           $ca = ['main'] if !$ca;
+
+           push @$sources, {
+               source => $url,
+               comp => $ca,
+               suite => $su,
+               keep => 0,
+           };
+       } else {
+           die "syntax error in install-source specification '$is'\n";
        }
     }
 
@@ -1380,7 +1404,8 @@ sub bootstrap {
        mkdir "$rootdir/etc/apt/sources.list.d";
        my $origin = lc($suiteinfo->{origin});
        my $keyring = $suiteinfo->{keyring} or die "missing keyring for origin 
'$origin'";
-       my $uris = { map { $_->{source} => 1 } $self->{sources}->@* };
+       my @keep_sources = grep { $_->{keep} } $self->{sources}->@*;
+       my $uris = { map { $_->{source} => 1 } @keep_sources };
 
        for my $uri (keys $uris->%*) {
            my $sources = [ grep { $_->{source} eq $uri } $self->{sources}->@* 
];
diff --git a/dab b/dab
index d79afe6..c01c513 100755
--- a/dab
+++ b/dab
@@ -451,6 +451,12 @@ Note: SUITE is a variable and will be substituted.
 There are also reasonable defaults for Ubuntu. If you do not specify any source
 the defaults are used.
 
+=item B<Install-Source:> I<URL [components]>
+
+Defines a source location used only during appliance creation. It is
+not added to the sources.list entries in the resulting templates. Else behaves
+like a B<Source:> entry.
+
 =item B<Depends:> I<dependencies>
 
 Debian like package dependencies. This can be used to make sure that speific
-- 
2.39.5



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to