Commit 289c677a087b81df8ec1077b7f1087cf0efa16a9
1 parent
d670462b
Add package generation script for Mac OS X
Showing
1 changed file
with
233 additions
and
0 deletions
dev/macosx-package.sh
0 → 100755
| 1 | +#!/bin/bash -f | ||
| 2 | +# ========================================================================== | ||
| 3 | +# ctools Mac OS X package creation | ||
| 4 | +# | ||
| 5 | +# Copyright (C) 2017 Sylvie Brau-Nogué | ||
| 6 | +# | ||
| 7 | +# This program is free software: you can redistribute it and/or modify | ||
| 8 | +# it under the terms of the GNU General Public License as published by | ||
| 9 | +# the Free Software Foundation, either version 3 of the License, or | ||
| 10 | +# (at your option) any later version. | ||
| 11 | +# | ||
| 12 | +# This program is distributed in the hope that it will be useful, | ||
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | +# GNU General Public License for more details. | ||
| 16 | +# | ||
| 17 | +# You should have received a copy of the GNU General Public License | ||
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | +# | ||
| 20 | +# ========================================================================== | ||
| 21 | + | ||
| 22 | +# ============================================= # | ||
| 23 | +# Get ctools/GammaLib version from command line # | ||
| 24 | +# ============================================= # | ||
| 25 | +if [ $# -ne 1 ] ; then | ||
| 26 | + echo "Please specify ctools/GammaLib version in the form x.y.z" | ||
| 27 | + exit 1 | ||
| 28 | +fi | ||
| 29 | +VERSION=$1 | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +# =============================== # | ||
| 33 | +# Set software component versions # | ||
| 34 | +# =============================== # | ||
| 35 | +CFITSIO=cfitsio3410 | ||
| 36 | +NCURSES=ncurses-6.0 | ||
| 37 | +READLINE=readline-7.0 | ||
| 38 | +GAMMALIB=gammalib-$VERSION | ||
| 39 | +CTOOLS=ctools-$VERSION | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +# ============== # | ||
| 43 | +# Set parameters # | ||
| 44 | +# ============== # | ||
| 45 | +WRKDIR=$PWD/osxpackage | ||
| 46 | +INSTALLDIR=$WRKDIR/install | ||
| 47 | +SRCDIR=$WRKDIR/src | ||
| 48 | +PKGDIR=$WRKDIR/pkg | ||
| 49 | +PRODDIR=$WRKDIR/prod | ||
| 50 | +PLISTFILE=$PKGDIR/$CTOOLS-components.plist | ||
| 51 | +DISTFILE=$PRODDIR/$CTOOLS.dist | ||
| 52 | +DMGFILE=$WRKDIR/$CTOOLS-macosx10.7.dmg | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +# ====================== # | ||
| 56 | +# Clean package creation # | ||
| 57 | +# ====================== # | ||
| 58 | +rm -rf $INSTALLDIR | ||
| 59 | +rm -rf $PKGDIR | ||
| 60 | +rm -rf $PRODDIR | ||
| 61 | +rm -rf $DMGFILE | ||
| 62 | + | ||
| 63 | + | ||
| 64 | +# ============================= # | ||
| 65 | +# Create package directory tree # | ||
| 66 | +# ============================= # | ||
| 67 | +mkdir -p $SRCDIR | ||
| 68 | +mkdir -p $PKGDIR | ||
| 69 | +mkdir -p $PRODDIR | ||
| 70 | + | ||
| 71 | + | ||
| 72 | +# Make sure that wget is installed | ||
| 73 | +# TODO: If not installed, execute "brew install wget" | ||
| 74 | + | ||
| 75 | + | ||
| 76 | +# =============== # | ||
| 77 | +# Install ncurses # | ||
| 78 | +# =============== # | ||
| 79 | +cd $SRCDIR | ||
| 80 | +if [ ! -d "$NCURSES" ]; then | ||
| 81 | + wget https://ftp.gnu.org/pub/gnu/ncurses/$NCURSES.tar.gz | ||
| 82 | + tar xvfz $NCURSES.tar.gz | ||
| 83 | +fi | ||
| 84 | +cd $NCURSES | ||
| 85 | +./configure --prefix=$INSTALLDIR --with-shared | ||
| 86 | +make | ||
| 87 | +make install | ||
| 88 | + | ||
| 89 | + | ||
| 90 | +# ================ # | ||
| 91 | +# Install readline # | ||
| 92 | +# ================ # | ||
| 93 | +cd $SRCDIR | ||
| 94 | +if [ ! -d "$READLINE" ]; then | ||
| 95 | + wget https://ftp.gnu.org/pub/gnu/readline/$READLINE.tar.gz | ||
| 96 | + tar xvfz $READLINE.tar.gz | ||
| 97 | +fi | ||
| 98 | +cd $READLINE | ||
| 99 | +./configure --prefix=$INSTALLDIR | ||
| 100 | +make | ||
| 101 | +make install | ||
| 102 | + | ||
| 103 | + | ||
| 104 | +# =============== # | ||
| 105 | +# Install cfitsio # | ||
| 106 | +# =============== # | ||
| 107 | +cd $SRCDIR | ||
| 108 | +if [ ! -d "cfitsio" ]; then | ||
| 109 | + wget http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/$CFITSIO.tar.gz | ||
| 110 | + tar xvfz $CFITSIO.tar.gz | ||
| 111 | +fi | ||
| 112 | +cd cfitsio | ||
| 113 | +./configure --prefix=$INSTALLDIR | ||
| 114 | +make shared | ||
| 115 | +make install | ||
| 116 | + | ||
| 117 | + | ||
| 118 | +# ================ # | ||
| 119 | +# Install GammaLib # | ||
| 120 | +# ================ # | ||
| 121 | +cd $SRCDIR | ||
| 122 | +if [ ! -d "$GAMMALIB" ]; then | ||
| 123 | + wget http://cta.irap.omp.eu/ctools/releases/gammalib/$GAMMALIB.tar.gz | ||
| 124 | + tar xvfz $GAMMALIB.tar.gz | ||
| 125 | +fi | ||
| 126 | +cd $GAMMALIB | ||
| 127 | +./configure --prefix=$INSTALLDIR | ||
| 128 | +make | ||
| 129 | +make install | ||
| 130 | + | ||
| 131 | + | ||
| 132 | +# ============== # | ||
| 133 | +# Install ctools # | ||
| 134 | +# ============== # | ||
| 135 | +cd $SRCDIR | ||
| 136 | +if [ ! -d "$CTOOLS" ]; then | ||
| 137 | + wget http://cta.irap.omp.eu/ctools/releases/ctools/$CTOOLS.tar.gz | ||
| 138 | + tar xvfz $CTOOLS.tar.gz | ||
| 139 | +fi | ||
| 140 | +cd $CTOOLS | ||
| 141 | +./configure --prefix=$INSTALLDIR | ||
| 142 | +make | ||
| 143 | +make install | ||
| 144 | + | ||
| 145 | + | ||
| 146 | +# ====================== # | ||
| 147 | +# Build Mac OS X package # | ||
| 148 | +# ====================== # | ||
| 149 | +pkgbuild --analyze --root $INSTALLDIR $PLISTFILE | ||
| 150 | +pkgbuild --identifier cta.irap.omp.eu.ctools.pkg \ | ||
| 151 | + --version $VERSION \ | ||
| 152 | + --root $INSTALLDIR \ | ||
| 153 | + --install-location /usr/local/gamma \ | ||
| 154 | + --component-plist $PLISTFILE \ | ||
| 155 | + $PKGDIR/$CTOOLS.pkg | ||
| 156 | + | ||
| 157 | + | ||
| 158 | +# ====================== # | ||
| 159 | +# Build Mac OS X product # | ||
| 160 | +# ====================== # | ||
| 161 | +# Analyse existing package | ||
| 162 | +productbuild --synthesize \ | ||
| 163 | + --package $PKGDIR/$CTOOLS.pkg \ | ||
| 164 | + $DISTFILE | ||
| 165 | + | ||
| 166 | +# Add information to dist file | ||
| 167 | +sed -i '' '$ i \ | ||
| 168 | +<license file="COPYING"/>\ | ||
| 169 | +<title>'$CTOOLS'</title>\ | ||
| 170 | +<organization>irap.omp.eu</organization>\ | ||
| 171 | +<description>CTA Science Analysis Tools</description>\ | ||
| 172 | +' "$PRODDIR/$CTOOLS.dist" | ||
| 173 | + | ||
| 174 | +# Build product | ||
| 175 | +productbuild --distribution $DISTFILE \ | ||
| 176 | + --version $VERSION \ | ||
| 177 | + --resources $SRCDIR/$CTOOLS \ | ||
| 178 | + --package-path $WRKDIR \ | ||
| 179 | + $PRODDIR/$CTOOLS.pkg | ||
| 180 | + | ||
| 181 | +# Add additional files to production folder | ||
| 182 | +cp $SRCDIR/$CTOOLS/COPYING $PRODDIR/License.txt | ||
| 183 | + | ||
| 184 | +# Add ReadMe | ||
| 185 | +/bin/cat <<EOM >$PRODDIR/ReadMe.txt | ||
| 186 | +This package will install | ||
| 187 | + | ||
| 188 | + ctools-$VERSION and gammalib-$VERSION | ||
| 189 | + | ||
| 190 | +for Mac OS X 10.7 or later. | ||
| 191 | + | ||
| 192 | +Installation requires approximately 260 MB of disk space. The package | ||
| 193 | +will be installed in the directory /usr/local/gamma, hence you need | ||
| 194 | +administrator privileges to do the install. | ||
| 195 | + | ||
| 196 | +Simply click on the installer package and follow the instructions. | ||
| 197 | +The installation will take less than one minute. | ||
| 198 | + | ||
| 199 | +After installing the package, you have to initialise the ctools | ||
| 200 | +environment. This will be done by invoking an initialisation script | ||
| 201 | +that can be found in the /usr/local/gamma/bin directory. | ||
| 202 | + | ||
| 203 | +To invoke this script you need to add the following to your .bashrc | ||
| 204 | +or $HOME/.profile script: | ||
| 205 | + | ||
| 206 | + export CTOOLS=/usr/local/gamma | ||
| 207 | + source \$CTOOLS/bin/gammalib-init.sh | ||
| 208 | + | ||
| 209 | +If you use C shell or a variant then add the following to your | ||
| 210 | +.cshrc or .tcshrc script: | ||
| 211 | + | ||
| 212 | + setenv CTOOLS /usr/local/gamma | ||
| 213 | + source \$CTOOLS/bin/gammalib-init.csh | ||
| 214 | + | ||
| 215 | +More information on ctools can be found at | ||
| 216 | +http://cta.irap.omp.eu/ctools/. | ||
| 217 | + | ||
| 218 | +If you encounter problems in installing or using this package, please | ||
| 219 | +send your error report to jurgen.knodlseder@irap.omp.eu. In your report, | ||
| 220 | +please specify your Mac OS X version and Python version and the problem | ||
| 221 | +you're facing. | ||
| 222 | +EOM | ||
| 223 | + | ||
| 224 | + | ||
| 225 | + | ||
| 226 | +# ==================== # | ||
| 227 | +# Create Mac OS X disk # | ||
| 228 | +# ==================== # | ||
| 229 | +hdiutil create -volname $CTOOLS \ | ||
| 230 | + -srcfolder $PRODDIR/$CTOOLS.pkg \ | ||
| 231 | + -srcfolder $PRODDIR/License.txt \ | ||
| 232 | + -srcfolder $PRODDIR/ReadMe.txt \ | ||
| 233 | + $DMGFILE |