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.
29 lines
796 B
Bash
29 lines
796 B
Bash
#!/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"
|