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 <abel@guardianproject.info>
This commit is contained in:
Abel Luck 2019-02-13 11:59:36 +01:00
parent a64b1c4b51
commit d395fdcc6a
No known key found for this signature in database
GPG Key ID: D780C7E7C59278C8
1 changed files with 23 additions and 1 deletions

View File

@ -1,4 +1,10 @@
#!/bin/bash #!/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 ] if [ $# != 1 ]
then 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_256x256@2x.png"
cp "$tmpdir/512.png" "$tmpdir/Riot.iconset/icon_512x512.png" cp "$tmpdir/512.png" "$tmpdir/Riot.iconset/icon_512x512.png"
cp "$tmpdir/1024.png" "$tmpdir/Riot.iconset/icon_512x512@2x.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/36.png" "res/vector-icons/android-chrome-36x36.png"
cp "$tmpdir/48.png" "res/vector-icons/android-chrome-48x48.png" cp "$tmpdir/48.png" "res/vector-icons/android-chrome-48x48.png"