From c086283bc534a46e63f4cd00f539c694657dae45 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Thu, 22 Mar 2012 18:37:43 -0700 Subject: [PATCH] added scripts to build bundle and dmg on Mac OS X --- packaging/fwb3-makebundle.sh | 206 +++++++++++++++++++++++++++++++++ packaging/fwbuilder-makedmg.sh | 48 ++++++++ 2 files changed, 254 insertions(+) create mode 100755 packaging/fwb3-makebundle.sh create mode 100755 packaging/fwbuilder-makedmg.sh diff --git a/packaging/fwb3-makebundle.sh b/packaging/fwb3-makebundle.sh new file mode 100755 index 000000000..f238de3ed --- /dev/null +++ b/packaging/fwb3-makebundle.sh @@ -0,0 +1,206 @@ +#!/bin/sh +# +# This script assembles Mac OS X bundle +# +#--------------------------------------------------------------------- +# +# + + +function usage { + echo "makebundle MODULE_NAME BUNDLE_ROOT" + exit 1 +} + +unset DISPLAY +unset LD_LIBRARY_PATH + +MODULE_NAME=$1 +BUNDLE_ROOT=$2 + +test -z "$BUNDLE_ROOT" && { + usage + exit 1 +} + +export BUNDLE_ROOT + +# Assuming script is being run with fwbuilder top directory as +# cwd. Need to switch to the top level build environment dir. + +test -d 'tools' || cd ../.. + +pwd + +eval $(python tools/module.py -s $MODULE_NAME) + +BUILD_ROOT_DIR=$(pwd) + +test -d ${BUILD_ROOT_DIR}/source || { + echo "Can't find directory where source tree should be located: ${BUILD_ROOT_DIR}/source" + exit 1 +} + +#VERSIONED_MODULE_NAME=$(basename $BUNDLE_ROOT | sed 's/\.app//') +VERSIONED_MODULE_NAME="$MODULE_NAME-$VERSION" + +echo "Module name: $MODULE_NAME" +echo "Versioned module name: $VERSIONED_MODULE_NAME" + +QT_FRAMEWORKS="QtCore QtGui QtNetwork QtDBus QtXml" + +FWBUILDER_ROOT_DIR=$(find ${BUILD_ROOT_DIR}/source -name "$VERSIONED_MODULE_NAME" -o -name $MODULE_NAME -depth 1) + +echo +echo "=== Building bundle ${BUNDLE_ROOT} " +echo + +TMP_BUNDLE_DIR=$(ls -d ${FWBUILDER_ROOT_DIR}/src/gui/*.app) +test -z "$TMP_BUNDLE_DIR" && { + echo "Can not find GUI bundle inside of ${FWBUILDER_ROOT_DIR}/src/gui" + exit 1 +} +TMP_BUNDLE=$(basename $TMP_BUNDLE_DIR) +rm -rf $TMP_BUNDLE + +cp -R ${FWBUILDER_ROOT_DIR}/src/gui/$TMP_BUNDLE . + +echo "=== Running macdeployqt" +macdeployqt ${TMP_BUNDLE} + + +echo "=== Copying fwbuilder resources and libfwbuilder libraries" +mkdir -p ${TMP_BUNDLE}/Contents/Resources +mkdir -p ${TMP_BUNDLE}/Contents/Resources/os +mkdir -p ${TMP_BUNDLE}/Contents/Resources/platform +mkdir -p ${TMP_BUNDLE}/Contents/Resources/help +mkdir -p ${TMP_BUNDLE}/Contents/Resources/configlets + +(cd ${FWBUILDER_ROOT_DIR}/src/res/; tar cf - --exclude .svn {*.xml,os/*.xml,platform/*.xml,help,configlets} ) | \ + tar -C ${TMP_BUNDLE}/Contents/Resources -xf - + +mkdir -p ${TMP_BUNDLE}/Contents/Frameworks + +#echo "=== Copying libfwbuilder" +# +#cp ${LIBFWBUILDER_ROOT_DIR}/src/fwbuilder/libfwbuilder.?.dylib \ +# ${TMP_BUNDLE}/Contents/Frameworks/ +#cp ${LIBFWBUILDER_ROOT_DIR}/src/fwcompiler/libfwcompiler.?.dylib \ +# ${TMP_BUNDLE}/Contents/Frameworks/ +# +#chmod u+w ${TMP_BUNDLE}/Contents/Frameworks/* + +cp ${FWBUILDER_ROOT_DIR}/src/libfwbuilder/etc/fwbuilder.dtd ${TMP_BUNDLE}/Contents/Resources + +mkdir -p ${TMP_BUNDLE}/Contents/Resources/migration +cp ${FWBUILDER_ROOT_DIR}/src/libfwbuilder/migration/*.xslt ${TMP_BUNDLE}/Contents/Resources/migration + + + +echo "=== Copying binaries" +cp -r ${FWBUILDER_ROOT_DIR}/src/fwbedit/fwbedit.app/Contents/MacOS/fwbedit \ + ${TMP_BUNDLE}/Contents/MacOS/ + +for c in ipt pf ipf ipfw iosacl pix procurve_acl +do + cp -r ${FWBUILDER_ROOT_DIR}/src/$c/fwb_$c.app/Contents/MacOS/fwb_$c \ + ${TMP_BUNDLE}/Contents/MacOS/ +done + +chmod +x ${TMP_BUNDLE}/Contents/MacOS/fwb* + +for f in ${TMP_BUNDLE}/Contents/MacOS/fwb* +do + for framework in $QT_FRAMEWORKS + do + install_name_tool -change ${framework}.framework/Versions/4/${framework} \ + @executable_path/../Frameworks/${framework}.framework/Versions/4/${framework} \ + $f + done +done + +rm -rf $BUNDLE_ROOT +mv $TMP_BUNDLE $BUNDLE_ROOT + + +exit 0 + + + +echo "=== Copying qt.conf file" +cp ${FWBUILDER_ROOT_DIR}/packaging/qt.conf ${BUNDLE_ROOT}/Contents/Resources + +echo "=== Copying .nib files" +test -d /Library/Frameworks/QtGui.framework/Versions/4/Resources && \ + cp -R /Library/Frameworks/QtGui.framework/Versions/4/Resources/* ${BUNDLE_ROOT}/Contents/Resources + +# we have no working translations in v4 and v5 +# echo "=== Copying locales" +# mkdir -p ${BUNDLE_ROOT}/Contents/Resources/locale +# cp -r ${FWBUILDER_ROOT_DIR}/src/gui/*.qm ${BUNDLE_ROOT}/Contents/Resources/locale + +qt_translations=$(find /Developer/Applications/Qt/translations/ -name '*.qm') +test -n "$qt_translations" && { + for f in $qt_translations; do + cp $f ${BUNDLE_ROOT}/Contents/Resources/locale/ + done +} + + +echo "=== Setting up copies of QT frameworks" + +for framework in $QT_FRAMEWORKS +do + test -d /Library/Frameworks/${framework}.framework/Versions && { + cp -R /Library/Frameworks/${framework}.framework/Versions/4/${framework} ${BUNDLE_ROOT}/Contents/Frameworks/ + install_name_tool -id @executable_path/../Frameworks/${framework} \ + ${BUNDLE_ROOT}/Contents/Frameworks/${framework} + } +done + +mkdir -p ${BUNDLE_ROOT}/Contents/plugins +cp /Developer//Applications/Qt/plugins/accessible/libqtaccessiblewidgets.dylib \ + ${BUNDLE_ROOT}/Contents/plugins/ + + +install_name_tool -change QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/QtCore \ + ${BUNDLE_ROOT}/Contents/Frameworks/QtGui + +install_name_tool -change QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/QtCore \ + ${BUNDLE_ROOT}/Contents/Frameworks/QtNetwork + +install_name_tool -change QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/QtCore \ + ${BUNDLE_ROOT}/Contents/Frameworks/QtXml + +test -f ${BUNDLE_ROOT}/Contents/Frameworks/QtDBus && { + install_name_tool -change QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/QtCore \ + ${BUNDLE_ROOT}/Contents/Frameworks/QtDBus + install_name_tool -change QtXml.framework/Versions/4/QtXml \ + @executable_path/../Frameworks/QtXml \ + ${BUNDLE_ROOT}/Contents/Frameworks/QtDBus +} + +install_name_tool -change QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/QtCore \ + ${BUNDLE_ROOT}/Contents/plugins/libqtaccessiblewidgets.dylib +install_name_tool -change QtGui.framework/Versions/4/QtGui \ + @executable_path/../Frameworks/QtGui \ + ${BUNDLE_ROOT}/Contents/plugins/libqtaccessiblewidgets.dylib + + +for f in ${BUNDLE_ROOT}/Contents/MacOS/fwb* +do + for framework in $QT_FRAMEWORKS + do + install_name_tool -change ${framework}.framework/Versions/4/${framework} \ + @executable_path/../Frameworks/${framework} \ + $f + done +done + + + diff --git a/packaging/fwbuilder-makedmg.sh b/packaging/fwbuilder-makedmg.sh new file mode 100755 index 000000000..9668abb49 --- /dev/null +++ b/packaging/fwbuilder-makedmg.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +MODULE_NAME=$1 +BUNDLE=$2 + +test -z "$BUNDLE" && { + echo "Usage: fwbuilder-makedmg.sh MODULE_NAME " + exit 1 +} + +# assuming the top of fwbuilder module source code is cwd when this +# script is executed +BUILD_ROOT_DIR="../../" + +. VERSION + +BASE_DMG_FILE_NAME=$(basename $BUNDLE | sed 's/\.app/.dmg/') +BASE_RO_DMG_FILE_NAME=$(basename $BUNDLE | sed 's/\.app/-ro.dmg/') + +SLA_FILE="packaging/SLA.r" +DMG_FILE="${BUILD_ROOT_DIR}/$BASE_DMG_FILE_NAME" +DMG_RO_FILE="${BUILD_ROOT_DIR}/${BASE_RO_DMG_FILE_NAME}" + +/usr/bin/hdiutil create -srcfolder $BUNDLE \ + -ov -fs HFS+ -volname "Firewall Builder $VERSION" $DMG_FILE +# chmod 0664 $DMG_FILE + +# ################################################################ +# How to add license agreement to the dms image +# +# http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Containers/chapter_3_section_4.html +# +# Need "Software License Agreements for UDIFs (DMG)" +# http://developer.apple.com/sdk/index.html +# Instructions are in this package. The SLA prototype in this SDK was in +# a format that requires resource editor which I could not find. However +# SLA prototype file provided in the buildDMG package found at +# http://www.objectpark.org/buildDMG.html was usable. The prototype comes +# in file SLA.r which can be edited with XCode (just do "open SLA.r"). +# I added NetCitadel license text to the file SLA.r and checked it in +# as modules/fwbuilder/files/packaging/SLA.r + +hdiutil convert -format UDCO $DMG_FILE -o $DMG_RO_FILE +hdiutil unflatten $DMG_RO_FILE +Rez /Developer/Headers/FlatCarbon/*.r $SLA_FILE -a -o $DMG_RO_FILE +hdiutil flatten $DMG_RO_FILE +mv $DMG_RO_FILE $DMG_FILE +