zmanda / amanda

Amanda Network Backup
https://www.zmanda.com/downloads/
Other
227 stars 108 forks source link

Amanda needs to be updated to work with Perl 5.40 #262

Open tim1724 opened 2 months ago

tim1724 commented 2 months ago

Perl 5.40 has a few breaking changes that require Amanda to be updated.

I haven't done an exhaustive search, but here are the two issues I've found so far when running Amanda 3.54 under perl 5.40:

  1. taper dies with a fatal error:
    Missing comma after first argument to return at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Scribe.pm line 1087, near ");"
    BEGIN not safe after errors--compilation aborted at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Scribe.pm line 1690.
    Compilation failed in require at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Worker.pm line 53.
    BEGIN failed--compilation aborted at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Worker.pm line 53.
    Compilation failed in require at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Controller.pm line 55.
    BEGIN failed--compilation aborted at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Taper/Controller.pm line 55.
    Compilation failed in require at ./taper line 31.
    BEGIN failed--compilation aborted at ./taper line 31.

I believe this patch should fix it. I honestly don't understand how it ever worked before! It should have always been either &$finished_cb() or $finished_cb->(). I think perl must have been silently ignoring the error. Perhaps this was somehow fixed as a side effect of this change to return statements.

--- amanda-orig/perl/Amanda/Taper/Scribe.pm 2024-09-06 19:51:01.479458775 -0700
+++ amanda-fixed/perl/Amanda/Taper/Scribe.pm    2024-09-06 19:59:12.957510409 -0700
@@ -1116,7 +1116,7 @@
    if ($chg->{'global_space'}) {
        $chg->inventory(inventory_cb => $steps->{'got_inventory'});
    } else {
-       return $finished_cb();
+       return $finished_cb->();
    }
     };
  1. Running amanda produces a warning:
    Attempt to call undefined import method with arguments (":severity") via package "Amanda::Message" (Perhaps you forgot to load the package?) at /usr/lib64/perl5/vendor_perl/5.40/Amanda/Tapelist.pm line 318.

It looks like Amanda::Message doesn't actually define an import method so passing an argument list to use Amanda::Message can't possibly work. But undefined import methods were silently ignored that in older versions of perl. Starting with 5.40 it now complains about it.

Given that this wasn't actually doing anything I simply commented out the offending line in Amanda::Tapelist but it should probably just be removed entirely.

--- amanda-orig/perl/Amanda/Tapelist.swg    2024-09-06 19:51:01.475458921 -0700
+++ amanda-fixed/perl/Amanda/Tapelist.swg   2024-09-06 19:53:05.074944725 -0700
@@ -36,7 +36,7 @@
 use Amanda::Config qw( config_dir_relative );
 use File::Copy;
 use Fcntl qw(:flock); # import LOCK_* constants
-use Amanda::Message qw( :severity );
+#use Amanda::Message qw( :severity );

 ## package functions

I wouldn't be surprised if there are other similar problems in parts of the code I haven't looked at yet. (I'm still in the middle of running my first dump after updating perl and I haven't tried restoring from backups yet. And of course I don't use every possible piece of Amanda in my setup.)

pbiering commented 2 weeks ago

Fedora 41 now hit by this bug, see also https://bugzilla.redhat.com/show_bug.cgi?id=2322518

pbiering commented 2 weeks ago

Given that this wasn't actually doing anything I simply commented out the offending line in Amanda::Tapelist but it should probably just be removed entirely.

Looks like Amanda/Tapelist.pm was the only file where qw ( :severity ) was still not removed, so far all other files contain only use Amanda::Message;, so proposed diff would be

--- Amanda/Tapelist.pm.orig 2024-10-29 20:13:26.802470484 +0100
+++ Amanda/Tapelist.pm  2024-10-29 20:14:08.448755135 +0100
@@ -315,7 +315,7 @@
 use Amanda::Config qw( config_dir_relative );
 use File::Copy;
 use Fcntl qw(:flock); # import LOCK_* constants
-use Amanda::Message qw( :severity );
+use Amanda::Message;

 ## package functions