]>
git.proxmox.com Git - proxmox-ve.git/blob - debian/apthook/pve-apt-hook
8 my $fd = $ENV{APT_HOOK_INFO_FD
};
9 my $check_file = '/please-remove-proxmox-ve';
10 my $check_package = 'proxmox-ve';
11 my $hook_name = basename
($0);
15 print "W: ($hook_name) $line";
18 if (!defined $fd || $fd == 0 || $fd !~ /^\d+$/) {
19 $log->("APT_HOOK_INFO_FD not correctly defined, skipping apt-pve-hook checks\n");
23 open(my $fh, "<&=", $fd) or die "E: could not open APT_HOOK_INFO_FD (${fd}) - $!\n";
26 my ($rc, $confirm) = @_;
37 my $file_read_firstline = sub {
40 my $fh = IO
::File-
>new($filename, "r");
48 chomp (my $ver = <$fh>);
49 if ($ver ne "VERSION 2") {
50 $log->("apt-pve-hook misconfigured, expecting hook protocol version 2\n");
55 while (my $line = <$fh>) {
58 if (!defined($blank)) {
63 my ($pkg, $old, $dir, $new, $action) = (split / /, $line, 5);
64 if (!defined($action)) {
65 $log->("apt-pve-hook encountered unexpected line: $line\n");
69 if ($pkg eq 'proxmox-ve') {
70 if ($action eq '**REMOVE**') {
72 $log->("'$check_file' exists, proceeding with removal of package '${check_package}'\n");
75 $log->("!! WARNING !!\n");
76 $log->("You are attempting to remove the meta-package '${check_package}'!\n");
78 $log->("If you really want to permanently remove '${check_package}' from your system, run the following command\n");
79 $log->("\ttouch '${check_file}'\n");
80 $log->("run apt purge ${check_package} to remove the meta-package\n");
81 $log->("and repeat your apt invocation.\n");
83 $log->("If you are unsure why '$check_package' would be removed, please verify\n");
84 $log->("\t- your APT repository settings\n");
85 $log->("\t- that you are using 'apt full-upgrade' to upgrade your system\n");
88 } elsif ($action eq '**CONFIGURE**' && $dir eq '<' && $old =~ /^6\./ && $new =~ /^7\./) {
89 $log->("!! ATTENTION !!\n");
90 $log->("You are attempting to upgrade from proxmox-ve '$old' to proxmox-ve '$new'. Please make sure to read the Upgrade notes at\n");
91 $log->("\thttps://pve.proxmox.com/wiki/Upgrade_from_6.x_to_7.0\n");
92 $log->("before proceeding with this operation.\n");
94 $log->("Press enter to continue, or C^c to abort.\n");
98 if ($pkg =~ /^pve-kernel-/) {
99 if ($action eq '**REMOVE**') {
100 my $next_boot_ver = $file_read_firstline->("/etc/kernel/next-boot-pin");
101 my $pinned_ver = $file_read_firstline->("/etc/kernel/proxmox-boot-pin");
102 my $remove_pinned_ver = ($next_boot_ver && $pkg =~ /$next_boot_ver$/);
103 $remove_pinned_ver ||= ($pinned_ver && $pkg =~ /$pinned_ver$/);
104 if ($remove_pinned_ver) {
105 $log->("!! WARNING !!\n");
106 $log->("You are attempting to remove the currently pinned kernel '${pkg}'!\n");
108 $log->("If you really do not need the version anymore unpin it by running\n");
109 $log->("\tproxmox-boot-tool kernel unpin'\n");
110 $log->("and repeat your apt invocation.\n");