-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use 7z to create more efficient ZIP archives #81
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ export basedir=$(pwd) | |
# For signing keystore and password. | ||
source ./config.sh | ||
|
||
export ZIP="7z a -bso0 -bd -mx9" | ||
|
||
can_sign_windows=0 | ||
if [ ! -z "${SIGN_KEYSTORE}" ] && [ ! -z "${SIGN_PASSWORD}" ] && [[ $(type -P "osslsigncode") ]]; then | ||
can_sign_windows=1 | ||
|
@@ -47,7 +49,7 @@ sign_macos() { | |
codesign --force --timestamp \ | ||
--options=runtime --entitlements editor.entitlements \ | ||
-s ${OSX_KEY_ID} -v ${_appname} && \ | ||
zip -r ${_binname}_signed.zip ${_appname}" | ||
$ZIP -r ${_binname}_signed.zip ${_appname}" | ||
|
||
_request_uuid=$(ssh "${OSX_HOST}" "xcrun notarytool submit ${_macos_tmpdir}/${_binname}_signed.zip --team-id \"${APPLE_TEAM}\" --apple-id \"${APPLE_ID}\" --password \"${APPLE_ID_PASSWORD}\" --no-progress --output-format json") | ||
_request_uuid=$(echo ${_request_uuid} | sed -e 's/.*"id":"\([^"]*\)".*/\1/') | ||
|
@@ -61,7 +63,7 @@ sign_macos() { | |
ssh "${OSX_HOST}" " | ||
cd ${_macos_tmpdir} && \ | ||
xcrun stapler staple ${_appname} && \ | ||
zip -r ${_binname}_stapled.zip ${_appname}" | ||
$ZIP -r ${_binname}_stapled.zip ${_appname}" | ||
scp "${OSX_HOST}:${_macos_tmpdir}/${_binname}_stapled.zip" "${_reldir}/${_binname}.zip" | ||
ssh "${OSX_HOST}" "rm -rf ${_macos_tmpdir}" | ||
fi | ||
|
@@ -82,7 +84,7 @@ sign_macos_template() { | |
codesign --force -s - \ | ||
--options=linker-signed \ | ||
-v macos_template.app/Contents/MacOS/* && \ | ||
zip -r macos_signed.zip macos_template.app" | ||
$ZIP -r macos_signed.zip macos_template.app" | ||
|
||
scp "${OSX_HOST}:${_macos_tmpdir}/macos_signed.zip" "${_reldir}/macos.zip" | ||
ssh "${OSX_HOST}" "rm -rf ${_macos_tmpdir}" | ||
|
@@ -240,22 +242,22 @@ if [ "${build_classical}" == "1" ]; then | |
# Editor | ||
binname="${godot_basename}_linux.x86_64" | ||
cp out/linux/x86_64/tools/godot.linuxbsd.editor.x86_64 ${binname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} | ||
rm ${binname} | ||
|
||
binname="${godot_basename}_linux.x86_32" | ||
cp out/linux/x86_32/tools/godot.linuxbsd.editor.x86_32 ${binname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} | ||
rm ${binname} | ||
|
||
binname="${godot_basename}_linux.arm64" | ||
cp out/linux/arm64/tools/godot.linuxbsd.editor.arm64 ${binname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} | ||
rm ${binname} | ||
|
||
binname="${godot_basename}_linux.arm32" | ||
cp out/linux/arm32/tools/godot.linuxbsd.editor.arm32 ${binname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} | ||
rm ${binname} | ||
|
||
# Templates | ||
|
@@ -279,7 +281,7 @@ if [ "${build_classical}" == "1" ]; then | |
cp out/windows/x86_64/tools/godot.windows.editor.x86_64.console.exe ${wrpname} | ||
strip ${wrpname} | ||
sign_windows ${wrpname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} ${wrpname} | ||
rm ${binname} ${wrpname} | ||
|
||
binname="${godot_basename}_win32.exe" | ||
|
@@ -290,7 +292,7 @@ if [ "${build_classical}" == "1" ]; then | |
cp out/windows/x86_32/tools/godot.windows.editor.x86_32.console.exe ${wrpname} | ||
strip ${wrpname} | ||
sign_windows ${wrpname} | ||
zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname} | ||
$ZIP "${reldir}/${binname}.zip" ${binname} ${wrpname} | ||
rm ${binname} ${wrpname} | ||
|
||
# Templates | ||
|
@@ -313,7 +315,7 @@ if [ "${build_classical}" == "1" ]; then | |
mkdir -p Godot.app/Contents/MacOS | ||
cp out/macos/tools/godot.macos.editor.universal Godot.app/Contents/MacOS/Godot | ||
chmod +x Godot.app/Contents/MacOS/Godot | ||
zip -q -9 -r "${reldir}/${binname}.zip" Godot.app | ||
$ZIP -r "${reldir}/${binname}.zip" Godot.app | ||
rm -rf Godot.app | ||
sign_macos ${reldir} ${binname} 0 | ||
|
||
|
@@ -325,7 +327,7 @@ if [ "${build_classical}" == "1" ]; then | |
cp out/macos/templates/godot.macos.template_release.universal macos_template.app/Contents/MacOS/godot_macos_release.universal | ||
cp out/macos/templates/godot.macos.template_debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal | ||
chmod +x macos_template.app/Contents/MacOS/godot_macos* | ||
zip -q -9 -r "${templatesdir}/macos.zip" macos_template.app | ||
$ZIP -r "${templatesdir}/macos.zip" macos_template.app | ||
rm -rf macos_template.app | ||
sign_macos_template ${templatesdir} 0 | ||
|
||
|
@@ -370,15 +372,15 @@ if [ "${build_classical}" == "1" ]; then | |
cp -r deps/vulkansdk-macos/MoltenVK/MoltenVK.xcframework ios_xcode/ | ||
rm -rf ios_xcode/MoltenVK.xcframework/{macos,tvos}* | ||
cd ios_xcode | ||
zip -q -9 -r "${templatesdir}/ios.zip" * | ||
$ZIP -r "${templatesdir}/ios.zip" * | ||
cd .. | ||
rm -rf ios_xcode | ||
|
||
## Templates TPZ (Classical) ## | ||
|
||
echo "${templates_version}" > ${templatesdir}/version.txt | ||
pushd ${templatesdir}/.. | ||
zip -q -9 -r -D "${reldir}/${godot_basename}_export_templates.tpz" templates/* | ||
$ZIP -r "${reldir}/${godot_basename}_export_templates.tpz" templates/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only difference I can notice between 2 ZIP archives created (one with In practice, this appears to make no concrete difference on what you see when opening the ZIP archive: both have the exact same folder structure when viewed with GUI archive managers. In short, I think the #!/usr/bin/env bash
mkdir -p example/{folder1,folder2,empty_folder}
touch example/{folder1,folder2}/example.txt
echo -e "\n\n================ Creating archives ================"
zip -r example.zip example
zip -r example-flat.zip example/*
zip -r -D example-D.zip example
zip -r -D example-D-flat.zip example/*
7z a example-7z.zip example
7z a example-7z-flat.zip example/*
echo -e "\n\n================ File contents created by zip ================"
7z l example.zip
7z l example-flat.zip
7z l example-D.zip
7z l example-D-flat.zip
echo -e "\n\n================ File contents created by 7z ================"
7z l example-7z.zip
7z l example-7z-flat.zip There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record, in the asset library I had to fix some bugs related to directory entries missing. Not sure if the export template installer handles it any better. |
||
popd | ||
|
||
## SHA-512 sums (Classical) ## | ||
|
@@ -402,14 +404,14 @@ if [ "${build_mono}" == "1" ]; then | |
mkdir -p ${binbasename}_x86_64 | ||
cp out/linux/x86_64/tools-mono/godot.linuxbsd.editor.x86_64.mono ${binbasename}_x86_64/${binbasename}.x86_64 | ||
cp -rp out/linux/x86_64/tools-mono/GodotSharp ${binbasename}_x86_64/ | ||
zip -r -q -9 "${reldir_mono}/${binbasename}_x86_64.zip" ${binbasename}_x86_64 | ||
$ZIP -r "${reldir_mono}/${binbasename}_x86_64.zip" ${binbasename}_x86_64 | ||
rm -rf ${binbasename}_x86_64 | ||
|
||
binbasename="${godot_basename}_mono_linux" | ||
mkdir -p ${binbasename}_x86_32 | ||
cp out/linux/x86_32/tools-mono/godot.linuxbsd.editor.x86_32.mono ${binbasename}_x86_32/${binbasename}.x86_32 | ||
cp -rp out/linux/x86_32/tools-mono/GodotSharp/ ${binbasename}_x86_32/ | ||
zip -r -q -9 "${reldir_mono}/${binbasename}_x86_32.zip" ${binbasename}_x86_32 | ||
$ZIP -r "${reldir_mono}/${binbasename}_x86_32.zip" ${binbasename}_x86_32 | ||
rm -rf ${binbasename}_x86_32 | ||
|
||
binbasename="${godot_basename}_mono_linux" | ||
|
@@ -449,7 +451,7 @@ if [ "${build_mono}" == "1" ]; then | |
cp out/windows/x86_64/tools-mono/godot.windows.editor.x86_64.mono.console.exe ${binname}/${wrpname}.exe | ||
strip ${binname}/${wrpname}.exe | ||
sign_windows ${binname}/${wrpname}.exe | ||
zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname} | ||
$ZIP -r "${reldir_mono}/${binname}.zip" ${binname} | ||
rm -rf ${binname} | ||
|
||
binname="${godot_basename}_mono_win32" | ||
|
@@ -462,7 +464,7 @@ if [ "${build_mono}" == "1" ]; then | |
cp out/windows/x86_32/tools-mono/godot.windows.editor.x86_32.mono.console.exe ${binname}/${wrpname}.exe | ||
strip ${binname}/${wrpname}.exe | ||
sign_windows ${binname}/${wrpname}.exe | ||
zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname} | ||
$ZIP -r "${reldir_mono}/${binname}.zip" ${binname} | ||
rm -rf ${binname} | ||
|
||
# Templates | ||
|
@@ -486,7 +488,7 @@ if [ "${build_mono}" == "1" ]; then | |
cp out/macos/tools-mono/godot.macos.editor.universal.mono Godot_mono.app/Contents/MacOS/Godot | ||
cp -rp out/macos/tools-mono/GodotSharp Godot_mono.app/Contents/Resources/GodotSharp | ||
chmod +x Godot_mono.app/Contents/MacOS/Godot | ||
zip -q -9 -r "${reldir_mono}/${binname}.zip" Godot_mono.app | ||
$ZIP -r "${reldir_mono}/${binname}.zip" Godot_mono.app | ||
rm -rf Godot_mono.app | ||
sign_macos ${reldir_mono} ${binname} 1 | ||
|
||
|
@@ -497,7 +499,7 @@ if [ "${build_mono}" == "1" ]; then | |
cp out/macos/templates-mono/godot.macos.template_debug.universal.mono macos_template.app/Contents/MacOS/godot_macos_debug.universal | ||
cp out/macos/templates-mono/godot.macos.template_release.universal.mono macos_template.app/Contents/MacOS/godot_macos_release.universal | ||
chmod +x macos_template.app/Contents/MacOS/godot_macos* | ||
zip -q -9 -r "${templatesdir_mono}/macos.zip" macos_template.app | ||
$ZIP -r "${templatesdir_mono}/macos.zip" macos_template.app | ||
rm -rf macos_template.app | ||
sign_macos_template ${templatesdir_mono} 1 | ||
|
||
|
@@ -521,7 +523,7 @@ if [ "${build_mono}" == "1" ]; then | |
cp -r deps/vulkansdk-macos/MoltenVK/MoltenVK.xcframework ios_xcode/ | ||
rm -rf ios_xcode/MoltenVK.xcframework/{macos,tvos}* | ||
cd ios_xcode | ||
zip -q -9 -r "${templatesdir_mono}/ios.zip" * | ||
$ZIP -r "${templatesdir_mono}/ios.zip" * | ||
cd .. | ||
rm -rf ios_xcode | ||
|
||
|
@@ -541,7 +543,7 @@ if [ "${build_mono}" == "1" ]; then | |
|
||
echo "${templates_version}.mono" > ${templatesdir_mono}/version.txt | ||
pushd ${templatesdir_mono}/.. | ||
zip -q -9 -r -D "${reldir_mono}/${godot_basename}_mono_export_templates.tpz" templates/* | ||
$ZIP -r "${reldir_mono}/${godot_basename}_mono_export_templates.tpz" templates/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also needs -D equivalent. |
||
popd | ||
|
||
## SHA-512 sums (Mono) ## | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this bit forces me to have 7zip installed on macOS, which is less trivial than on Linux.
It seems available on homebrew but homebrew isn't set up on HP's Mac, could likely install it.
But this begs the question of whether there's anything more actively maintained than 7zip to compress zips. The last release dates back to 2016.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last GUI release was made in June 2023: https://7-zip.org/
However, the CLI version was never updated past 16.02 (May 2016). This is an unfortunate artifact of 7-zip being developed around its Windows GUI first, and also being developed behind closed doors.
I don't know of any alternatives that have the same level of efficiency and performance for compressing ZIP archives. Using Zopfli to create a ZIP archive will result in slightly more efficiency, but it's more than 10× slower which makes it not worth the time.
zip -9
is slightly better than the default option, but still not as good as7z a -mx9
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Windows only though, no?
I found PeaZip which seems actively maintained and properly cross-platform: https://github.com/peazip/PeaZip/releases/
Might be worth comparing with 7zip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in macOS homebrew, there are two 7Z packages:
p7zip
-7z
executable, built from p7zip port source from 2017 (17.04).sevenzip
-7zz
executable, built from official 2023 source (23.01, same as GUI version).Seems like official source added support for Linux/macOS command line build in 2021.
Edit: Debian seems to use the same naming, so it should be standard - https://manpages.debian.org/unstable/7zip/7zz.1.en.html