3 # Script to sign dylibs and frameworks in an app bundle plus the
4 # bundle itself. Called from
5 # installer::simplepackage::create_package() in
6 # solenv/bin/modules/installer/simplepackage.pm
8 test `uname` = Darwin ||
{ echo This is
for OS X only
; exit 1; }
10 test $# = 1 ||
{ echo Usage
: $0 app-bundle
; exit 1; }
14 MACOSX_BUNDLE_IDENTIFIER \
15 MACOSX_CODESIGNING_IDENTITY
; do
16 if test -z "$(eval echo '$'$V)"; then
17 echo No
'$'$V "environment variable! This should be run in a build only"
22 echo "codesigning using MACSOX_CODESIGNING_IDENTITY=[${MACOSX_CODESIGNING_IDENTITY?}]"
28 # Executables get signed right after linking, see
29 # solenv/gbuild/platform/macosx.mk. But many of our dylibs are built
30 # by ad-hoc or 3rd-party mechanisms, so we can't easily sign them
31 # right after linking. So do it here.
33 # The dylibs in the Python framework are called *.so. Go figure
35 # On Mavericks also would like to have data files signed...
36 # add some where it makes sense. Make a depth-first search to sign the contents
37 # of e.g. the spotlight plugin before attempting to sign the plugin itself
39 find -d "$APP_BUNDLE" \
( -name '*.dylib' -or -name '*.so' -or -name '*.fodt' \
40 -or -name 'schema.strings' -or -name 'schema.xml' -or -name '*.mdimporter' \
41 -or -name '*.jar' -or -name '*.jnilib' -or -name 'LICENSE' -or -name 'LICENSE.html' \
42 -or -name '*.applescript' \
) ! -type l |
grep -v "LibreOfficePython\.framework" | \
44 id
=`echo ${file#${APP_BUNDLE}/Contents/} | sed -e 's,/,.,g'`
45 codesign
--verbose --identifier=$MACOSX_BUNDLE_IDENTIFIER.
$id --sign "$MACOSX_CODESIGNING_IDENTITY" "$file" ||
exit 1
48 find $APP_BUNDLE -name '*.dylib.*' ! -type l | \
49 while read dylib
; do \
50 id
=`basename "$dylib"`; \
51 id
=`echo $id | sed -e 's/dylib.*/dylib/'`; \
52 codesign
--verbose --identifier=$MACOSX_BUNDLE_IDENTIFIER.
$id --sign "$MACOSX_CODESIGNING_IDENTITY" "$dylib" ||
exit 1
55 # The executables have already been signed by
56 # gb_LinkTarget__command_dynamiclink in
57 # solenv/gbuild/platform/macosx.mk, but sign the handful of scripts remaining
59 # (<https://developer.apple.com/library/mac/technotes/tn2206/_index.html> "OS X
60 # Code Signing In Depth" suggests we should get rid of them rather sooner than
61 # later, but they appear to be OK for now):
63 for i
in gengal python senddoc unoinfo
65 if [ -f "$APP_BUNDLE/Contents/MacOS/$i" ]
67 codesign
--verbose --identifier="$MACOSX_BUNDLE_IDENTIFIER.$i" \
68 --sign "$MACOSX_CODESIGNING_IDENTITY" "$APP_BUNDLE/Contents/MacOS/$i" \
75 # Yeah, we don't bundle any other framework than our Python one, and
76 # it has just one version, so this generic search is mostly for
79 for framework
in `find $APP_BUNDLE -name '*.framework' -type d`; do \
80 fn
="$(basename $framework)"
82 for version
in $framework/Versions
/*; do \
83 if test ! -L $version -a -d $version; then
84 codesign
--force --verbose --prefix=$MACOSX_BUNDLE_IDENTIFIER.
--sign "$MACOSX_CODESIGNING_IDENTITY" $version/$fn ||
exit 1
85 codesign
--force --verbose --prefix=$MACOSX_BUNDLE_IDENTIFIER.
--sign "$MACOSX_CODESIGNING_IDENTITY" $version ||
exit 1
90 # Sign the app bundle as a whole which means finally signing the
91 # CFBundleExecutable from Info.plist, i.e. soffice (which is exempted from the
92 # on-the-go executable signing in gb_LinkTarget__command_dynamiclink in
93 # solenv/gbuild/platform/macosx.mk), plus the contents
94 # of the Resources tree (which unless you used
95 # --enable-canonical-installation-tree-structure is not much, far from
96 # all of our non-code "resources").
98 # At this stage we also attach the entitlements in the sandboxing case
100 id
=`echo ${MACOSX_APP_NAME} | tr ' ' '-'`
102 if test -n "$ENABLE_MACOSX_SANDBOX"; then
103 entitlements
="--entitlements $BUILDDIR/lo.xcent"
106 codesign
--force --verbose --identifier="${MACOSX_BUNDLE_IDENTIFIER}.$id" --sign "$MACOSX_CODESIGNING_IDENTITY" $entitlements $APP_BUNDLE ||
exit 1