mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Add support for listing deb822-style repos
https://forum.virtualmin.com/t/package-repositories-empty-ubuntu-24-04/129152/12?u=ilia
This commit is contained in:
@@ -244,7 +244,7 @@ if ($has_repos) {
|
||||
"<font color=green>$text{'yes'}</font>" :
|
||||
"<font color=red>$text{'no'}</font>",
|
||||
$r->{'url'},
|
||||
], "", "d", $r->{'id'});
|
||||
], "", "d", $r->{'id'}, undef, $r->{'cannot'});
|
||||
}
|
||||
print &ui_columns_end();
|
||||
print &ui_form_end([
|
||||
|
||||
@@ -457,7 +457,34 @@ my @rv;
|
||||
foreach my $f ($sources_list_file, glob("$sources_list_dir/*")) {
|
||||
my $lref = &read_file_lines($f, 1);
|
||||
my $lnum = 0;
|
||||
my (%repo, @types);
|
||||
my $repo = sub {
|
||||
foreach my $type (@types) {
|
||||
my @suites = @{$repo{'suites'}};
|
||||
foreach my $suite (@suites) {
|
||||
my @comps = @{$repo{'comps'}};
|
||||
foreach my $comp (@comps) {
|
||||
my $repo =
|
||||
{
|
||||
'cannot' => 1,
|
||||
'file' => $f,
|
||||
# 'line' => $lnum,
|
||||
'url' => $repo{'url'},
|
||||
'enabled' => !$repo{'disabled'},
|
||||
'words' => [$comp, $suite],
|
||||
'name' => join("/", $comp, $suite).
|
||||
($type =~ /src/ ? " ($type)" : ""),
|
||||
'signed_by' => $repo{'signed_by'},
|
||||
};
|
||||
$repo->{'id'} =
|
||||
$repo->{'url'}.$repo->{'name'};
|
||||
push(@rv, $repo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
foreach my $l (@$lref) {
|
||||
# Debian classic format (using .list files)
|
||||
if ($l =~ /^(#*)\s*deb.*?((http|https)\S+)\s+(\S.*)/) {
|
||||
my $repo = { 'file' => $f,
|
||||
'line' => $lnum,
|
||||
@@ -471,6 +498,40 @@ foreach my $f ($sources_list_file, glob("$sources_list_dir/*")) {
|
||||
$repo->{'id'} = $repo->{'url'}.$repo->{'name'};
|
||||
push(@rv, $repo);
|
||||
}
|
||||
# New Ubuntu-style repos (using .sources files)
|
||||
elsif ($f =~ /\.sources$/) {
|
||||
if ($l =~ /^([\w\-]+):\s*(.+)$/) {
|
||||
my ($key, $value) = ($1, $2);
|
||||
if ($key eq 'Types') {
|
||||
@types = split(/\s+/, $value);
|
||||
}
|
||||
elsif ($key eq 'URIs') {
|
||||
$repo{'url'} = $value;
|
||||
}
|
||||
elsif ($key eq 'Suites') {
|
||||
$repo{'suites'} = [split(/\s+/, $value)];
|
||||
}
|
||||
elsif ($key eq 'Components') {
|
||||
$repo{'comps'} = [split(/\s+/, $value)];
|
||||
}
|
||||
elsif ($key eq 'Signed-By') {
|
||||
$repo{'signed_by'} = $value;
|
||||
}
|
||||
elsif ($key eq 'Enabled') {
|
||||
$repo{'disabled'} =
|
||||
(lc($value) eq 'no') ? 1 : 0;
|
||||
}
|
||||
}
|
||||
elsif ($l =~ /^\s*$/ || $lnum == $#{$lref}) {
|
||||
# Process and push the current repo if we
|
||||
# got an empty line or it's the last line
|
||||
if (%repo) {
|
||||
$repo->();
|
||||
%repo = ();
|
||||
@types = ();
|
||||
}
|
||||
}
|
||||
}
|
||||
$lnum++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user