Skip to content

Commit ce88093

Browse files
committed
RPM build directory structure for FogLAMP package
1 parent d3e9dfd commit ce88093

File tree

3 files changed

+67
-72
lines changed

3 files changed

+67
-72
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# Build
1212
packages/Debian/build/
13+
packages/RPM/build/
1314

1415
# Archived packages
1516
plugins/archive

make_rpm

Lines changed: 60 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
set -e
2323

2424
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
2626
branch="master" # Default Git branch to use
2727
pkg_name="foglamp" # Name of the package to build
2828
architecture="x86_64" # The architecture for which the rpm should be created
@@ -41,51 +41,49 @@ Arguments:
4141
-b - Branch to base package on"
4242

4343
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
8084
done
8185

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
8987
echo You must run this script from the foglamp-pkg directory
9088
exit 1
9189
fi
@@ -94,27 +92,24 @@ fi
9492
# Extracts/updates Git repository
9593
#
9694
if [[ $skip_build == 0 ]]; then
97-
9895
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")
10299
else
103-
git clone -b "$branch" https://github.com/foglamp/${repos}.git
100+
git clone -b "$branch" https://github.com/foglamp/${repo_name}.git
104101
fi
105102

106-
GIT_ROOT=/tmp/"$repos"
103+
GIT_ROOT=/tmp/"${repo_name}"
107104
cd ${GIT_ROOT}
108105
fi
109106

110107
#
111108
# Builds FogLAMP
112109
#
113110
if [[ $skip_build == 0 ]]; then
114-
115111
# Backups FOGLAMP_ROOT
116112
export FOGLAMP_ROOT_BCK=${FOGLAMP_ROOT}
117-
118113
export FOGLAMP_ROOT=${GIT_ROOT}
119114
export FOGLAMP_DATA=${FOGLAMP_ROOT}/data
120115
export PYTHONPATH=${FOGLAMP_ROOT}/python
@@ -135,19 +130,16 @@ if [[ $skip_build == 0 ]]; then
135130
status_pg_isready=$?
136131

137132
if [[ $status_rh_postgresql96 != 0 ]]; then
138-
139133
echo "ERROR : it is not possible to enable the ${rhpg_pkg} environment"
140134
exit 1
141135
fi
142136

143137
if [[ $status_devtoolset != 0 ]]; then
144-
145138
echo "ERROR : it is not possible to enable the ${rhgcc_pkg} environment"
146139
exit 1
147140
fi
148141

149142
if [[ $status_pg_isready != 0 ]]; then
150-
151143
echo "ERROR : the command pg_isready is not available"
152144
exit 1
153145
fi
@@ -163,22 +155,20 @@ fi
163155

164156
# Checks if the FOGLAMP_ROOT environment is defined
165157
if [[ "${FOGLAMP_ROOT}" == "" ]]; then
166-
167158
# Set FOGLAMP_ROOT as the default directory
168-
export FOGLAMP_ROOT="/usr/local/foglamp"
159+
export FOGLAMP_ROOT="/usr/local/foglamp"
169160
fi
170161

171162
if [[ ! -d "${FOGLAMP_ROOT}" ]]; then
172-
173163
echo "No FOGLAMP_ROOT directory found in the path ${FOGLAMP_ROOT} - Program exit."
174164
exit 1
175165
fi
176166

177167
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"
179169

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
182172

183173
# Final package name
184174
package_name="${pkg_name}-${version}-1.${architecture}"
@@ -187,7 +177,7 @@ package_name="${pkg_name}-${version}-1.${architecture}"
187177
echo "The package root directory is : ${PKG_ROOT}"
188178
echo "The FogLAMP directory is : ${FOGLAMP_ROOT}"
189179
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}"
191181
echo "The package name is : ${package_name}"
192182
echo
193183

@@ -214,9 +204,9 @@ mkdir "${package_name}"
214204
echo -n "Populating the package and updating version in control file..."
215205
cd "${package_name}"
216206

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
220210

221211
mkdir -p usr/local/foglamp
222212
cd usr/local/foglamp
@@ -249,7 +239,11 @@ fi
249239

250240
echo "Building the new package..."
251241
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
253243
echo "Building Complete."
254244

245+
if [[ $skip_build == 0 ]]; then
246+
rm -rf /tmp/${repo_name}
247+
fi
248+
255249
exit 0

packages/rpmbuild/SPECS/foglamp.spec renamed to packages/RPM/SPECS/foglamp.spec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
%define __spec_install_pre /bin/true
22

3-
Name: __NAME__
3+
Name: foglamp
44
Vendor: Dianomic Systems, Inc. <[email protected]>
5-
Version: __VERSION__
5+
Version: 1.7.0
66
Release: 1
7-
BuildArch: __ARCH__
7+
BuildArch: x86_64
88
Summary: FogLAMP, the open source platform for the Internet of Things
99
License: Apache License
1010
Group: IOT
@@ -23,7 +23,7 @@ FogLAMP, the open source platform for the Internet of Things
2323
#!/usr/bin/env bash
2424

2525
##--------------------------------------------------------------------
26-
## Copyright (c) 2019 OSIsoft, LLC
26+
## Copyright (c) 2019 Dianomic Systems Inc.
2727
##
2828
## Licensed under the Apache License, Version 2.0 (the "License");
2929
## you may not use this file except in compliance with the License.
@@ -134,7 +134,7 @@ fi
134134
#!/usr/bin/env bash
135135

136136
##--------------------------------------------------------------------
137-
## Copyright (c) 2019 OSIsoft, LLC
137+
## Copyright (c) 2019 Dianomic Systems Inc.
138138
##
139139
## Licensed under the Apache License, Version 2.0 (the "License");
140140
## you may not use this file except in compliance with the License.
@@ -242,7 +242,7 @@ reset_systemctl
242242
#!/usr/bin/env bash
243243

244244
##--------------------------------------------------------------------
245-
## Copyright (c) 2019 OSIsoft, LLC
245+
## Copyright (c) 2019 Dianomic Systems Inc.
246246
##
247247
## Licensed under the Apache License, Version 2.0 (the "License");
248248
## you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)