Skip to content

Commit 878bf84

Browse files
Merge pull request #45 from fledge-iot/FOGL-6130.Rpm
FOGL-6130 - make_rpm fixes for any service to build with
2 parents 54410fe + 6bd17de commit 878bf84

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

service/make_rpm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ fi
7272
# Check if the default directory exists
7373
echo FLEDGE_ROOT = ${FLEDGE_ROOT}
7474
if [ "${FLEDGE_ROOT}" = "" ]; then
75-
echo "Notification server cannot be compiled: FLEDGE_ROOT environment variable is not set."
75+
echo "${REPO_NAME} service cannot be compiled: FLEDGE_ROOT environment variable is not set."
7676
echo "Specify the base directory for Fledge and set the variable with:"
7777
echo "export FLEDGE_ROOT=<basedir>"
7878
exit 1
7979
fi
8080

8181
if [ ! -d "${FLEDGE_ROOT}" ]; then
82-
echo "Notification server cannot be compiled: ${FLEDGE_ROOT} is not a valid directory."
82+
echo "${REPO_NAME} service cannot be compiled: ${FLEDGE_ROOT} is not a valid directory."
8383
echo "Specify the base directory for Fledge and set the variable with:"
8484
echo "export FLEDGE_ROOT=<basedir>"
8585
exit 1
@@ -137,7 +137,7 @@ do
137137
pkg_name="${REPO_NAME}"
138138

139139
if [ -f "${GIT_ROOT}/VERSION" ]; then
140-
version=`cat "${GIT_ROOT}/VERSION" | tr -d ' ' | grep "notification_version" | head -1 | sed -e 's/\(.*\)version\([>=|>|<|<=|=]*\)\(.*\)/\3/g'`
140+
version=`cat "${GIT_ROOT}/VERSION" | tr -d ' ' | grep "${service_name}_version" | head -1 | sed -e 's/\(.*\)version\([>=|>|<|<=|=]*\)\(.*\)/\3/g'`
141141
fledge_version=`cat ${GIT_ROOT}/VERSION| tr -d ' ' | grep 'fledge_version' | head -1 | sed -e 's/\(.*\)version\([>=|>|<|<=|=]*\)\(.*\)/\2 \3/g'`
142142
else
143143
echo Unable to determine version of package to create
@@ -207,6 +207,7 @@ do
207207
sed -i "s/fledge,/fledge ${fledge_version},/" SPECS/service.spec
208208
sed -i "s/fledge$/fledge ${fledge_version}/" SPECS/service.spec
209209
sed -i "s/__VCS__/${git_tag_info:1}/g" SPECS/service.spec
210+
sed -i "s/__SERVICE_NAME__/${service_name}/g" SPECS/service.spec
210211

211212
cat > /tmp/sed.script.$$ << EOF
212213
/__DESCRIPTION__/ {
@@ -232,7 +233,7 @@ EOF
232233
mkdir -p python/fledge/plugins/notificationRule
233234
fi
234235
mkdir -p ${install_dir}
235-
cp -R --preserve=links ${GIT_ROOT}/build/C/${install_dir}/notification/fledge* "${install_dir}/"
236+
cp -R --preserve=links ${GIT_ROOT}/build/C/${install_dir}/${service_name}/fledge* "${install_dir}/"
236237
echo "Done."
237238
cd ..
238239
find -L . -type f -exec echo '%{install_path}/'{} \; >> ../../../../SPECS/service.spec
@@ -243,8 +244,9 @@ EOF
243244
# Full Package name
244245
fullname="${package_name}.${arch}.rpm"
245246
# Move final package and its spec file to archive/arch directory
246-
cp ${BUILD_ROOT}/${package_name}/RPMS/${arch}/${fullname} ${archive}/${arch}/${fullname}
247-
cp ${BUILD_ROOT}/${package_name}/SPECS/service.spec ${archive}/${arch}
247+
mkdir -p "${archive}/$arch/${service_name}"
248+
cp ${BUILD_ROOT}/${package_name}/RPMS/${arch}/${fullname} ${archive}/${arch}/${service_name}/${fullname}
249+
cp ${BUILD_ROOT}/${package_name}/SPECS/service.spec ${archive}/${arch}/${service_name}
248250
# Remove /tmp cloned directory
249251
rm -rf /tmp/${REPO_NAME}
250252
exit 0

service/packages/RPM/SPECS/service.spec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ URL: http://www.dianomic.com
1212
VCS: __VCS__
1313

1414
%define install_path /usr/local
15+
%define service_name __SERVICE_NAME__
1516

1617
Prefix: /usr/local
1718
Requires: __REQUIRES__
@@ -26,7 +27,6 @@ __DESCRIPTION__
2627
%preun
2728
PKG_NAME="__PACKAGE_NAME__"
2829

29-
3030
%post
3131
set -e
3232
set_files_ownership () {
@@ -37,9 +37,10 @@ set_files_ownership () {
3737
echo "Setting ownership of Fledge files"
3838
set_files_ownership
3939

40-
4140
%files
41+
%if "%{service_name}" == "notification"
4242
%{install_path}/fledge/plugins/notificationDelivery
4343
%{install_path}/fledge/plugins/notificationRule
4444
%{install_path}/fledge/python/fledge/plugins/notificationDelivery
4545
%{install_path}/fledge/python/fledge/plugins/notificationRule
46+
%endif

0 commit comments

Comments
 (0)