Skip to content

Instantly share code, notes, and snippets.

@jegger
Created April 19, 2017 15:32
Show Gist options
  • Save jegger/215ff0e170bac4f68c3233cd05647f68 to your computer and use it in GitHub Desktop.
Save jegger/215ff0e170bac4f68c3233cd05647f68 to your computer and use it in GitHub Desktop.
macOS kivy pyinstaller sign
####
# Usage:
# build.sh kivy-app.sh
#
# What does this?:
# This signs kivy executables built with pyinstaller for macOS.
#
####
if [ $# -eq 0 ]
then
echo "Usage: build.sh paht/to/myKivyApp.app"
exit
fi
# Certificate used to sign the application
identity="Developer ID Application: <Company>"
app="$PWD/$1"
cd $app
# All paths to the included frameworks
sld2_image="Contents/Frameworks/SDL2_image.framework"
sld2_image_webp="Contents/Frameworks/SDL2_image.framework/Versions/A/Frameworks/webp.framework"
sdl_mixer="Contents/Frameworks/SDL2_mixer.framework"
sdl_mixer_flac="Contents/Frameworks/SDL2_mixer.framework/Versions/A/Frameworks/FLAC.framework"
sdl_mixer_modplug="Contents/Frameworks/SDL2_mixer.framework/Versions/A/Frameworks/modplug.framework"
sdl_mixer_ogg="Contents/Frameworks/SDL2_mixer.framework/Versions/A/Frameworks/Ogg.framework"
sdl_mixer_smpeg2="Contents/Frameworks/SDL2_mixer.framework/Versions/A/Frameworks/smpeg2.framework"
sdl_mixer_vorbis="Contents/Frameworks/SDL2_mixer.framework/Versions/A/Frameworks/Vorbis.framework"
sdl_ttf="Contents/Frameworks/SDL2_ttf.framework"
sdl_ttf_freetype="Contents/Frameworks/SDL2_ttf.framework/Versions/A/Frameworks/FreeType.framework"
sdl2="Contents/Frameworks/SDL2.framework"
# Sanitize frameworks folder structure
# There is nothing other than symlinks allowed in the top dir
# framework.framework
# framework -> Versions/Current/framework
# Resources -> Versions/Current/Resources
# Versions/
# Current -> A
# A/
# framework
# Resources
# SDL2_image.framework=>webp.framework
cd $sld2_image_webp
rm -rf Headers LICENSE* webp Resources Versions/Current
cd Versions
ln -s A Current
cd ..
ln -s Versions/Current/webp webp
ln -s Versions/Current/Resources Resources
cd $app
# SDL_image LICENCE files
rm -f "$sdl_mixer_flac/LICENSE.FLAC.txt"
rm -f "$sdl_mixer_modplug/LICENSE.modplug.txt"
rm -f "$sdl_mixer_ogg/LICENSE.ogg-vorbis.txt"
rm -f "$sdl_mixer_smpeg2/LICENSE.smpeg.txt"
rm -f "$sdl_mixer_vorbis/LICENSE.ogg-vorbis.txt"
#SDL freetype
cd $sdl_ttf_freetype
rm -rf FreeType LICENSE.freetype.txt Resources Versions/Current
cd Versions
ln -s A Current
cd ..
ln -s Versions/Current/FreeType FreeType
ln -s Versions/Current/Resources Resources
cd $app
# Sign frameworks
cd $app
# SDL Image
codesign --deep --force --verbose --sign "$identity" $sld2_image_webp
codesign --verbose --verify $sld2_image_webp
codesign --deep --force --verbose --sign "$identity" $sld2_image
codesign --verbose --verify $sld2_image
# SDL Mixer
codesign --deep --force --verbose --sign "$identity" $sdl_mixer_flac
codesign --verbose --verify $sdl_mixer_flac
codesign --deep --force --verbose --sign "$identity" $sdl_mixer_modplug
codesign --verbose --verify $sdl_mixer_modplug
codesign --deep --force --verbose --sign "$identity" $sdl_mixer_ogg
codesign --verbose --verify $sdl_mixer_ogg
codesign --deep --force --verbose --sign "$identity" $sdl_mixer_smpeg2
codesign --verbose --verify $sdl_mixer_smpeg2
codesign --deep --force --verbose --sign "$identity" $sdl_mixer_vorbis
codesign --verbose --verify $sdl_mixer_vorbis
codesign --deep --force --verbose --sign "$identity" $sdl_mixer
codesign --verbose --verify $sdl_mixer
# SDL ttf
codesign --deep --force --verbose --sign "$identity" $sdl_ttf_freetype
codesign --verbose --verify $sdl_ttf_freetype
codesign --deep --force --verbose --sign "$identity" $sdl_ttf
codesign --verbose --verify $sdl_ttf
# SDL2
codesign --deep --force --verbose --sign "$identity" $sdl2
codesign --verbose --verify $sdl2
# Sign hole app
codesign --deep --force --verbose --sign "$identity" $app
codesign --verbose --verify $app
# Was it succesfull?
spctl -a -vvvv $app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment