Commit 6083490f25611aa4b5ca1bf53cf13897072be39c

Authored by Sylvie Brau-Nogué
1 parent dfaeddad

Major add-ons, mainly for Packaging

* Add platform parameter for rpmbuild
* Sign rpm with a GPG signature
* fine tuning of some configuration files
Makefile.am
... ... @@ -98,7 +98,8 @@ pkg:
98 98 case `lsb_release -irs` in \
99 99 CentOS*) \
100 100 echo "CentOS supported"; \
101   - dev/pkgbuild-centos.sh $(PACKAGE_NAME) $(PACKAGE_VERSION); \
  101 + dev/pkgbuild-centos.sh $(PACKAGE_NAME) $(PACKAGE_VERSION) x86_64 NA ; \
  102 + dev/pkgbuild-centos.sh $(PACKAGE_NAME) $(PACKAGE_VERSION) i386 NA ; \
102 103 ;; \
103 104 *) \
104 105 echo "Linux OS not supported"; \
... ...
dev/pkgbuild-centos.sh
... ... @@ -30,13 +30,18 @@
30 30 # ============================================= #
31 31 # Get ctools/GammaLib version from command line #
32 32 # ============================================= #
33   -if [ $# -ne 2 ] ; then
34   -echo "Please specify package name and version in the form 'package x.y.z'"
  33 +if [ $# -ne 4 ] ; then
  34 +echo "Please specify package name version package and Gammalib version in the form 'package x.y.z platform gammalib-version'"
35 35 exit 1
36 36 fi
37 37 PACKNAME=$1
38 38 VERSION=$2
  39 +PLATFORM=$3
  40 +GVERSION=$4
39 41  
  42 +echo " ================================================================= "
  43 +echo " Build $PACKNAME rpm package, Version $VERSION, Platform $PLATFORM "
  44 +echo " ================================================================= "
40 45  
41 46 # =============================== #
42 47 # Set software component versions #
... ... @@ -65,20 +70,32 @@ RELEASE=1
65 70 #
66 71 #
67 72 # SBN : Liste à fixer.
  73 +TMPDIR=$HOME/usr
68 74 WRKDIR=$HOME/rpmbuild
69 75 SRCDIR=$WRKDIR/SOURCES
70 76 PKGDIR=$WRKDIR/RPMS
71   -PRODDIR=$WRKDIR/RPMS/noarch
72   -RPMFILE=$PRODDIR/$PACKAGE-$RELEASE.noarch.rpm
  77 +PRODDIR=$WRKDIR/RPMS/$PLATFORM
  78 +RPMFILE=$PRODDIR/$PACKAGE-$RELEASE-*$PLATFORM.rpm
73 79 #
74 80 LOGFILE=$HOME/pkg_build/pkg_build.log
75 81 LOGDEPILE=$HOME/pkg_build/pkg_dependencies_rpm.log
76 82  
  83 +# ==================================================== #
  84 +# TODO : Create a secure RPM repository
  85 +# ==================================================== #
  86 +# Temporary solution, to be fixed
  87 +YUMREPO=$HOME/YUM-REPO
  88 +
77 89 # ======================= #
78 90 # Clean package directory #
79 91 # ======================= #
80 92 rm -rf $WRKDIR
81 93  
  94 +# ========================= #
  95 +# Clean temporary directory #
  96 +# ========================= #
  97 +rm -rf $TMPDIR
  98 +
82 99 # ============================= #
83 100 # Create package directory tree #
84 101 # ============================= #
... ... @@ -91,16 +108,17 @@ mkdir -p $HOME/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
91 108 # rpm -qa | grep ncurses || sudo yum install ncurses
92 109  
93 110 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
  111 + echo "ncurses need to be installed"
  112 + sudo yum install ncurses
  113 + if ! rpm -qa | grep -q ncurses; then
  114 + echo "================================================================================================="
  115 + echo "ERROR : ncurses need to be installed manually"
  116 + echo " "
  117 + echo "================================================================================================="
  118 + exit
  119 + fi
103 120 fi
  121 +# Check ncurses version
104 122 v=$(rpm --qf '%{VERSION}\n' -q ncurses)
105 123 echo "ncurses $v checked"
106 124  
... ... @@ -111,16 +129,17 @@ echo "ncurses $v checked"
111 129 # rpm -qa | grep readline || sudo yum install readline
112 130  
113 131 if ! rpm -qa | grep -q readline; then
114   - echo "readline need to be installed"
115   - sudo yum install readline
116   - if ! rpm -qa | grep -q readline; then
117   - echo "================================================================================================="
118   - echo "ERROR : readline need to be installed manually"
119   - echo " "
120   - echo "================================================================================================="
121   - exit
122   - fi
  132 + echo "readline need to be installed"
  133 + sudo yum install readline
  134 + if ! rpm -qa | grep -q readline; then
  135 + echo "================================================================================================="
  136 + echo "ERROR : readline need to be installed manually"
  137 + echo " "
  138 + echo "================================================================================================="
  139 + exit
  140 + fi
123 141 fi
  142 +# Check readline version
124 143 v=$(rpm --qf '%{VERSION}\n' -q readline)
125 144 echo "readline $v checked"
126 145  
... ... @@ -131,48 +150,32 @@ echo "readline $v checked"
131 150 # rpm -qa | grep cfitsio || sudo yum install cfitsio
132 151  
133 152 if ! rpm -qa | grep -q cfitsio; then
134   - echo "cfitsio need to be installed"
135   - sudo yum install cfitsio-devel
136   - if ! rpm -qa | grep -q cfitsio; then
137   - echo "================================================================================================="
138   - echo " ERROR : cfitsio need to be installed"
139   - echo "================================================================================================="
140   - echo "You can download the latest version of CFITSIO on http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html"
141   - echo " "
142   - echo "or "
143   - echo " "
144   - echo "cfitsio rpm can be found in the epel-release repository ; Try : sudo yum install cfitsio-devel"
145   - echo " "
146   - echo "================================================================================================="
147   - exit
148   - fi
  153 + echo "cfitsio need to be installed"
  154 + sudo yum install cfitsio-devel
  155 + if ! rpm -qa | grep -q cfitsio; then
  156 + echo "================================================================================================="
  157 + echo " ERROR : cfitsio need to be installed"
  158 + echo "================================================================================================="
  159 + echo "You can download the latest version of CFITSIO on http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html"
  160 + echo " "
  161 + echo "or "
  162 + echo " "
  163 + echo "cfitsio rpm can be found in the epel-release repository ; Try : sudo yum install cfitsio-devel"
  164 + echo " "
  165 + echo "================================================================================================="
  166 + exit
  167 + fi
149 168 fi
  169 +# Check cfitsio version
150 170 v=$(rpm --qf '%{VERSION}\n' -q cfitsio)
151 171 echo "cfitsio $v checked"
152 172  
153   -
154 173 # ======================================== #
155 174 # Copy package configuration file (*.spec) #
156 175 # ======================================== #
157 176 cp $PACKNAME.spec $WRKDIR/SPECS/
158 177  
159 178 # ================================================================== #
160   -# Check if Gammalib installed and version
161   -# No need to install Gammalib since this script follows a 'make dist'#
162   -# ================================================================== #
163   -#
164   -v=$(rpm --qf '%{VERSION}\n' -q gammalib)
165   -
166   -if ! rpm -qa | grep -q gammalib; then
167   - echo "================================================================================================="
168   - echo "$v"
169   - echo "================================================================================================="
170   -else
171   -v=$(rpm --qf '%{VERSION}\n' -q gammalib)
172   - echo "gammalib $v already installed"
173   -fi
174   -
175   -# ================================================================== #
176 179 # Just copy dist in SOURCES dir #
177 180 # ================================================================== #
178 181 cp $PACKAGE.tar.gz $SRCDIR/
... ... @@ -187,14 +190,38 @@ cp $PACKAGE.tar.gz $SRCDIR/
187 190 # Build centOS package #
188 191 # ====================== #
189 192  
190   -rpmbuild -ba $WRKDIR/SPECS/$PACKNAME.spec -v
  193 +rpmbuild --target $PLATFORM -ba $WRKDIR/SPECS/$PACKNAME.spec -v
  194 +
  195 +# ==================================================== #
  196 +# Sign package with an environment variable is set by the pass phrase during login
  197 +# for example in .bashrc file
  198 +# > GPG_PASSPHRASE="tombelaneige"
  199 +# > export GPG_PASSPHRASE
  200 +# Another possibility to create a specific file in .gnupg directory
  201 +# > at login script, extract pass phrase from this file
  202 +# ==================================================== #
  203 +(\
  204 + echo set timeout -1;\
  205 + echo spawn rpmsign --addsign $PKGDIR/*/*.rpm;\
  206 + echo expect -re \"pass\";\
  207 + echo send -- \"$GPG_PASSPHRASE\\r\";\
  208 + echo expect eof;\
  209 +) | expect
  210 +
191 211  
192 212 echo " ===================================================="
193 213 echo " Packaging DONE :"
194 214 echo " New package is located at $PRODDIR"
195   -echo " rpm file : $PACKAGE-$RELEASE.noarch.rpm"
196   -echo " ===================================================="
197   -echo " "
198   -rpm -qip $RPMFILE
199   -
  215 +for package in $(find $PRODDIR -iname *.rpm ); do
  216 + echo " rpm file : $package"
  217 + echo " ===================================================="
  218 + echo " "
  219 + rpm -qip $package;
  220 +
  221 + # ==================================================== #
  222 + # TODO : Move package in a secure RPM repository
  223 + # ==================================================== #
  224 + # Temporary solution, to be fixed
  225 + cp $package $YUMREPO
  226 +done
200 227 exit
... ...
gammalib.spec.in
... ... @@ -4,8 +4,7 @@
4 4 #%define _binaries_in_noarch_packages_terminate_build 0
5 5 %define PKGNAME @PACKAGE_NAME@
6 6 %define VERSION @PACKAGE_VERSION@
7   -# TODO fix %define RELEASE 1
8   -%define RELEASE 1
  7 +%define RELEASE 1%{?dist}
9 8  
10 9 Name: %{PKGNAME}
11 10 Summary: Versatile toolbox for scientific analysis of astronomical gamma-ray data
... ... @@ -33,7 +32,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
33 32 # Requires: liste des packages requis pour l'installation
34 33 Requires: ncurses
35 34 Requires: readline
36   -#Requires: gcc-c++
37 35 Requires: cfitsio
38 36 #
39 37 Prefix: /usr/local/gamma
... ...