Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-PAR-Packer for openSUSE:Factory 
checked in at 2022-07-05 12:09:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-PAR-Packer (Old)
 and      /work/SRC/openSUSE:Factory/.perl-PAR-Packer.new.1548 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-PAR-Packer"

Tue Jul  5 12:09:24 2022 rev:21 rq:986678 version:1.055

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-PAR-Packer/perl-PAR-Packer.changes  
2022-03-04 00:18:49.812300272 +0100
+++ 
/work/SRC/openSUSE:Factory/.perl-PAR-Packer.new.1548/perl-PAR-Packer.changes    
    2022-07-05 12:09:55.800595493 +0200
@@ -1,0 +2,23 @@
+Mon Jul  4 03:06:30 UTC 2022 - Tina M??ller <[email protected]>
+
+- updated to 1.055
+   see /usr/share/doc/packages/perl-PAR-Packer/Changes
+
+  1.055  2022-07-03
+  - Fix #62: rs6000_71 (AIX) "An offset in the .loader section header is too 
large."
+    Communicate pp option "--clean" to the generated executable in a
+    different way. Previously this was done by patching "__ENV_PAR_..." strings
+    **in the executable being built** and interpreting these strings in
+    par.pl **at runtime**. Though hacky, this seemingly worked on any OS
+    (without rendering the executable invalid).
+    But the only information ever passed was the value of PAR_CLEAN and this 
was
+    gleaned at build time from the value of JSONPath $par.clean from META.yml
+    in the zip (set by pp by option "--clean").
+    Instead read and interpret "META.yml" in par.pl **at runtime**.
+  - Fix: merge PR #58 from [email protected]:
+    Adding support for running MacOS Universal binaries created via 'lipo'
+    from already pp'ed and signed thin binaries
+  - Make writing stuff more robust: check return value of print()
+    and close() in some places.
+
+-------------------------------------------------------------------

Old:
----
  PAR-Packer-1.054.tar.gz

New:
----
  PAR-Packer-1.055.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-PAR-Packer.spec ++++++
--- /var/tmp/diff_new_pack.Ir1hy5/_old  2022-07-05 12:09:57.200597504 +0200
+++ /var/tmp/diff_new_pack.Ir1hy5/_new  2022-07-05 12:09:57.204597510 +0200
@@ -18,7 +18,7 @@
 
 %define cpan_name PAR-Packer
 Name:           perl-PAR-Packer
-Version:        1.054
+Version:        1.055
 Release:        0
 License:        Artistic-1.0 OR GPL-1.0-or-later
 Summary:        PAR Packager

++++++ PAR-Packer-1.054.tar.gz -> PAR-Packer-1.055.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/Changes new/PAR-Packer-1.055/Changes
--- old/PAR-Packer-1.054/Changes        2022-01-27 11:59:37.000000000 +0100
+++ new/PAR-Packer-1.055/Changes        2022-07-03 18:15:37.000000000 +0200
@@ -1,3 +1,25 @@
+1.055  2022-07-03
+
+- Fix #62: rs6000_71 (AIX) "An offset in the .loader section header is too 
large."
+  
+  Communicate pp option "--clean" to the generated executable in a
+  different way. Previously this was done by patching "__ENV_PAR_..." strings
+  **in the executable being built** and interpreting these strings in
+  par.pl **at runtime**. Though hacky, this seemingly worked on any OS
+  (without rendering the executable invalid).
+  But the only information ever passed was the value of PAR_CLEAN and this was
+  gleaned at build time from the value of JSONPath $par.clean from META.yml
+  in the zip (set by pp by option "--clean").
+  Instead read and interpret "META.yml" in par.pl **at runtime**.
+
+- Fix: merge PR #58 from [email protected]:
+  
+  Adding support for running MacOS Universal binaries created via 'lipo'
+  from already pp'ed and signed thin binaries
+
+- Make writing stuff more robust: check return value of print() 
+  and close() in some places.
+
 1.054  2022-01-27
 
 - Temporarily disable t/90-gh41.t (system("\\\\?\\some-absolute-path") fails)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/META.json 
new/PAR-Packer-1.055/META.json
--- old/PAR-Packer-1.054/META.json      2022-01-27 12:00:01.000000000 +0100
+++ new/PAR-Packer-1.055/META.json      2022-07-03 18:24:32.000000000 +0200
@@ -4,7 +4,7 @@
       "Audrey Tang <[email protected]>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter 
version 2.150010",
+   "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter 
version 2.150010",
    "license" : [
       "perl_5"
    ],
@@ -78,6 +78,6 @@
       },
       "x_MailingList" : "mailto:[email protected]";
    },
-   "version" : "1.054",
-   "x_serialization_backend" : "JSON::PP version 4.07"
+   "version" : "1.055",
+   "x_serialization_backend" : "JSON::PP version 4.10"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/META.yml 
new/PAR-Packer-1.055/META.yml
--- old/PAR-Packer-1.054/META.yml       2022-01-27 12:00:01.000000000 +0100
+++ new/PAR-Packer-1.055/META.yml       2022-07-03 18:24:32.000000000 +0200
@@ -14,7 +14,7 @@
   File::Glob: '0'
   File::Spec::Functions: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 
2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 
2.150010'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -48,5 +48,5 @@
   MailingList: mailto:[email protected]
   bugtracker: https://github.com/rschupp/PAR-Packer/issues
   repository: git://github.com/rschupp/PAR-Packer.git
-version: '1.054'
+version: '1.055'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/lib/PAR/Packer.pm 
new/PAR-Packer-1.055/lib/PAR/Packer.pm
--- old/PAR-Packer-1.054/lib/PAR/Packer.pm      2022-01-27 11:20:47.000000000 
+0100
+++ new/PAR-Packer-1.055/lib/PAR/Packer.pm      2022-01-27 12:01:23.000000000 
+0100
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '1.054';
+our $VERSION = '1.055';
 
 =head1 NAME
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/lib/PAR/StrippedPARL/Base.pm 
new/PAR-Packer-1.055/lib/PAR/StrippedPARL/Base.pm
--- old/PAR-Packer-1.054/lib/PAR/StrippedPARL/Base.pm   2021-01-20 
18:16:14.000000000 +0100
+++ new/PAR-Packer-1.055/lib/PAR/StrippedPARL/Base.pm   2022-07-03 
17:59:12.000000000 +0200
@@ -74,7 +74,7 @@
 
     system(Cwd::abs_path($tfile), @libs, qw( -q -B ), "-O$file");
     unless ($? == 0) {
-        warn "Failed to execute temporary parl (class $class) in file 
'$tfile': $!";
+        warn "Failed to execute temporary parl (class $class) '$tfile': 
\$?=$?";
         return;
     }
     return 1;
@@ -121,22 +121,22 @@
 =cut
 
 sub write_raw {
-    my $class = shift;
-    my $file = shift;
+    my ($class, $file) = @_;
     if (not defined $file) {
         warn "${class}->write_raw() needs a file name as argument";
-        return();
+        return;
     }
     my $binary = $class->get_raw();
     if (not defined $binary) {
         warn "${class}->get_raw() did not return the raw binary data for a PAR 
loader";
-        return();
+        return;
     }
 
-    open my $fh, '>', $file or die "Could not open file '$file' for writing: 
$!";
-    binmode $fh;
-    print $fh $binary;
-    close $fh;
+    my $fh;
+    (open $fh, '>:raw', $file) 
+    && (print $fh $binary)
+    && (close $fh)
+        or die "Could not write file '$file': $!";
 
     return 1;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/myldr/boot.c 
new/PAR-Packer-1.055/myldr/boot.c
--- old/PAR-Packer-1.054/myldr/boot.c   2021-04-06 10:31:08.000000000 +0200
+++ new/PAR-Packer-1.055/myldr/boot.c   2022-02-13 17:53:43.000000000 +0100
@@ -8,6 +8,15 @@
 #include <stdio.h>
 #include <stdarg.h>
 #endif
+#ifdef __MACH__
+#include <sys/sysctl.h>
+#include <mach-o/fat.h>
+#include <mach-o/loader.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <string.h> 
+#endif
 
 #include "mktmpdir.c"
 
@@ -77,6 +86,30 @@
     return EXTRACT_OK;
 }
 
+/* Simple magic number reader for MacOS */
+#ifdef __MACH__
+uint32_t read_magic(FILE *obj_file, int offset) {
+  uint32_t magic;
+  fseek(obj_file, offset, SEEK_SET);
+  fread(&magic, sizeof(uint32_t), 1, obj_file);
+  return magic;
+}
+
+/* double slashes in the tmpdir path confuse execve on macOS */
+char *sanitise_tmp(char *s) {
+  if (s) {
+    const char *src = s;
+    char *dst = s;
+    while ((*dst = *src) != '\0') {
+      do {
+        src++;
+      } while (*dst == '/' && *src == '/');
+      dst++;
+    }
+  }  
+  return s;
+}
+#endif
 
 /* turn off automatic globbing of process arguments when using MingW */
 #if defined(WIN32) && defined(__MINGW32__)
@@ -192,7 +225,7 @@
 
     par_init_env();
 
-    stmpdir = par_mktmpdir( argv );    
+    stmpdir = par_mktmpdir( argv );
     if ( !stmpdir ) die("");        /* error message has already been printed 
*/
 
     rc = my_mkdir(stmpdir, 0700);
@@ -204,6 +237,75 @@
     /* extract embedded_files[0] (i.e. the custom Perl interpreter) 
      * into stmpdir (but under the same basename as argv[0]) */
     my_prog = par_findprog(argv[0], par_getenv("PATH"));
+
+#ifdef __MACH__
+    {
+        /* Detect if FAT binary */
+        FILE *obj_file = fopen(my_prog, "rb");
+        uint32_t magic = read_magic(obj_file, 0);
+        fclose(obj_file);
+
+        if (magic == FAT_CIGAM || magic == FAT_MAGIC) 
+        {
+            /* Create separate dir for extracted thin binary*/
+            char *ftmpdir = malloc(strlen(stmpdir) + 5 + 1);
+            sprintf(ftmpdir, "%s%s", stmpdir, "/thin");
+            sanitise_tmp(ftmpdir);
+            rc = my_mkdir(ftmpdir, 0700);
+            if (rc == -1 && errno != EEXIST)
+                die("%s: creation of cache subdirectory "
+                    "for extracted macOS thin binary %s failed (errno= %i)\n", 
+                    argv[0], ftmpdir, errno);
+            
+            /* Get architecture name */
+            size_t size;
+            sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+            char *arch = malloc(size);
+            sysctlbyname("hw.machine", arch, &size, NULL, 0);
+
+            /* Detect if lipo exists, if not die */
+            struct stat buffer;
+            int exist = stat("/usr/bin/lipo", &buffer);
+            if (exist == -1)
+                die("%s: cannot find /usr/bin/lipo to unpack universal binary 
- "
+                    "do you need install Developer Tools? (errno=%i)\n", 
+                    argv[0], errno);
+          
+            char *archthinbin = malloc(strlen(ftmpdir) + 1 + 
strlen(par_basename(my_prog)) + 1);
+            sprintf(archthinbin, "%s/%s", ftmpdir, par_basename(my_prog));
+            char* lipo_argv[] = { "lipo", "-extract_family", arch, "-output", 
archthinbin, my_prog, NULL };
+            pid_t pid = fork();
+            if (pid == -1) 
+                die("%s: fork failed (errno=%i)\n",  argv[0], errno);
+            if (pid == 0)
+            {
+                /* child */
+                execve("/usr/bin/lipo", lipo_argv, env);
+                exit(1);
+            }
+
+            /* parent */
+            int wstatus;
+            waitpid(pid, &wstatus, 0);
+            if (!(WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0))
+                die("%s: extracting %s binary with lipo failed (wstatus=%i)\n",
+                    argv[0], arch, wstatus);
+            free(arch);
+
+            /* exec correct thin binary */
+            exist = stat(archthinbin, &buffer);
+            if (exist == -1)
+                die("%s: cannot find thin binary %s to run (errno=%i)\n", 
+                    argv[0], archthinbin, errno);
+
+            argv[0] = archthinbin;
+            execve(archthinbin, argv, env);
+            die("%s: cannot execute thin binary %s (errno=%i)\n", 
+                argv[0], archthinbin, errno);
+        }
+    }
+#endif    
+    
     rc = extract_embedded_file(embedded_files, par_basename(my_prog), stmpdir, 
&my_perl);
     if (rc == EXTRACT_FAIL) {
         die("%s: extraction of %s (custom Perl interpreter) failed 
(errno=%i)\n", 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/myldr/utils.c 
new/PAR-Packer-1.055/myldr/utils.c
--- old/PAR-Packer-1.054/myldr/utils.c  2021-04-06 10:33:36.000000000 +0200
+++ new/PAR-Packer-1.055/myldr/utils.c  2022-07-01 23:09:24.000000000 +0200
@@ -208,7 +208,6 @@
 }
 
 void par_init_env () {
-    char par_clean[] = "__ENV_PAR_CLEAN__               \0";
     char *buf;
 
     /* ignore PERL5LIB et al. as they make no sense for a self-contained 
executable */
@@ -239,12 +238,6 @@
     else if ( (buf = par_getenv("PAR_GLOBAL_CLEAN")) != NULL ) {
         par_setenv("PAR_CLEAN", buf);
     }
-    else {
-        buf = par_clean + 12 + strlen("CLEAN");
-        if (strncmp(buf, "PAR_CLEAN=", strlen("PAR_CLEAN=")) == 0) {
-            par_setenv("PAR_CLEAN", buf + strlen("PAR_CLEAN="));
-        }
-    }
 
     par_setenv("PAR_INITIALIZED", "1");
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/PAR-Packer-1.054/script/par.pl 
new/PAR-Packer-1.055/script/par.pl
--- old/PAR-Packer-1.054/script/par.pl  2021-04-05 23:22:05.000000000 +0200
+++ new/PAR-Packer-1.055/script/par.pl  2022-07-03 17:59:12.000000000 +0200
@@ -258,12 +258,15 @@
         outs(qq[Can't find magic string "$PAR_MAGIC" in file "$progname"]);
         last MAGIC;
     }
+    outs("Found PAR magic at position $magic_pos");
 
     # Seek 4 bytes backward from the signature to get the offset of the
     # first embedded FILE, then seek to it
     seek _FH, $magic_pos - 4, 0;
     read _FH, $buf, 4;
-    seek _FH, $magic_pos - 4 - unpack("N", $buf), 0;
+    my $offset = unpack("N", $buf);
+    outs("Offset from start of FILEs is $offset");
+    seek _FH, $magic_pos - 4 - $offset, 0;
     $data_pos = tell _FH;
 
     # }}}
@@ -474,14 +477,6 @@
     }
 
 
-    my %env = do {
-        if ($zip and my $meta = $zip->contents('META.yml')) {
-            $meta =~ s/.*^par:$//ms;
-            $meta =~ s/^\S.*//ms;
-            $meta =~ /^  ([^:]+): (.+)$/mg;
-        }
-    };
-
     # Open input and output files {{{
 
     if (defined $par) {
@@ -515,16 +510,9 @@
         require PAR::Filter::PodStrip;
         PAR::Filter::PodStrip->apply(\$loader, $0);
     }
-    foreach my $key (sort keys %env) {
-        my $val = $env{$key} or next;
-        $val = eval $val if $val =~ /^['"]/;
-        my $magic = "__ENV_PAR_" . uc($key) . "__";
-        my $set = "PAR_" . uc($key) . "=$val";
-        $loader =~ s{$magic( +)}{
-            $magic . $set . (' ' x (length($1) - length($set)))
-        }eg;
-    }
-    $fh->print($loader);
+
+    $fh->print($loader)
+        or die qq[Error writing loader to "$out": $!];
     # }}}
 
     # Write bundled modules {{{
@@ -595,9 +583,9 @@
             }
             else {
                 local $/ = undef;
-                open my $fh, '<:raw', $file or die qq[Can't read "$file": $!];
-                $content = <$fh>;
-                close $fh;
+                open my $th, '<:raw', $file or die qq[Can't read "$file": $!];
+                $content = <$th>;
+                close $th;
 
                 PAR::Filter::PodStrip->apply(\$content, "<embedded>/$name")
                     if !$ENV{PAR_VERBATIM} and $name =~ /\.(?:pm|ix|al)$/i;
@@ -609,30 +597,38 @@
                        pack('N', length($name) + 9),
                        sprintf("%08x/%s", 
Archive::Zip::computeCRC32($content), $name),
                        pack('N', length($content)),
-                       $content);
+                       $content)
+                or die qq[Error writing embedded FILE to "$out": $!];
+
             outs(qq[Written as "$name"]);
         }
     }
     # }}}
 
     # Now write out the PAR and magic strings {{{
-    $zip->writeToFileHandle($fh) if $zip;
+    if ($zip) {
+        $zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK
+            or die qq[Error writing zip part of "$out"];
+    }
 
     $cache_name = substr $cache_name, 0, 40;
     if (!$cache_name and my $mtime = (stat($out))[9]) {
         my $ctx = Digest::SHA->new(1);
-        open my $fh, "<:raw", $out;
-        $ctx->addfile($fh);
-        close $fh;
+        open my $th, "<:raw", $out;
+        $ctx->addfile($th);
+        close $th;
 
         $cache_name = $ctx->hexdigest;
     }
-    $cache_name .= "\0" x (41 - length $cache_name);
-    $cache_name .= "CACHE";
-    $fh->print($cache_name);
-    $fh->print(pack('N', $fh->tell - length($loader)));
-    $fh->print($PAR_MAGIC);
-    $fh->close;
+    $cache_name .= "\0" x (40 - length $cache_name);
+    $cache_name .= "\0CACHE";
+    # compute the offset from the end of $loader to end of "...\0CACHE"
+    my $offset = $fh->tell + length($cache_name) - length($loader);
+    $fh->print($cache_name, 
+               pack('N', $offset),
+               $PAR_MAGIC)
+    && $fh->close
+        or die qq[Error writing trailer of "$out": $!];
     chmod 0755, $out;
     # }}}
 
@@ -664,15 +660,28 @@
     # even if lots of stuff has been appended to the pp'ed exe (e.g. by OSX 
codesign).
     Archive::Zip::setChunkSize(-s _FH);
     my $zip = Archive::Zip->new;
-    ( $zip->readFromFileHandle($fh, $progname) == Archive::Zip::AZ_OK() )
+    ($zip->readFromFileHandle($fh, $progname) == Archive::Zip::AZ_OK())
         or die qq[Error reading zip archive "$progname"];
     Archive::Zip::setChunkSize(64 * 1024);
 
+    $quiet = !$ENV{PAR_DEBUG};
+
+    outs("Reading META.yml...");
+    if (my $meta = $zip->contents('META.yml')) {
+        # check par.clean
+        $meta =~ s/.*^par:\s*$//ms;
+        $meta =~ s/^\S.*//ms;
+        if (my ($clean) = $meta =~ /^\s+clean: (.*)$/m) {
+            $clean =~ /^\s*|\s*$/g;
+            $ENV{PAR_CLEAN} = 1 if $clean;
+        }
+    }
+
     push @PAR::LibCache, $zip;
     $PAR::LibCache{$progname} = $zip;
 
-    $quiet = !$ENV{PAR_DEBUG};
 
+    outs("Extracting zip...");
     if (defined $ENV{PAR_TEMP}) { # should be set at this point!
         foreach my $member ( $zip->members ) {
             next if $member->isDirectory;
@@ -690,8 +699,9 @@
             if (-f $dest_name && -s _ == $member->uncompressedSize()) {
                 outs(qq[Skipping "$member_name" since it already exists at 
"$dest_name"]);
             } else {
-                outs(qq[Extracting "$member_name" to "$dest_name"]);
-                $member->extractToFileNamed($dest_name);
+                outs(qq[Extracting "$member_name" to "$dest_name"...]);
+                ($member->extractToFileNamed($dest_name) == 
Archive::Zip::AZ_OK())
+                    or die qq[Error extracting zip member to "$dest_name"];
                 chmod(0555, $dest_name) if $^O eq "hpux";
             }
         }
@@ -842,9 +852,11 @@
     unless (-e $fullname) {
         my $tempname = "$fullname.$$";
 
-        open my $fh, '>:raw', $tempname or die qq[Can't write "$tempname": $!];
-        print $fh $contents;
-        close $fh;
+        my $fh;
+        (open $fh, '>:raw', $tempname)
+        && (print $fh $contents)
+        && (close $fh)
+            or die qq[Error writing "$tempname": $!];
         chmod $mode, $tempname if defined $mode;
 
         rename($tempname, $fullname) or unlink($tempname);
@@ -912,21 +924,16 @@
     }
 
     for (qw( SPAWNED TEMP CLEAN DEBUG CACHE PROGNAME ) ) {
-        delete $ENV{'PAR_'.$_};
+        delete $ENV{"PAR_$_"};
     }
+
     for (qw/ TMPDIR TEMP CLEAN DEBUG /) {
-        $ENV{'PAR_'.$_} = $ENV{'PAR_GLOBAL_'.$_} if exists 
$ENV{'PAR_GLOBAL_'.$_};
+        $ENV{"PAR_$_"} = $ENV{"PAR_GLOBAL_$_"} if exists $ENV{"PAR_GLOBAL_$_"};
     }
 
-    my $par_clean = "__ENV_PAR_CLEAN__               ";
-
     if ($ENV{PAR_TEMP}) {
         delete $ENV{PAR_CLEAN};
     }
-    elsif (!exists $ENV{PAR_GLOBAL_CLEAN}) {
-        my $value = substr($par_clean, 12 + length("CLEAN"));
-        $ENV{PAR_CLEAN} = $1 if $value =~ /^PAR_CLEAN=(\S+)/;
-    }
 }
 
 sub outs {

Reply via email to