tdf#151341 Use lzfse compression instead of bzip2

Several users reported that copying the LibreOffice.app package
in the Finder from a .dmg file compressed with lzfse compression
copies the package several times faster than from a .dmg compressed
with bzip2 compression.

On a mid-2015 Intel MacBook Pro running macOS, copying in the Finder
was at least 5 times faster with lzfse than with bzip2. Also, the
hdiutil man page as of macOS Monterey 12.6.2 has marked bzip2 as
deprecated. lzfse is marked as supported since macOS El Capitan 10.11
so this change appears safe.

The one thing that bzip2 has is better compression so a .dmg with
bzip2 should be smaller than with lzfse. A .dmg built from a debug
build was 262M with bzip2 and 273MB for lzfse. So it appears that
lzfse creates .dmg files that are only 4% or 5% larger than bzip2.

Change-Id: I61e2a08cede19a5bb8c257d4fa4762168a3a9dc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144342
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit 5c98d8e79b4b35d30f1198f8c7b4beef44e421f4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144605
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/solenv/bin/modules/installer/simplepackage.pm b/solenv/bin/modules/installer/simplepackage.pm
index 5ab1297..e681a00 100644
--- a/solenv/bin/modules/installer/simplepackage.pm
+++ b/solenv/bin/modules/installer/simplepackage.pm
@@ -455,8 +455,23 @@ sub create_package
            }
        }
        my $megabytes = 1500;
        $megabytes = 2000 if $ENV{'ENABLE_DEBUG'};
        $systemcall = "cd $localtempdir && hdiutil create -megabytes $megabytes -srcfolder $folder $archive -ov -fs HFS+ -volname \"$volume_name\" -format UDBZ";
        $megabytes = 3000 if $ENV{'ENABLE_DEBUG'};

        # tdf#151341 Use lzfse compression instead of bzip2
        # Several users reported that copying the LibreOffice.app package
        # in the Finder from a .dmg file compressed with lzfse compression
        # copies the package several times faster than from a .dmg compressed
        # with bzip2 compression.
        # On a mid-2015 Intel MacBook Pro running macOS, copying in the Finder
        # was at least 5 times faster with lzfse than with bzip2. Also, the
        # hdiutil man page as of macOS Monterey 12.6.2 has marked bzip2 as
        # deprecated. lzfse is marked as supported since macOS El Capitan 10.11
        # so this change appears safe.
        # The one thing that bzip2 has is better compression so a .dmg with
        # bzip2 should be smaller than with lzfse. A .dmg built from a debug
        # build was 262M with bzip2 and 273MB for lzfse. So it appears that
        # lzfse creates .dmg files that are only 4% or 5% larger than bzip2.
        $systemcall = "cd $localtempdir && hdiutil create -megabytes $megabytes -srcfolder $folder $archive -ov -fs HFS+ -volname \"$volume_name\" -format ULFO";
        if (( $ref ne "" ) && ( $$ref ne "" ) && system("hdiutil 2>&1 | grep unflatten") == 0) {
            $systemcall .= " && hdiutil unflatten $archive && Rez -a $$ref -o $archive && hdiutil flatten $archive &&";
        }