]> git.proxmox.com Git - pve-manager.git/commitdiff
pve7to8: add checks for mismatched or strange repos
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 3 Jul 2023 11:08:45 +0000 (13:08 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 3 Jul 2023 11:12:03 +0000 (13:12 +0200)
adapted and extended from pmg-api's commit 6ceeea8 [0].

[0]: https://git.proxmox.com/?p=pmg-api.git;a=commit;h=6ceeea877027853d6ae7a44f2d4d732ed6b136b9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/CLI/pve7to8.pm

index 4cc7d31435e9867bcef78d183d9cf192beb48c6c..c7d3f19c132c4f7cdcc147ed18463931ae1c76ab 100644 (file)
@@ -44,6 +44,14 @@ sub setup_environment {
     PVE::RPCEnvironment->setup_default_cli_env();
 }
 
+my $new_suite = 'bookworm';
+my $old_suite = 'bullseye';
+my $older_suites = {
+    buster => 1,
+    stretch => 1,
+    jessie => 1,
+};
+
 my ($min_pve_major, $min_pve_minor, $min_pve_pkgrel) = (7, 4, 1);
 
 my $ceph_release2code = {
@@ -1164,6 +1172,9 @@ sub check_apt_repos {
 
     # TODO: check that (original) debian and Proxmox VE mirrors are present.
 
+    my ($found_suite, $found_suite_where);
+    my ($mismatches, $strange_suites);
+
     my $check_file = sub {
        my ($file) = @_;
 
@@ -1184,23 +1195,32 @@ sub check_apt_repos {
            next if $line !~ m/^deb[[:space:]]/; # is case sensitive
 
            my $suite;
-
-           # catch any of
-           # https://deb.debian.org/debian-security
-           # http://security.debian.org/debian-security
-           # http://security.debian.org/
-           if ($line =~ m|https?://deb\.debian\.org/debian-security/?\s+(\S*)|i) {
-               $suite = $1;
-           } elsif ($line =~ m|https?://security\.debian\.org(?:.*?)\s+(\S*)|i) {
+           if ($line =~ m|deb\s+\w+://\S+\s+(\S*)|i) {
                $suite = $1;
            } else {
                next;
            }
+           my $where = "in ${file}:${number}";
 
-           $found = 1;
+           $suite =~ s/-(?:(?:proposed-)?updates|backports|debug|security)(?:-debug)?$//;
+           if ($suite ne $old_suite && $suite ne $new_suite && !$older_suites->{$suite}) {
+               push $strange_suites->@*, { suite => $suite, where => $where };
+               next;
+           }
 
-           my $where = "in ${file}:${number}";
-           # TODO: is this useful (for some other checks)?
+           if (!defined($found_suite)) {
+               $found_suite = $suite;
+               $found_suite_where = $where;
+           } elsif ($suite ne $found_suite) {
+               if (!defined($mismatches)) {
+                   $mismatches = [];
+                   push $mismatches->@*,
+                       { suite => $found_suite, where => $found_suite_where},
+                       { suite => $suite, where => $where};
+               } else {
+                   push $mismatches->@*, { suite => $suite, where => $where};
+               }
+           }
        }
     };
 
@@ -1210,10 +1230,28 @@ sub check_apt_repos {
 
     PVE::Tools::dir_glob_foreach($dir, '^.*\.list$', $check_file);
 
-    if (!$found) {
-       # only warn, it might be defined in a .sources file or in a way not caaught above
-       log_warn("No Debian security repository detected in /etc/apt/sources.list and " .
-           "/etc/apt/sources.list.d/*.list");
+    if ($strange_suites) {
+       my @strange_list = map { "found suite $_->{suite} at $_->{where}" } $strange_suites->@*;
+       log_notice(
+           "found unusual suites that are neither old '$old_suite' nor new '$new_suite':"
+           ."\n    " . join("\n    ", @strange_list)
+           ."\n  Please ensure these repositories are shipping compatible packages for the upgrade!"
+       );
+    }
+    if (defined($mismatches)) {
+       my @mismatch_list = map { "found suite $_->{suite} at $_->{where}" } $mismatches->@*;
+
+       log_fail(
+           "Found mixed old and new package repository suites, fix before upgrading! Mismatches:"
+           ."\n    " . join("\n    ", @mismatch_list)
+           ."\n  Configure the same base-suite for all Proxmox and Debian provided repos and ask"
+           ." original vendor for any third-party repos."
+           ."\n  E.g., for the upgrade to Proxmox VE ".($min_pve_major + 1)." use the '$new_suite' suite."
+       );
+    } elsif (defined($strange_suites)) {
+       log_notice("found no suite mismatches, but found at least one strange suite");
+    } else {
+       log_pass("found no suite mismatch");
     }
 }