22
22
set -e
23
23
24
24
PKG_ROOT=` pwd` # The script must be executed from the root git directory
25
- repos =" FogLAMP" # Name of the Git repository
25
+ repo_name =" FogLAMP" # Name of the Git repository
26
26
branch=" master" # Default Git branch to use
27
27
pkg_name=" foglamp" # Name of the package to build
28
28
architecture=" x86_64" # The architecture for which the rpm should be created
@@ -41,51 +41,49 @@ Arguments:
41
41
-b - Branch to base package on"
42
42
43
43
while getopts " :hcasb:" opt; do
44
- case " $opt " in
45
- h)
46
- echo " ${usage} "
47
- exit 0
48
- ;;
49
- c)
50
- echo -n " Cleaning the build folder from older versions..."
51
- find " ${PKG_ROOT} /packages/rpmbuild/BUILDROOT" -maxdepth 1 | grep ' .*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
52
- echo " Done."
53
- exit 0
54
- ;;
55
- a)
56
- if [ -d " ${PKG_ROOT} /packages/rpmbuild/BUILDROOT" ]; then
57
-
58
- echo -n " Cleaning the build folder..."
59
- sudo rm -rf ${PKG_ROOT} /packages/rpmbuild/BUILDROOT/*
60
- echo " Done."
61
- else
62
- echo " No build folder, skipping cleanall"
63
- fi
64
- exit 0
65
- ;;
66
- s)
67
- skip_build=1
68
- ;;
69
- b)
70
- branch=$OPTARG
71
- ;;
72
- \? )
73
- echo " Invalid option -$OPTARG "
74
- exit 1
75
- ;;
76
- :)
77
- echo " -$OPTARG requires an argument"
78
- exit 1
79
- esac
44
+ case " $opt " in
45
+ h)
46
+ echo " ${usage} "
47
+ exit 0
48
+ ;;
49
+ c)
50
+ if [ -d " ${GIT_ROOT} /packages/RPM/build" ]; then
51
+ echo -n " Cleaning the build folder from older versions..."
52
+ find " ${PKG_ROOT} /packages/RPM/build/BUILDROOT" -maxdepth 1 | grep ' .*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
53
+ find " ${PKG_ROOT} /packages/RPM/build/RPMS/${architecture} " -maxdepth 1 | grep ' .*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
54
+ echo " Done."
55
+ else
56
+ echo " No build folder, skipping clean old versions"
57
+ fi
58
+ exit 0
59
+ ;;
60
+ a)
61
+ if [ -d " ${PKG_ROOT} /packages/RPM/build" ]; then
62
+ echo -n " Cleaning the build folder..."
63
+ sudo rm -rf ${PKG_ROOT} /packages/RPM/build/*
64
+ echo " Done."
65
+ else
66
+ echo " No build folder, skipping cleanall"
67
+ fi
68
+ exit 0
69
+ ;;
70
+ s)
71
+ skip_build=1
72
+ ;;
73
+ b)
74
+ branch=$OPTARG
75
+ ;;
76
+ \? )
77
+ echo " Invalid option -$OPTARG "
78
+ exit 1
79
+ ;;
80
+ :)
81
+ echo " -$OPTARG requires an argument"
82
+ exit 1
83
+ esac
80
84
done
81
85
82
-
83
- # If the architecture has not been defined, then the script is complete
84
- if [[ " $architecture " == " none" ]]; then
85
- exit 0
86
- fi
87
-
88
- if [ ! -f packages/rpmbuild/SPECS/foglamp.spec ] ; then
86
+ if [ ! -f packages/RPM/SPECS/foglamp.spec ] ; then
89
87
echo You must run this script from the foglamp-pkg directory
90
88
exit 1
91
89
fi
94
92
# Extracts/updates Git repository
95
93
#
96
94
if [[ $skip_build == 0 ]]; then
97
-
98
95
cd /tmp
99
- if [ -d " $repos " ]; then
100
- echo WARNING: Repository $repos already exists, using the existing copy
101
- (cd $repos ; git fetch --all; git pull ; git checkout " $branch " )
96
+ if [ -d " ${repo_name} " ]; then
97
+ echo WARNING: Repository ${repo_name} already exists, using the existing copy
98
+ (cd ${repo_name} ; git fetch --all; git pull ; git checkout " $branch " )
102
99
else
103
- git clone -b " $branch " https://github.com/foglamp/${repos } .git
100
+ git clone -b " $branch " https://github.com/foglamp/${repo_name } .git
104
101
fi
105
102
106
- GIT_ROOT=/tmp/" $repos "
103
+ GIT_ROOT=/tmp/" ${repo_name} "
107
104
cd ${GIT_ROOT}
108
105
fi
109
106
110
107
#
111
108
# Builds FogLAMP
112
109
#
113
110
if [[ $skip_build == 0 ]]; then
114
-
115
111
# Backups FOGLAMP_ROOT
116
112
export FOGLAMP_ROOT_BCK=${FOGLAMP_ROOT}
117
-
118
113
export FOGLAMP_ROOT=${GIT_ROOT}
119
114
export FOGLAMP_DATA=${FOGLAMP_ROOT} /data
120
115
export PYTHONPATH=${FOGLAMP_ROOT} /python
@@ -135,19 +130,16 @@ if [[ $skip_build == 0 ]]; then
135
130
status_pg_isready=$?
136
131
137
132
if [[ $status_rh_postgresql96 != 0 ]]; then
138
-
139
133
echo " ERROR : it is not possible to enable the ${rhpg_pkg} environment"
140
134
exit 1
141
135
fi
142
136
143
137
if [[ $status_devtoolset != 0 ]]; then
144
-
145
138
echo " ERROR : it is not possible to enable the ${rhgcc_pkg} environment"
146
139
exit 1
147
140
fi
148
141
149
142
if [[ $status_pg_isready != 0 ]]; then
150
-
151
143
echo " ERROR : the command pg_isready is not available"
152
144
exit 1
153
145
fi
163
155
164
156
# Checks if the FOGLAMP_ROOT environment is defined
165
157
if [[ " ${FOGLAMP_ROOT} " == " " ]]; then
166
-
167
158
# Set FOGLAMP_ROOT as the default directory
168
- export FOGLAMP_ROOT=" /usr/local/foglamp"
159
+ export FOGLAMP_ROOT=" /usr/local/foglamp"
169
160
fi
170
161
171
162
if [[ ! -d " ${FOGLAMP_ROOT} " ]]; then
172
-
173
163
echo " No FOGLAMP_ROOT directory found in the path ${FOGLAMP_ROOT} - Program exit."
174
164
exit 1
175
165
fi
176
166
177
167
version=` cat ${FOGLAMP_ROOT} /VERSION | tr -d ' ' | grep ' foglamp_version=' | head -1 | sed -e ' s/\(.*\)=\(.*\)/\2/g' `
178
- BUILD_ROOT=" ${PKG_ROOT} /packages/rpmbuild /BUILDROOT"
168
+ BUILD_ROOT=" ${PKG_ROOT} /packages/RPM/build /BUILDROOT"
179
169
180
- mkdir -p ${PKG_ROOT} /packages/rpmbuild /{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
181
- mkdir -p ${PKG_ROOT} /packages/rpmbuild /RPMS/x86_64
170
+ mkdir -p ${PKG_ROOT} /packages/RPM/build /{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
171
+ mkdir -p ${PKG_ROOT} /packages/RPM/build /RPMS/x86_64
182
172
183
173
# Final package name
184
174
package_name=" ${pkg_name} -${version} -1.${architecture} "
@@ -187,7 +177,7 @@ package_name="${pkg_name}-${version}-1.${architecture}"
187
177
echo " The package root directory is : ${PKG_ROOT} "
188
178
echo " The FogLAMP directory is : ${FOGLAMP_ROOT} "
189
179
echo " The FogLAMP version is : ${version} "
190
- echo " The package will be built in : ${PKG_ROOT} /packages/rpmbuild /RPMS/${architecture} "
180
+ echo " The package will be built in : ${PKG_ROOT} /packages/RPM/build /RPMS/${architecture} "
191
181
echo " The package name is : ${package_name} "
192
182
echo
193
183
@@ -214,9 +204,9 @@ mkdir "${package_name}"
214
204
echo -n " Populating the package and updating version in control file..."
215
205
cd " ${package_name} "
216
206
217
- sed -i " s/__NAME__/${pkg_name} /g" ${PKG_ROOT} /packages/rpmbuild /SPECS/foglamp.spec
218
- sed -i " s/__VERSION__/${version} /g" ${PKG_ROOT} /packages/rpmbuild /SPECS/foglamp.spec
219
- sed -i " s/__ARCH__/${architecture} /g" ${PKG_ROOT} /packages/rpmbuild /SPECS/foglamp.spec
207
+ sed -i " s/__NAME__/${pkg_name} /g" ${PKG_ROOT} /packages/RPM /SPECS/foglamp.spec
208
+ sed -i " s/__VERSION__/${version} /g" ${PKG_ROOT} /packages/RPM /SPECS/foglamp.spec
209
+ sed -i " s/__ARCH__/${architecture} /g" ${PKG_ROOT} /packages/RPM /SPECS/foglamp.spec
220
210
221
211
mkdir -p usr/local/foglamp
222
212
cd usr/local/foglamp
249
239
250
240
echo " Building the new package..."
251
241
base_dir=${PKG_ROOT} /packages
252
- rpmbuild --define " _topdir ${base_dir} /rpmbuild " --noclean -bb ${base_dir} /rpmbuild /SPECS/foglamp.spec
242
+ rpmbuild --define " _topdir ${base_dir} /RPM/build " --noclean -bb ${base_dir} /RPM /SPECS/foglamp.spec
253
243
echo " Building Complete."
254
244
245
+ if [[ $skip_build == 0 ]]; then
246
+ rm -rf /tmp/${repo_name}
247
+ fi
248
+
255
249
exit 0
0 commit comments