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