Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bash script for local nightly builds of QGIS master branch on Mac OS X Snow Leopard and Lion
#!/bin/bash
# -*- coding: utf-8 -*-
#
# Create QGIS for Mac OS X nightly build from github.com 'master' branch.
# Keep a number of dmg archives of previous builds as backups.
#
# Tested under Lion 10.7.4 and Snow Leopard 10.6.8, **run via sudo**
# Requires same kyngchaos.com framework setup and build environment as per
# https://github.com/qgis/Quantum-GIS/blob/master/INSTALL
### start run settings
CPUCORES=`/usr/sbin/sysctl -n hw.ncpu`
GITPULL=1
GITSTASH=1
BUILDQGIS=1
QGISDEBUG=0
QGISAPIDOCS=TRUE
QGISTESTS=FALSE
ADDQSCI=1
ARCHIVEAPP=1
KEEPARCHIVES=10
### end run settings
# output locations
USERDIR=`echo ~`
QGISDIR="$USERDIR/QGIS"
NIGHTLYDIR="$QGISDIR/github-nightly"
QGISGITDIR="$NIGHTLYDIR/quantum-gis"
BUILDDIR="$QGISGITDIR/build"
APPTARGET="$NIGHTLYDIR/QGIS.app"
NIGHTLYARCHIVES="$NIGHTLYDIR/archives"
# config build options
BUILDTYPE="MinSizeRel"
if [ $QGISDEBUG -gt 0 ]; then
BUILDTYPE="RelWithDebInfo"
fi
# git setup
GIT=/usr/local/git/bin/git
GITURL="git://github.com/qgis/Quantum-GIS.git"
###############################################################################
## Start Nightly Build
###############################################################################
echo -e "QGIS Nightly Build @ `date`"
###############################################################################
## Update QGIS Working Tree
###############################################################################
cd "$NIGHTLYDIR"
if [ $GITPULL -gt 0 ]; then
# check for existing repo dir
if [ ! -d "$QGISGITDIR" ]; then
echo -e "\nRepository missing, cloning 'master' branch...\n"
mkdir "$QGISGITDIR" && cd "$QGISGITDIR"
$GIT init
$GIT remote add -f -t master -m master origin "$GITURL"
$GIT merge origin
if [ $? -gt 0 ]; then
echo -e "\nERROR in cloning git repo 'master' branch!"
rm -R "$QGISGITDIR"
exit 1
fi
else
cd "$QGISGITDIR"
if [ $GITSTASH -gt 0 ]; then
echo -e "\nClearing any existing stash...\n"
$GIT stash clear
echo -e "\nStashing any unstaged changes...\n"
$GIT stash
fi
# update master branch
echo -e "\nRepository exists, pulling 'master' branch ...\n"
# this assumes no other branches have been created beyond master
$GIT pull
if [ $? -gt 0 ]; then
echo -e "\nERROR pulling git repo 'master' branch!"
exit 1
fi
if [ $GITSTASH -gt 0 ]; then
echo -e "\nApplying any existing stash...\n"
$GIT stash apply
fi
# if [ $? -gt 0 ]; then
# echo -e "\nERROR in applying stash!"
# exit 1
# fi
fi
chown -R $SUDO_USER "$QGISGITDIR"
fi
###############################################################################
## Build QGIS.app
###############################################################################
if [ $BUILDQGIS -gt 0 ]; then
# remove any previous build dir
if [ -d "$BUILDDIR" ]; then
echo -e "\nRemoving existing build directory ...\n"
rm -R "$BUILDDIR"
fi
# QGIS CMake setup supports out-of-source dir builds
# make build directory and configure
mkdir "$BUILDDIR" && cd "$BUILDDIR"
echo -e "\nConfiguring nightly build ...\n"
cmake -D CMAKE_INSTALL_PREFIX="$NIGHTLYDIR" \
-D CMAKE_BUILD_TYPE="$BUILDTYPE" \
-D ENABLE_TESTS="$QGISTESTS" \
-D WITH_INTERNAL_SPATIALITE=FALSE \
-D WITH_PYSPATIALITE=FALSE \
-D QWT_LIBRARY=/usr/local/qwt-5.2.2/lib/libqwt.dylib \
-D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.2/include \
-D BISON_EXECUTABLE=/usr/local/bin/bison \
-D WITH_APIDOC="$QGISAPIDOCS" \
-D QGIS_MACAPP_BUNDLE=2 \
..
if [ $? -gt 0 ]; then
echo -e "\nERROR configuring nightly QGIS build!"
exit 1
fi
#Build and install target QGIS.app
echo -e "\nMaking nightly build ...\n"
make -j $CPUCORES
if [ $? -gt 0 ]; then
echo -e "\nERROR building QGIS!"
exit 1
fi
chown -R $SUDO_USER "$BUILDDIR"
# remove last app built if current repo built
if [ -d "$APPTARGET" ]; then
echo -e "\nRemoving previously built app ...\n"
rm -R "$APPTARGET"
fi
echo -e "\nInstalling nightly build ...\n"
make install
if [ $? -gt 0 ]; then
echo -e "\nERROR installing QGIS!"
exit 1
fi
fi
###############################################################################
## Add QScintilla Python modules to QGIS.app
###############################################################################
if [ $ADDQSCI -gt 0 ]; then
echo -e "\nAdding Qsci.so module to nightly build..."
# cd $QSCIPATH
# QSCIPATH="$QGISDIR/Qsci_Lion/4.8.0"
# /bin/cp -a Qsci.so "$APPTARGET/Contents/Resources/python/PyQt4/";
# /bin/cp -a libqscintilla2.* "$APPTARGET/Contents/MacOS/lib/";
# /usr/bin/install_name_tool -add_rpath @executable_path/lib/libqscintilla2.8.dylib "$APPTARGET/Contents/MacOS/QGIS"
QSCI=''
if [ -e /Library/Python/2.7/site-packages/PyQt4/Qsci.so ]; then
QSCI=/Library/Python/2.7/site-packages/PyQt4/Qsci.so
elif [ -e /Library/Python/2.6/site-packages/PyQt4/Qsci.so ]; then
QSCI=/Library/Python/2.6/site-packages/PyQt4/Qsci.so
fi
if [ -n $QSCI ]; then
cd "$APPTARGET/Contents/Resources/python/PyQt4"
cp -a $QSCI .
install_name_tool -change /Library/Frameworks/libqscintilla2.8.dylib \
@loader_path/../../../MacOS/lib/libqscintilla2.8.dylib Qsci.so
install_name_tool -change QtCore.framework/Versions/4/QtCore \
@loader_path/../../../MacOS/../Frameworks/QtCore.framework/QtCore Qsci.so
install_name_tool -change QtGui.framework/Versions/4/QtGui \
@loader_path/../../../MacOS/../Frameworks/QtGui.framework/QtGui Qsci.so
cd "$APPTARGET/Contents/MacOS/lib"
cp -a /Library/Frameworks/libqscintilla*.dylib .
install_name_tool -change QtCore.framework/Versions/4/QtCore \
@loader_path/../../Frameworks/QtCore.framework/QtCore libqscintilla2.8.dylib
install_name_tool -change QtGui.framework/Versions/4/QtGui \
@loader_path/../../Frameworks/QtGui.framework/QtGui libqscintilla2.8.dylib
install_name_tool -add_rpath @executable_path/lib/libqscintilla2.8.dylib \
"$APPTARGET/Contents/MacOS/QGIS"
else
echo -e "\nQsci.so module not found..."
fi
fi
# set permissions on app
chown -R $SUDO_USER "$APPTARGET"
###############################################################################
## Archive QGIS.app to DMG Archives
###############################################################################
if [ $ARCHIVEAPP -gt 0 ]; then
sleep 5
# make sure dir structure exists
if [ ! -d "$NIGHTLYARCHIVES" ]; then
mkdir -p "$NIGHTLYARCHIVES"
fi
# congifure archive file
cd "$QGISGITDIR"
REVHASH=`$GIT log --no-color --pretty=format:%H origin/master^..origin/master`
REVSHORTHASH=`echo ${REVHASH:0:7}`
REVMAJOR=`grep 'SET(CPACK_PACKAGE_VERSION_MAJOR' CMakeLists.txt | egrep -o '[0-9]+'`
REVMINOR=`grep 'SET(CPACK_PACKAGE_VERSION_MINOR' CMakeLists.txt | egrep -o '[0-9]+'`
REVPATCH=`grep 'SET(CPACK_PACKAGE_VERSION_PATCH' CMakeLists.txt | egrep -o '[0-9]+'`
VERNUM="${REVMAJOR}-${REVMINOR}-${REVPATCH}"
TODAY=`date -u +"%Y-%m-%d"`
APPNAME="qgis-nightly_${VERNUM}_${TODAY}_${REVSHORTHASH}"
APPARCHIVE="$APPNAME.dmg"
OLDARCHIVE="$APPNAME_old.dmg"
# archive built app to compressed dmg
echo -e "\nArchiving nightly build ...\n"
cd "$NIGHTLYDIR"
# keep at least 1 archive with same hash, in case build fails
if [ -e "$NIGHTLYARCHIVES/$APPARCHIVE" ]; then
if [ -e "$NIGHTLYARCHIVES/$OLDARCHIVE" ]; then
rm "$NIGHTLYARCHIVES/$OLDARCHIVE"
fi
mv "$NIGHTLYARCHIVES/$APPARCHIVE" "$NIGHTLYARCHIVES/$OLDARCHIVE"
fi
# create dmg archive
hdiutil create -nospotlight -skipunreadable -noanyowners \
-copyuid $SUDO_USER -srcfolder "$APPTARGET" "$NIGHTLYARCHIVES/$APPARCHIVE"
if [ $? -gt 0 ]; then
echo -e "\nERROR archiving QGIS to dmg!"
exit 1
fi
chown -R $SUDO_USER "$NIGHTLYARCHIVES"
# prune dmg archives
CURFILE=1
for f in $( ls -1t "$NIGHTLYARCHIVES" ); do
if [ $CURFILE -gt $KEEPARCHIVES ]; then
rm "$NIGHTLYARCHIVES/$f"
fi
let CURFILE=CURFILE+1
done
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.