From e583165dffac588ec58c0e0ecb8ca99a17fd6df3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 23 Dec 2020 17:45:59 +0000 Subject: [PATCH] Replace duplicate runtime files with hardlinks to reduce dmg size. --- packaging/macos/buildpackage.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packaging/macos/buildpackage.sh b/packaging/macos/buildpackage.sh index 87430d7794..5b50e406a6 100755 --- a/packaging/macos/buildpackage.sh +++ b/packaging/macos/buildpackage.sh @@ -181,6 +181,25 @@ build_platform() { SetFile -c icnC "/Volumes/OpenRA/.VolumeIcon.icns" SetFile -a C "/Volumes/OpenRA" + # Replace duplicate .NET runtime files with hard links to improve compression + if [ "${PLATFORM}" != "compat" ]; then + OIFS="$IFS" + IFS=$'\n' + for MOD in "Red Alert" "Tiberian Dawn"; do + for f in $(find /Volumes/OpenRA/OpenRA\ -\ ${MOD}.app/Contents/MacOS/*); do + g="/Volumes/OpenRA/OpenRA - Dune 2000.app/Contents/MacOS/"$(basename "${f}") + hashf=$(shasum "${f}" | awk '{ print $1 }') + hashg=$(shasum "${g}" | awk '{ print $1 }') + if [ "${hashf}" = "${hashg}" ]; then + echo "Deduplicating ${f}" + rm "${f}" + ln "${g}" "${f}" + fi + done + done + IFS="$OIFS" + fi + chmod -Rf go-w /Volumes/OpenRA sync sync