99# IMPORTANT: Application bundle must exist in folder noted below
1010# User must specify the package version: (example: "-v 1.0.56")
1111#
12- # All other parameters are optional: (FTDI driver installer, restart requirement, developer identities, deploy package request )
12+ # All other parameters are optional: (FTDI driver installer, restart requirement, developer identities)
1313#
1414# These files and folders must exist in the paths show below (in relation to this script's folder):
1515# ./drivers/FTDIUSBSerialDriver.kext
16+ # ./mac-resources/neededToRun.entitlements
1617# ../dist/|application_bundle_name|.app
1718#
1819# To update the driver,
2324# - copy the FTDIUSBSerialDriver.kext from /Library/Extensions/ to the ../drivers/ folder
2425#
2526# The ../dist/|application_bundle_name|.app will be modified by this script to digitally sign it with the default or optional
26- # application developer identity certificate
27+ # application developer identity certificate as well as with the given runtime entitlements (neededToRun.entitlements)
2728#
2829
2930usage ()
5657#
5758# Resource paths
5859#
60+ # Notes:
61+ # * All are paths relative to this script.
62+ # * NWJS_FW_LIBRARIES (NW.js Framework Libraries) is the path inside of APP_BUNDLE (defined later)
63+ #
5964RESOURCES=" ./mac-resources/"
6065DISTRIBUTION=" ../dist/"
66+ NWJS_FW=" /Contents/Frameworks/nwjs Framework.framework/"
67+ NWJS_FW_LIBRARIES=" ${NWJS_FW} Versions/Current/Libraries/"
68+ ENTITLEMENTS=" ${RESOURCES} neededToRun.entitlements"
6169
6270#
6371# Default installation locations
6472#
65- # note: the FTDI kext used to be in "/System/Library/Extensions/" per Apple's previous suggestion (before Mavericks?)
73+ # Note: the FTDI kext used to be in "/System/Library/Extensions/" per Apple's previous suggestion (before Mavericks?)
74+ #
6675FTDIDRIVER_DEST_DIR=" /Library/Extensions/"
6776DEFAULT_APP_DIR=" /Applications/"
6877
@@ -75,7 +84,8 @@ FTDIDRIVER_KEXT=${FTDIDRIVER}.kext
7584#
7685# Modified temporary distro xml
7786#
78- # note: will contain copied or sed-modified version of template DistributionXXXX.xml
87+ # Note: will contain copied or sed-modified version of template DistributionXXXX.xml
88+ #
7989DIST_DST=DistributionMOD.xml
8090
8191#
@@ -267,16 +277,64 @@ else
267277 exit 1
268278fi
269279
280+ echo
281+
282+ #
283+ # Attempt to deeply codesign the known-to-be-unsigned nwjs libraries and nwjs framework
284+ #
285+ echo " Code signing nwjs libraries and framework within the application bundle: ${DISTRIBUTION}${APP_BUNDLE} with identity: \" ${APP_IDENTITY} \" "
286+ #
287+ # signing libEGL.dylib
288+ #
289+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE}${NWJS_FW_LIBRARIES} libEGL.dylib"
290+ if [ " $? " != " 0" ]; then
291+ echo " [Error] Code signing nwjs library failed!" 1>&2
292+ exit 1
293+ fi
294+ #
295+ # libGLESv2.dylib
296+ #
297+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE}${NWJS_FW_LIBRARIES} libGLESv2.dylib"
298+ if [ " $? " != " 0" ]; then
299+ echo " [Error] Code signing nwjs library failed!" 1>&2
300+ exit 1
301+ fi
302+ #
303+ # libswiftshader_libEGL.dylib
304+ #
305+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE}${NWJS_FW_LIBRARIES} libswiftshader_libEGL.dylib"
306+ if [ " $? " != " 0" ]; then
307+ echo " [Error] Code signing nwjs library failed!" 1>&2
308+ exit 1
309+ fi
310+ #
311+ # libswiftshader_libGLESv2.dylib
312+ #
313+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE}${NWJS_FW_LIBRARIES} libswiftshader_libGLESv2.dylib"
314+ if [ " $? " != " 0" ]; then
315+ echo " [Error] Code signing nwjs library failed!" 1>&2
316+ exit 1
317+ fi
318+ #
319+ # nwjs Framework
320+ #
321+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE}${NWJS_FW} nwjs Framework"
322+ if [ " $? " != " 0" ]; then
323+ echo " [Error] Code signing nwjs framework failed!" 1>&2
324+ exit 1
325+ fi
326+
327+
270328echo
271329
272330#
273331# Attempt to deeply codesign the app bundle
274332#
275333echo " Code signing the application bundle (hardened runtime with entitlements): ${DISTRIBUTION}${APP_BUNDLE} with identity: \" ${APP_IDENTITY} \" "
276- codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ./mac-resources/neededToRun.entitlements " " ${DISTRIBUTION}${APP_BUNDLE} "
334+ codesign -s " $APP_IDENTITY " --deep -f -v --options runtime --timestamp --entitlements " ${ENTITLEMENTS} " " ${DISTRIBUTION}${APP_BUNDLE} "
277335if [ " $? " != " 0" ]; then
278- echo " [Error] Codesigning the application bundle failed!" 1>&2
279- exit 1
336+ echo " [Error] Code signing the application bundle failed!" 1>&2
337+ exit 1
280338fi
281339
282340echo
0 commit comments