1
|
#!/bin/bash
|
2
|
# ==========================================================================
|
3
|
# ctools CentOS 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
|
# This script installs the ctools and GammaLib packages in the location
|
23
|
# /usr/local/gamma and then builds a CentOS rpm package.
|
24
|
# Any existing content in /usr/local/gamma will be
|
25
|
# destroyed. The script needs the priviledges to create a folder in
|
26
|
# /usr/local.
|
27
|
#
|
28
|
# ==========================================================================
|
29
|
|
30
|
# ============================================= #
|
31
|
# Get ctools/GammaLib version from command line #
|
32
|
# ============================================= #
|
33
|
if [ $# -ne 2 ] ; then
|
34
|
echo "Please specify package name and version in the form 'package x.y.z'"
|
35
|
exit 1
|
36
|
fi
|
37
|
PACKNAME=$1
|
38
|
VERSION=$2
|
39
|
|
40
|
|
41
|
# =============================== #
|
42
|
# Set software component versions #
|
43
|
# =============================== #
|
44
|
#CFITSIO=cfitsio3410
|
45
|
#NCURSES=ncurses-5.9
|
46
|
#READLINE=readline-6.3
|
47
|
CFITSIO=cfitsio
|
48
|
NCURSES=ncurses
|
49
|
READLINE=readline
|
50
|
#
|
51
|
PACKAGE=$PACKNAME-$VERSION
|
52
|
RELEASE=1
|
53
|
|
54
|
# ============== #
|
55
|
# Set parameters #
|
56
|
# ============== #
|
57
|
#
|
58
|
# System Configuration Hypothesis with file ~/.rpmmacros.
|
59
|
# This file must contain at least the follwing lines :
|
60
|
# %packager KNODLSEDER
|
61
|
# %_topdir %(echo $HOME)/rpmbuild
|
62
|
# %_tmppath %(echo $HOME)/rpmbuild/tmp
|
63
|
# %_smp_mflags -j3
|
64
|
# %__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
|
65
|
#
|
66
|
#
|
67
|
# SBN : Liste à fixer.
|
68
|
WRKDIR=$HOME/rpmbuild
|
69
|
SRCDIR=$WRKDIR/SOURCES
|
70
|
PKGDIR=$WRKDIR/RPMS
|
71
|
PRODDIR=$WRKDIR/RPMS/noarch
|
72
|
RPMFILE=$PRODDIR/$PACKAGE-$RELEASE.noarch.rpm
|
73
|
#
|
74
|
LOGFILE=$HOME/pkg_build/pkg_build.log
|
75
|
LOGDEPILE=$HOME/pkg_build/pkg_dependencies_rpm.log
|
76
|
|
77
|
# ======================= #
|
78
|
# Clean package directory #
|
79
|
# ======================= #
|
80
|
rm -rf $WRKDIR
|
81
|
|
82
|
# ============================= #
|
83
|
# Create package directory tree #
|
84
|
# ============================= #
|
85
|
mkdir -p $HOME/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
|
86
|
|
87
|
# =============== #
|
88
|
# Install ncurses #
|
89
|
# =============== #
|
90
|
# TODO : eventuellement fixer le numero de version du paquet
|
91
|
# rpm -qa | grep ncurses || sudo yum install ncurses
|
92
|
|
93
|
if ! rpm -qa | grep -q ncurses; then
|
94
|
echo "ncurses need to be installed"
|
95
|
sudo yum install ncurses
|
96
|
if ! rpm -qa | grep -q ncurses; then
|
97
|
echo "================================================================================================="
|
98
|
echo "ERROR : ncurses need to be installed manually"
|
99
|
echo " "
|
100
|
echo "================================================================================================="
|
101
|
exit
|
102
|
fi
|
103
|
fi
|
104
|
# Check ncurses version
|
105
|
v=$(rpm --qf '%{VERSION}\n' -q ncurses)
|
106
|
echo "ncurses $v checked"
|
107
|
|
108
|
# ================ #
|
109
|
# Install readline #
|
110
|
# ================ #
|
111
|
# TODO : eventuellement fixer le numero de version du paquet
|
112
|
# rpm -qa | grep readline || sudo yum install readline
|
113
|
|
114
|
if ! rpm -qa | grep -q readline; then
|
115
|
echo "readline need to be installed"
|
116
|
sudo yum install readline
|
117
|
if ! rpm -qa | grep -q readline; then
|
118
|
echo "================================================================================================="
|
119
|
echo "ERROR : readline need to be installed manually"
|
120
|
echo " "
|
121
|
echo "================================================================================================="
|
122
|
exit
|
123
|
fi
|
124
|
fi
|
125
|
# Check readline version
|
126
|
v=$(rpm --qf '%{VERSION}\n' -q readline)
|
127
|
echo "readline $v checked"
|
128
|
|
129
|
# =============== #
|
130
|
# Install cfitsio #
|
131
|
# =============== #
|
132
|
# TODO : eventuellement fixer le numero de version du paquet
|
133
|
# rpm -qa | grep cfitsio || sudo yum install cfitsio
|
134
|
|
135
|
if ! rpm -qa | grep -q cfitsio; then
|
136
|
echo "cfitsio need to be installed"
|
137
|
sudo yum install cfitsio-devel
|
138
|
if ! rpm -qa | grep -q cfitsio; then
|
139
|
echo "================================================================================================="
|
140
|
echo " ERROR : cfitsio need to be installed"
|
141
|
echo "================================================================================================="
|
142
|
echo "You can download the latest version of CFITSIO on http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html"
|
143
|
echo " "
|
144
|
echo "or "
|
145
|
echo " "
|
146
|
echo "cfitsio rpm can be found in the epel-release repository ; Try : sudo yum install cfitsio-devel"
|
147
|
echo " "
|
148
|
echo "================================================================================================="
|
149
|
exit
|
150
|
fi
|
151
|
fi
|
152
|
# Check cfitsio version
|
153
|
v=$(rpm --qf '%{VERSION}\n' -q cfitsio)
|
154
|
echo "cfitsio $v checked"
|
155
|
|
156
|
# ======================================== #
|
157
|
# Copy package configuration file (*.spec) #
|
158
|
# ======================================== #
|
159
|
cp $PACKNAME.spec $WRKDIR/SPECS/
|
160
|
|
161
|
# ================================================================== #
|
162
|
# Install GammaLib #
|
163
|
# No need to install Gammalib since this script follows a 'make dist'#
|
164
|
# But you can check ... #
|
165
|
# ================================================================== #
|
166
|
# Check gammalib version
|
167
|
v=$(rpm --qf '%{VERSION}\n' -q gammalib)
|
168
|
if ! rpm -qa | grep -q gammalib; then
|
169
|
echo "================================================================================================="
|
170
|
echo "ERROR : $v"
|
171
|
echo "Trying to install gammalib"
|
172
|
echo "================================================================================================="
|
173
|
sudo yum install gammalib
|
174
|
if ! rpm -qa | grep -q gammalib; then
|
175
|
echo "================================================================================================="
|
176
|
echo "ERROR : gammalib need to be installed manually"
|
177
|
echo " "
|
178
|
echo "================================================================================================="
|
179
|
exit
|
180
|
fi
|
181
|
fi
|
182
|
v=$(rpm --qf '%{VERSION}\n' -q gammalib)
|
183
|
echo "gammalib $v checked"
|
184
|
|
185
|
# ================================================================== #
|
186
|
# Install ctools #
|
187
|
# No need to install ctools ; rpmbuild will package from 'scratch' #
|
188
|
# ================================================================== #
|
189
|
# Just copy dist in SOURCES dir #
|
190
|
# ================================================================== #
|
191
|
cp $PACKAGE.tar.gz $SRCDIR/
|
192
|
|
193
|
|
194
|
# ================= #
|
195
|
# Post-process code #
|
196
|
# ================= #
|
197
|
|
198
|
|
199
|
# ====================== #
|
200
|
# Build centOS package #
|
201
|
# ====================== #
|
202
|
|
203
|
rpmbuild -ba $WRKDIR/SPECS/$PACKNAME.spec -v
|
204
|
|
205
|
echo " ===================================================="
|
206
|
echo " Packaging DONE :"
|
207
|
echo " New package is located at $PRODDIR"
|
208
|
echo " rpm file : $PACKAGE-$RELEASE.noarch.rpm"
|
209
|
echo " ===================================================="
|
210
|
echo " "
|
211
|
rpm -qip $RPMFILE
|
212
|
|
213
|
exit
|