From d395fdcc6a4240c683fc19b9f98575c859f71ecc Mon Sep 17 00:00:00 2001 From: Abel Luck Date: Wed, 13 Feb 2019 11:59:36 +0100 Subject: [PATCH] Make scripts/make-icons.sh work on linux This commit detects if the macos-only utility `iconutil` is available in the PATH, if it is, then the icns is built as usual. However if it isn't (such as on a linux system), then it checks for `png2icns` and uses it if possible. Signed-off-by: Abel Luck --- scripts/make-icons.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/make-icons.sh b/scripts/make-icons.sh index 19e48895..2db5293d 100755 --- a/scripts/make-icons.sh +++ b/scripts/make-icons.sh @@ -1,4 +1,10 @@ #!/bin/bash +# +# Converts an svg logo into the various image resources required by +# the various platforms deployments. +# +# On debian-based systems you need these deps: +# apt-get install xmlstarlet python3-cairosvg icnsutils if [ $# != 1 ] then @@ -52,7 +58,23 @@ cp "$tmpdir/256.png" "$tmpdir/Riot.iconset/icon_256x256.png" cp "$tmpdir/512.png" "$tmpdir/Riot.iconset/icon_256x256@2x.png" cp "$tmpdir/512.png" "$tmpdir/Riot.iconset/icon_512x512.png" cp "$tmpdir/1024.png" "$tmpdir/Riot.iconset/icon_512x512@2x.png" -iconutil -c icns -o electron_app/build/icon.icns "$tmpdir/Riot.iconset" + +if [ -x "$(command -v iconutil)" ]; then + # available on macos + iconutil -c icns -o electron_app/build/icon.icns "$tmpdir/Riot.iconset" +elif [ -x "$(command -v png2icns)" ]; then + # available on linux + # png2icns is more finicky about its input than iconutil + # 1. it doesn't support a 64x64 (aka 32x32@2x) + # 2. it doesn't like duplicates (128x128@2x == 256x256) + rm "$tmpdir/Riot.iconset/icon_128x128@2x.png" + rm "$tmpdir/Riot.iconset/icon_256x256@2x.png" + rm "$tmpdir/Riot.iconset/icon_16x16@2x.png" + rm "$tmpdir/Riot.iconset/icon_32x32@2x.png" + png2icns electron_app/build/icon.icns "$tmpdir"/Riot.iconset/*png +else + echo "WARNING: Unsupported platform. Skipping icns build" +fi cp "$tmpdir/36.png" "res/vector-icons/android-chrome-36x36.png" cp "$tmpdir/48.png" "res/vector-icons/android-chrome-48x48.png"