+ rm -f "${BUNDLE_PATH}"/*-${arch}
+ done
+}
+
+# -------------------------
+# Create code sign signatures
+# -------------------------
+code_sign() {
+ target="$1"
+ condir=$(content_directory "${target}"/lyx)
+ appdir=$(dirname "${condir}")
+ # have to sign frameworks first
+ for fwname in Aspell Hunspell LibMagic ; do
+ fwitem="${condir}"/$(framework_name "${fwname}")
+ if [ -d "${fwitem}" ]; then
+ codesign --verbose --force --sign "${CODESIGN_IDENTITY}" "${fwitem}"
+ fi
+ done
+ for csitem in \
+ "${condir}"/Frameworks/Qt*.framework/Versions/${QtFrameworkVersion} \
+ "${condir}"/PlugIns/*/lib*.dylib \
+ "${condir}"/Library/Spotlight/* \
+ "${target}"/inkscape \
+ "${target}"/lilypond \
+ "${target}"/lilypond-book \
+ "${target}"/maxima \
+ "${target}"/tex2lyx \
+ "${target}"/lyxeditor \
+ "${target}"/lyxconvert \
+ "${target}"/lyxclient
+ do
+ codesign --verbose --force --sign "${CODESIGN_IDENTITY}" "${csitem}"
+ done
+
+ /usr/bin/codesign --verbose --force --sign "${CODESIGN_IDENTITY}" "${appdir}" || {
+ echo Warning: codesign failed with certificate named '"'${CODESIGN_IDENTITY}'"'
+ }
+}
+
+deduplicate() {
+ find "$@" -type f -print | while read file ; do
+ echo $(md5 -q "$file") "$file"
+ done | sort | while read hash file ; do
+ ppath=$(dirname "$pfile")
+ path=$(dirname "$file")
+ if [ "$phash" = "$hash" -a "$ppath" = "$path" ]; then
+ pname=$(basename "$pfile")
+ name=$(basename "$file")
+ cmp -s "$pfile" "$file" && (
+ rm "$file"
+ cd "$path" && ln -s "$pname" "$name" && echo link for "$file" created
+ )
+ fi
+ phash="$hash"
+ pfile="$file"