Switch the sfx installer to zstandard

Using a 7zip fork with zstandard support: https://github.com/mcmilk/7-Zip-zstd

Saves 20% CPU when extracting, also uses ~50MB less peak memory.
Downside is a 5% larger installer.
This commit is contained in:
Christoph Reiter
2021-11-29 16:40:00 +01:00
parent 289a0c9938
commit c898282f3f
5 changed files with 32 additions and 13 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
_cache
*.exe
*.xz

BIN
7zCon.sfx

Binary file not shown.

28
create-sfx.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# usage: ./create-sfx.sh /some/path/to/msys64 installer.exe
set -e
# Download and extract https://github.com/mcmilk/7-Zip-zstd
NAME="7z21.03-zstd-x64"
CHECKSUM="531b20dfb03d8f30f61ae56a181610bbb6f3cf7cc71dac1d8f95511289de76f3"
DIR="$( cd "$( dirname "$0" )" && pwd )"
mkdir -p "$DIR/_cache"
BASE="$DIR/_cache/$NAME"
if [ ! -f "$BASE.exe" ]; then
curl --fail -L "https://github.com/mcmilk/7-Zip-zstd/releases/download/v21.03-v1.5.0-R2/$NAME.exe" -o "$BASE.exe"
fi
echo "$CHECKSUM $BASE.exe" | sha256sum --quiet --check
if [ ! -d "$BASE" ]; then
7z e -o"$BASE" "$DIR/_cache/$NAME.exe"
fi
# Creat SFX installer
INPUT="$1"
OUTPUT="$2"
TEMP="$OUTPUT.payload"
rm -f "$TEMP"
"$BASE/7z" a "$TEMP" -ms1T -m0=zstd -mx22 "$INPUT"
cat "$BASE/7zCon.sfx" "$TEMP" > "$OUTPUT"
rm "$TEMP"

View File

@@ -1,10 +0,0 @@
#!/bin/bash
set -e
# Fetch 7zCon.sfx from upstream 7-zip
curl "https://www.7-zip.org/a/7z1900.exe" -o 7z1900.exe
echo "759aa04d5b03ebeee13ba01df554e8c962ca339c74f56627c8bed6984bb7ef80 7z1900.exe" | sha256sum --check
7z x -o7zout 7z1900.exe
cp 7zout/7zCon.sfx .
rm -Rf 7zout 7z1900.exe

View File

@@ -85,9 +85,7 @@ create_archives() {
fi
# self extracting cli 7z archive
7z a -mx=9 "${_thisdir}/_temp.7z" "msys${_bitness}"
cat ${_thisdir}/7zCon.sfx "${_thisdir}/_temp.7z" > "${_thisdir}/${_filename3}"
rm "${_thisdir}/_temp.7z"
"${_thisdir}/create-sfx.sh" "msys${_bitness}" "${_thisdir}/${_filename3}"
popd > /dev/null
}