diff --git a/packaging_scripts/HOWTO_MAC.md b/packaging_scripts/HOWTO_MAC.md new file mode 100644 index 0000000000000000000000000000000000000000..79d1d93e0af0cc37d9d97d94404bb42076560e9f --- /dev/null +++ b/packaging_scripts/HOWTO_MAC.md @@ -0,0 +1,18 @@ +This document describes how to create DMG package on MAC OSX. + +1. Run `./build_dmg_image_using_brew.sh` + +- This script create an empty dmg file. +- Mount it on /Volume/Moose_3.0.2 +- Install brew in it with prefix /Volumes/Moose_3.0.2 and `brew install moose` + with given prefix. +- It also adds an `moosegui` script which launches gui and also setup PYTHONPATH + in ~/.bash_profile. + +2. Run `./release_dmg_file.sh` + +- Copy the dmg created in step 1 and mount it. +- Remove unneccessay files `brew uninstall cmake gcc`. This saves us approx 400 + MB. +- Create another dmg file from folder and compress it. +- Compress this dmg file and test it on some MAC. diff --git a/packaging_scripts/build_dmg_image_using_brew.sh b/packaging_scripts/build_dmg_image_using_brew.sh new file mode 100755 index 0000000000000000000000000000000000000000..bf0b350bcd281c7bd274ba1334e47ad2bf8a4a35 --- /dev/null +++ b/packaging_scripts/build_dmg_image_using_brew.sh @@ -0,0 +1,177 @@ +#!/bin/bash + +echo "||NOTICE +If you are using this script on MacOSX 10.11.2, be careful about the following +error: + illegal instruction: 4 +I could get everything working fine on MacOSX- 10.8 +" + +set -x +set -e + +CURRDIR=`pwd` + +# Unset any enviroment PYTHONPATH. They can confuse us. +unset PYTHONPATH +PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin +export HOMEBREW_BUILD_FROM_SOURCE=YES + +## This is not needed. Forgot why I put it here in first place. +#CFLAGS+=-march=native + +APPNAME="Moose" +VERSION="3.0.2" +MAC_NAME=`sw_vers -productVersion` +PKGNAME="${APPNAME}_${VERSION}" + +VOLNAME="${PKGNAME}" + +### SAFETY +set +e +echo "|| Detaching possibly attached disk" +hdiutil detach /Volumes/${PKGNAME} +set -e + +DMGFILELABEL="${PKGNAME}" +THISDIR=`pwd` + +# create the temp DMG file +STAGING_DIR=_Install +DMG_TMP="${PKGNAME}-${MAC_NAME}_BREWED.dmg" +mkdir -p ${STAGING_DIR} + +if [ ! -f "${DMG_TMP}" ]; then + ## NOTE: When building MOOGLI, size should be at least 1 GB. + hdiutil create -srcfolder "${STAGING_DIR}" -volname "${PKGNAME}" \ + -format UDRW -size 1.5G "${DMG_TMP}" +else + echo "DMG file $DMG_TMP exists. Mounting ..." +fi + +# TODO +# mount it and save the device +DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \ + egrep '^/dev/' | sed 1q | awk '{print $1}') + +############################# EXIT gacefully ################################ +# Traps etc +# ALWAYS DETACH THE DEVICE BEFORE EXITING... +function detach_device +{ + hdiutil detach "${DEVICE}" + exit +} +trap detach_device SIGINT SIGTERM SIGKILL + +sleep 1 + +echo "Install whatever you want now" +BREW_PREFIX="/Volumes/${VOLNAME}" +BREW=$BREW_PREFIX/bin/brew +export PATH=${BREW_PREFIX}/bin:$PATH +( + cd $BREW_PREFIX + if [ ! -f $BREW_PREFIX/bin/brew ]; then + curl -L https://github.com/Homebrew/homebrew/tarball/master | \ + tar xz --strip 1 -C $BREW_PREFIX + else + echo "[I] Brew exists. Not installing" + fi + echo "Copying moose.rb and moogli.rb" + cp $CURRDIR/../macosx/*.rb $BREW_PREFIX/Library/Formula/ + + # This even works without python. + ## NOTE: DO NOT install matplotlib using brew unless also installing python + ## using brew. Since we are going to uninstall later, use pip to install + ## matplotlib and numpy. + $BREW -v install homebrew/python/matplotlib --with-pyqt + $BREW -v install homebrew/python/numpy + $BREW link --overwrite matplotlib + $BREW -v install homebrew/science/hdf5 + $BREW -v install moose --with-gui | tee "$CURRDIR/__brew_moose_log__" + # Set home of Qt4, openscenegraph etc. + # Install python-gobject + $BREW -v install gobject-introspection --env=std --with-head + export QT_HOME=$BREW_PREFIX + export OSG_HOME=$BREW_PREFIX + export PYQT_HOME=$BREW_PREFIX + $BREW -v install moogli | tee "$CURRDIR/__brew_moogli__log__" + # Lets not depends on system level libraries. Install all dependencies. + $BREW_PREFIX/bin/pip install suds-jurko --upgrade + $BREW_PREFIX/bin/pip install networkx + # Do not use pip to install matplotlib. It does not work. + + ## Tests + set -e + export PYTHONPATH=$BREW_PREFIX/lib/python2.7/site-packages + python -c 'import moose' + python -c 'import moogli' + python -c 'import matplotlib' + $BREW_PREFIX/bin/python -c 'import six' + set +e + + # Also write script to launch the moosegui. + MOOSEPATH=${BREW_PREFIX}/lib/python2.7/site-packages + cat > $BREW_PREFIX/moosegui <<EOF +#!/bin/bash +touch \$HOME/.bash_profile +source \$HOME/.bash_profile +if [[ "\${PYTHONPATH}" == *"${MOOSEPATH}"* ]]; then + echo "[INFO] PYTHONPATH aleady contains ${MOOSEPATH}" +else + # Also write to .bash_profile, so that we can use it. + echo "[INFO] Adding ${MOOSEPATH} to PYTHONPATH" + echo "export PYTHONPATH=${MOOSEPATH}:\$PYTHONPATH" >> \$HOME/.bash_profile + source \$HOME/.bash_profile +fi +# make sure that for current runtime, we have correct path. +export PYTHONPATH=${MOOSEPATH}:\$PYTHONPATH +exec ${BREW_PREFIX}/bin/moosegui +EOF + chmod a+x $BREW_PREFIX/moosegui +) + +################ COPY THE .app ########################################## +## DO NOT USE APP BUNDLE. +## Use simple shell script to launch moose. +###echo "|| Copying the APP to directory" +####cp -rpf "${APPNAME}.app" "$BREW_PREFIX" +###APPEXE="${APPNAME}.app/Contents/MacOS/${APPNAME}" +###mkdir -p `dirname $APPEXE` +#### create the executable. +###cat > ${APPEXE} <<-EOF +####!/bin/bash +###${BREW_PREFIX}/bin/moosegui +###EOF +###chmod +x ${APPEXE} + +################ INSTALL THE ICON ######################################## +DMG_BACKGROUND_IMG="${CURRDIR}/moose_icon_large.png" +# Check the background image DPI and convert it if it isn't 72x72 +_BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'` +_BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'` + +if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then + echo "WARNING: The background image's DPI is not 72." + echo "This will result in distorted backgrounds on Mac OS X 10.7+." + echo "I will convert it to 72 DPI for you." + _DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}" + sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP} + DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}" +fi + +echo "TODO. Now resize and compress using hdiutil" +echo "|| use: hdiutil convert a.dmg -format UDBZ -o b.dmg" + +#### TODO: Resize the harddisk and compress it for distribution if tests are OK. +##set +e +##DISKSIZE=`du -sh /Volumes/"${VOLNAME}"` +##echo "Overall disk size is $DISKSIZE" +##echo "|| Blowing up brew cache" +##rm -rf `${BREW_PREFIX}/bin/brew --cache` +## +##DISKSIZE=`du -sh /Volumes/"${VOLNAME}"` + +## Finally detach the device +detach_device diff --git a/packaging_scripts/build_dmg_without_package_managers.sh b/packaging_scripts/build_dmg_without_package_managers.sh new file mode 100755 index 0000000000000000000000000000000000000000..d729d42ab6dbaac3d6aadc090d13ab7a4b876a48 --- /dev/null +++ b/packaging_scripts/build_dmg_without_package_managers.sh @@ -0,0 +1,293 @@ +#!/bin/bash + +echo "||NOTICE +If you are using this script on MacOSX 10.11.2, be careful about the following +error: + illegal instruction: 4 +I could get everything working fine on MacOSX- 10.8 +" + +set -x +set -e + +CURRDIR=`pwd` + +# Unset any enviroment PYTHONPATH. They can confuse us. +unset PYTHONPATH + +echo "|WARN| Unsetting PATH" +unset PATH +export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin + +APPNAME="Moose" +VERSION="3.0.2" +MAC_NAME=`sw_vers -productVersion` +PKGNAME="${APPNAME}_${VERSION}" + +VOLNAME="${PKGNAME}" + +### SAFETY +set +e +echo "|| Detaching possibly attached disk" +hdiutil detach /Volumes/${PKGNAME} +set -e + +DMGFILELABEL="${PKGNAME}" +THISDIR=`pwd` + +# create the temp DMG file +STAGING_DIR=_Install +DMG_TMP="${PKGNAME}-${MAC_NAME}_LOCAL.dmg" +mkdir -p ${STAGING_DIR} + +SIZE=1G +echo "|| Creating dmg file of $SIZE size" +if [ ! -f "${DMG_TMP}" ]; then + hdiutil create -srcfolder "${STAGING_DIR}" -volname "${PKGNAME}" \ + -format UDRW -size $SIZE "${DMG_TMP}" +else + echo "DMG file $DMG_TMP exists. Mounting ..." +fi + +# TODO +# mount it and save the device +DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \ + egrep '^/dev/' | sed 1q | awk '{print $1}') + +############################# EXIT gacefully ################################ +# Traps etc +# ALWAYS DETACH THE DEVICE BEFORE EXITING... +function detach_device +{ + hdiutil detach "${DEVICE}" + exit +} +trap detach_device SIGINT SIGTERM SIGKILL + +sleep 1 + +echo "Install whatever you want now" +PORT_PREFIX="/Volumes/${VOLNAME}" +PYTHONPREFIX=$PORT_PREFIX/pymodules +export PATH=${PORT_PREFIX}/bin:$PATH +( + WORKDIR=$CURRDIR/_work + mkdir -p $WORKDIR + cd $PORT_PREFIX + ## NOTICE: Try to build using Xcode. + + # 1. Get cmake and install it to cmake/bin + CMAKE_BIN=$PORT_PREFIX/cmake/bin/cmake + if [ -f $CMAKE_BIN ]; then + echo "|| cmake is available at $CMAKE_BIN " + else + echo "No $CMAKE_BIN found. Building one" + cd $WORKDIR + curl -O https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz + tar xvf cmake-3.3.2.tar.gz + cd cmake-3.3.2 || ls -l + ./bootstrap + ./configure --prefix=$PORT_PREFIX/cmake + make -j3 + make install + cd $PORT_PREFIX + fi + + # 2. Install moose-full using cmake. + MOOSE_PREFIX=$PORT_PREFIX/moose + export PYTHONPATH=$PYTHONPREFIX/lib/python2.7/site-packages + if python -c 'import moose'; then + echo "|STATUS| MOOSE is installed and could be imported" + else + cd $WORKDIR + if [ ! -d moose-full ]; then + echo "Cloning moose-full" + git clone --depth 1 https://github.com/BhallaLab/moose-full + fi + set -e + cd moose-full + mkdir -p _build && cd _build + $CMAKE_BIN -DCMAKE_INSTALL_PREFIX=$MOOSE_PREFIX .. + make -j3 + # Override the install step. + cd ../moose-core/python + python setup.py install --prefix=$PYTHONPREFIX + python -c 'import moose' + set +e + cd $WORKDIR + cd .. + fi + + # 3. Let's get Qt4 + QTPREFIX=$PORT_PREFIX/qt4.8 + mkdir -p $QTPREFIX + ( + mkdir -p $QTPREFIX/bin/ + if [ ! -f $QTPREFIX/bin/qmake ]; then + echo "|| Trying to install qt" + cd $WORKDIR + QTDIR="qt" + if [ ! -d "$QTDIR" ]; then + git clone --depth 1 https://github.com/qtproject/qt + else + echo "|| qt is already downloaded." + #cd qt && git clean -fxd && cd .. + fi + cd $QTDIR + # Delete all license files so qt it does not prompt us to accept + # license. + ./configure -opensource -stl -no-qt3support \ + -confirm-license -nomake examples -nomake demos \ + -prefix $QTPREFIX + make -j3 + make install + else + echo "||| Qt seems to be installed. Here are the list of libs" + ls -lh "$QTPREFIX/lib" + fi + ) + + # 4. Install SIP + SIPPREFIX=$PORT_PREFIX/sip + mkdir -p $SIPPREFIX + if python -c 'import sip'; then + echo "|| SIP is installed" + else + ( + cd $WORKDIR + # Thought of trying this version as it is indicated to work with pyqt4. + SIPHEAD=4.17 + if [ ! -f sip-$SIPHEAD.tar.gz ] ; then + rm -f sip-$SIPHEAD.tar.gz + echo "|| Downloading SIP" + curl -L -O "https://sourceforge.net/projects/pyqt/files/sip/sip-4.15.5/sip-4.15.5.tar.gz" + else + echo "|| SIP is already downloaded and unarchived" + fi + + tar xvf sip-$SIPHEAD.tar.gz + + cd sip-$SIPHEAD + echo "|| installing sip" + python configure.py -b $SIPPREFIX/bin \ + -d $PYTHONPATH \ + -e $SIPPREFIX/include \ + -v $SIPPREFIX/include/sip + make + ( cd siplib && python -c 'import sip' ) + make install + ) + fi + + # 5. Install PyQt4. + + ( + if python -c 'from PyQt4 import pyqtconfig'; then + echo "|| PyQt4 already installed" + exit 1 + fi + + cd $WORKDIR + QTVERSION="4.11.4" + if [ ! -d PyQt-mac-gpl-$QTVERSION ]; then + echo "|| Downloading PyQt4" + curl -L -O "https://www.sourceforge.net/projects/pyqt/files/PyQt4/PyQt-$QTVERSION/PyQt-mac-gpl-$QTVERSION.tar.gz" + tar xvf PyQt-mac-gpl-$QTVERSION.tar.gz + else + echo "|| Already PyQt4 downloaded" + fi + cd PyQt-mac-gpl-$QTVERSION + export PATH=$QTPREFIX/bin:$PATH:$SIPPREFIX/bin + echo "||| sip: `which sip`" + #--sip-incdir=$SIPPREFIX/include \ + python configure.py --confirm-license \ + -b $PYTHONPREFIX/bin \ + -d $PYTHONPATH \ + -v $PYQT4PREFIX/sip + make -j3 + make install + ) + + # Install osg + OSGPREFIX=$PORT_PREFIX/osg + ( + if [ -f $OSGPREFIX/lib/libosg.dylib ]; then + echo "||| Looks like osg is installed. Heres the libraries" + ls $OSGPREFIX/lib + #exit + fi + cd $WORKDIR + OSG_VERSION=3.2.3 + if [ ! -f OpenSceneGraph-$OSG_VERSION.zip ]; then + echo "|| Downloading OSG - $OSG_VERSION" + curl -O http://trac.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-3.2.3.zip + else + echo "||| OSG $OSG_VERSION is already downloaded" + fi + if [ ! -d OpenSceneGraph-$OSG_VERSION ]; then + echo "|||| Unzipping " + unzip OpenSceneGraph-$OSG_VERSION.zip + fi + cd OpenSceneGraph-$OSG_VERSION + mkdir -p _build + cd _build + export QTDIR=$QTPREFIX + $CMAKE_BIN -DDESIRED_QT_VERSION=4 -DCMAKE_INSTALL_PREFIX=$OSGPREFIX .. + make -j4 + make install + ) + + # Now finally moogli. + MOOGLI_PREFIX=$PORT_PREFIX/moogli + ( + export DYLD_FALLBACK_FRAMEWORK_PATH=$QTPREFIX/lib + export DYLD_LIBRARY_PATH=$OSGPREFIX/lib + if python -c 'import moogli'; then + echo "Seems like moogli is already installed" + exit + fi + + cd $WORKDIR + if [ ! -d moogli ]; then + git clone --depth 1 --branch macosx https://github.com/BhallaLab/moogli + else + echo "||| moogli is already downloaded" + fi + cd moogli + export QT_HOME=$QTPREFIX + export OSG_HOME=$OSGPREFIX + export PYQT_HOME=$PYTHONPATH/PyQt4 + ( CFLAGS="-m64" CXXFLAGS="" OPT="" ARCHFLAGS="-arch x86_64" python setup.py build ) + if python -c 'import moogli'; then + CFLAGS="-m64" CXXFLAGS="" OPT="" ARCHFLAGS="-arch x86_64" \ + python setup.py install --prefix=$PYTHONPATH + # Also copy the _moogli.so, to be sure. distutils behaves oddly. + cp moogli/core/_moogli.so $PYTHONPATH/moogli/core/_moogli.so + else + echo "|| Loading of module is failing." + fi + ) + + ##||| Install startup scripts. + MOOSEPATH=${PORT_PREFIX}/lib/python2.7/site-packages + cat > $PORT_PREFIX/moosegui <<EOF +#!/bin/bash +touch \$HOME/.bash_profile +source \$HOME/.bash_profile +if [[ "\${PYTHONPATH}" == *"${MOOSEPATH}"* ]]; then + echo "[INFO] PYTHONPATH aleady contains ${MOOSEPATH}" +else + # Also write to .bash_profile, so that we can use it. + echo "[INFO] Adding ${MOOSEPATH} to PYTHONPATH" + echo "export PYTHONPATH=${MOOSEPATH}:\$PYTHONPATH" >> \$HOME/.bash_profile + source \$HOME/.bash_profile +fi +# make sure that for current runtime, we have correct path. +export PYTHONPATH=${MOOSEPATH}:\$PYTHONPATH +exec ${PORT_PREFIX}/bin/moosegui +EOF + chmod a+x $PORT_PREFIX/moosegui +) + +## Finally detach the device +detach_device diff --git a/packaging_scripts/build_using_xcode.sh b/packaging_scripts/build_using_xcode.sh new file mode 100755 index 0000000000000000000000000000000000000000..311c7562f690b1b15704eab28c9a57b2d901fb87 --- /dev/null +++ b/packaging_scripts/build_using_xcode.sh @@ -0,0 +1,14 @@ +#!/bin/bash +( + mkdir -p _build_macosx_ + cd _build_macosx_ + PROJECT=Moose.xcodeproj + cmake -G "Xcode" .. + xcodebuild -list + xcodebuild clean -project $PROJECT -configuration Release -alltargets + xcodebuild archive -project $PROJECT -configuration Release \ + -scheme moose.bin \ + -archivePath Moose.xcarhive + xcodebuild -exportArchive -archivePath Moose.xcarhive -exportPath Moose \ + -exportFormat pkg +) diff --git a/packaging_scripts/cmake_sanity_check.py b/packaging_scripts/cmake_sanity_check.py new file mode 100755 index 0000000000000000000000000000000000000000..e39e6d8ae18c19932b043fa02a78175ce7a80f70 --- /dev/null +++ b/packaging_scripts/cmake_sanity_check.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +"""cmake_sanity_check.py: Check if Cmake files are ok. + +Last modified: Sat Jan 18, 2014 05:01PM + +""" + +__author__ = "Dilawar Singh" +__copyright__ = "Copyright 2013, Dilawar Singh and NCBS Bangalore" +__credits__ = ["NCBS Bangalore"] +__license__ = "GNU GPL" +__version__ = "1.0.0" +__maintainer__ = "Dilawar Singh" +__email__ = "dilawars@ncbs.res.in" +__status__ = "Development" + +import sys +import os +import re +from collections import defaultdict + +makefiles = {} +cmakefiles = {} +makedirs = set() +cmakedirs = set() + +def check(d): + searchMakefiles(d) + checkMissingCMake() + checkSrcs() + +def checkMissingCMake(): + if (makedirs - cmakedirs): + print("[Failed] Test 1") + print("Following directories have Makefile but not a CMakeFiles.txt file.") + print("%s" % "\t\n".join(makedirs - cmakedirs)) + +def searchMakefiles(d): + for d, subd, fs in os.walk(d): + if "CMakeLists.txt" in fs: + cmakedirs.add(d) + cmakefiles[d] = fs + if "Makefile" in fs: + makedirs.add(d) + makefiles[d] = fs + else: pass + +def checkSrcs(): + objPat = re.compile(r"\w+\.o") + srcPat = re.compile(r"\w+\.cpp") + srcs = [] + csrcs = [] + for d in makefiles: + with open(os.path.join(d, "Makefile"), "r") as f: + txt = f.read() + srcs = objPat.findall(txt) + try: + with open(os.path.join(d, "CMakeLists.txt"), "r") as f: + txt = f.read() + csrcs = srcPat.findall(txt) + except: + print("Dir {} does not have CMakeLists.txt".format(d)) + csrcs = [] + #print("[TEST 2] Checking if CMake is creating extra objects") + for csr in csrcs: + objName = csr.replace(".cpp", ".o") + if objName in srcs: + pass + else: + #print(" Failed: In dir {}, CMake is creating extra object {}".format(d, objName)) + + pass + print("[TEST 3] Checking if CMake is missing some objects") + for obj in srcs: + srcName = obj.replace(".o", ".cpp") + if srcName in csrcs: pass + else: + print(" Failed: In dir {}, CMake is missing object {}".format(d, + srcName)) + +def main(): + dir = sys.argv[1] + check(dir) + + +if __name__ == '__main__': + main() diff --git a/packaging_scripts/moose_icon_64x64.png b/packaging_scripts/moose_icon_64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..270f5aa4fe31501e11b8e47b7777a43334309d6c Binary files /dev/null and b/packaging_scripts/moose_icon_64x64.png differ diff --git a/packaging_scripts/moose_icon_large.png b/packaging_scripts/moose_icon_large.png new file mode 100644 index 0000000000000000000000000000000000000000..ab8a1f041a97b9ed4bff0e0e34b41e10ecb795d0 Binary files /dev/null and b/packaging_scripts/moose_icon_large.png differ diff --git a/packaging_scripts/release_dmg_file.sh b/packaging_scripts/release_dmg_file.sh new file mode 100755 index 0000000000000000000000000000000000000000..a3ad35dd5e2fae3eb70ec08dee085d39e2abc1f6 --- /dev/null +++ b/packaging_scripts/release_dmg_file.sh @@ -0,0 +1,106 @@ +#!/bin/bash +set -x + +BREW_PREFIX=/Volumes/Moose_3.0.2 +function test_installation +{ + echo "||||||||| TEST STEP" + export PYTHONPATH=$BREW_PREFIX/lib/python2.7/site-packages + python -c 'import moose' + python -c 'import moogli' + python -c 'import matplotlib; import numpy' + python -c 'import networkx as nx' +} + +LABEL=Moose_3.0.2 + +# Not all build dependencies are required at runtime. Lets just disable them. +DMGFILE="$1" +if [ ! $DMGFILE ]; then + echo "USAGE: $0 dmg_file" + exit +fi + +TEMPDMG="$DMGFILE"_temp.dmg +rm -f $TEMPDMG +cp $DMGFILE $TEMPDMG + +echo "|| Detaching dmg file" +hdiutil detach /Volumes/$LABEL + +echo "|| Mouting DMG file" +hdiutil attach $TEMPDMG + +( + echo "Removing the temp files" + cd /Volumes/$LABEL + du -sh /Volumes/$LABEL + # One command in each line, else if one fails everyoone fails. + ./bin/brew uninstall cmake + ./bin/brew uninstall gcc + ./bin/brew uninstall python + ./bin/brew uninstall wget + ./bin/brew uninstall pkg-config + ./bin/brew uninstall sqlite + + rm -rf include + test_installation + rm -rf Frameworks + test_installation + rm -rf Library + test_installation + rm -rf etc + test_installation + rm -rf var + test_installation + ( + cd Cellar/qt/4.8* + rm -rf *.app + rm -rf bin + rm -rf tests + rm -rf plugins + rm -rf mkspecs + rm -rf translations + rm -rf Frameworks + ) + test_installation + + # Delete all folders named include and share and doc + find . -type d -name "include" -print0 | xargs -0 -I d rm -rf d + test_installation + find . -type d -name "share" -print0 | xargs -0 -I d rm -rf d + test_installation + find . -type d -name "doc" -print0 | xargs -0 -I d rm -rf d + test_installation + find . -type d -name "tests" -not -path "*/networkx/*" -print0 | xargs -0 -I d rm -rf d + test_installation + + # Remove all *.a + find . -name "*.a" -exec rm -rf \{} \; + find . -name "*.html" -exec rm -rf \{} \; + find . -name "*.pdf" -exec rm -rf \{} \; + find . -name "*.md" -exec rm -rf \{} \; + test_installation + + # Adding license. + curl -O https://gnu.org/licenses/gpl.txt + mv gpl.txt LICENSE.txt + + du -sh /Volumes/$LABEL +) + +# Create another image from this folder. +OUTFILE="$DMGFILE"_RW.dmg +rm -f $OUTFILE +hdiutil create -volname $LABEL -srcfolder /Volumes/$LABEL \ + -ov -format UDRW "$OUTFILE" + +ls -lh *.dmg + +echo "|| Detaching .." +hdiutil detach /Volumes/$LABEL + +echo "|| Compressing " +rm -f "$LABEL"_OSX.dmg +hdiutil convert "$OUTFILE" -format UDBZ -o "$LABEL"_OSX.dmg +