bin/lo-pack-sources |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit a0165bb7900f6d03a49076d755568ac33ee8e9c9
Author:     Sebastian Andrzej Siewior <sebast...@breakpoint.cc>
AuthorDate: Fri Feb 10 22:18:05 2023 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sat Feb 11 22:45:27 2023 +0000

    lo-pack-sources: Add support for pbzip2.
    
    Use pbzip for compression if possible. Otherwise fallback to bzip2.
    
    Signed-off-by: Sebastian Andrzej Siewior <sebast...@breakpoint.cc>
    Change-Id: I9091c5dfe25ee00854b6938464af23b56cdcb31c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146814
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/bin/lo-pack-sources b/bin/lo-pack-sources
index 289a595b06e0..a34a4c95ab6a 100755
--- a/bin/lo-pack-sources
+++ b/bin/lo-pack-sources
@@ -285,19 +285,33 @@ sub generate_module_tarball($$$$$$$$)
     my ($source_dir, $release_version, $module, $md5, $bzip2, $xz, 
$lo_topdir_name, $module_tarball_name) = @_;
         my $PARALLELISM =  $ENV{'PARALLELISM'};
         my $CPUS_XZ = 0;
+        my $CPUS_BZ2 = "";
+        my $bzip_arguments;
 
         # Set CPUS_ to the number of CPUs that should be used. If PARALLELISM
     # is set then this is used otherwise autodetect is used.
     if (defined $PARALLELISM) {
         if ($PARALLELISM > 0) {
             $CPUS_XZ = $PARALLELISM;
+            $CPUS_BZ2 = "-p$PARALLELISM";
         } else {
             $CPUS_XZ = 1;
+            $CPUS_BZ2 = "-p1";
                  }
     }
 
+        if (defined $bzip2) {
+                 my $exit_code = system("pbzip2 --version >/dev/null 2>&1");
+                 if ($exit_code == 0) {
+                         $bzip_arguments = "pbzip2 -z -b20 $CPUS_BZ2";
+                 } else {
+                         $bzip_arguments = "bzip2 -z --best";
+                         print("Consider installing pbzip2, using bzip2 
now.\n");
+                 }
+        }
+
     my $temp_dir = prepare_module_sources($source_dir, $release_version, 
$module, $lo_topdir_name);
-    pack_module_sources($temp_dir, $md5, "$module_tarball_name.tar.bz2", 
"bzip2 -z --best > ") if (defined $bzip2);
+    pack_module_sources($temp_dir, $md5, "$module_tarball_name.tar.bz2", 
"$bzip_arguments > ") if (defined $bzip2);
     pack_module_sources($temp_dir, $md5, "$module_tarball_name.tar.xz", "xz -z 
-T$CPUS_XZ -e > ") if (defined $xz);
     remove_tempdir($temp_dir);
 }

Reply via email to