Skip to content

Commit ced7c3a

Browse files
Merge pull request #26 from fledge-iot/1.9.1RC
1.9.1RC
2 parents 0231d07 + 5452d45 commit ced7c3a

File tree

7 files changed

+235
-7
lines changed

7 files changed

+235
-7
lines changed

others/make_rpm

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#!/bin/bash
2+
3+
##--------------------------------------------------------------------------
4+
## Copyright (c) 2021 Dianomic Systems
5+
##
6+
## Licensed under the Apache License, Version 2.0 (the "License");
7+
## you may not use this file except in compliance with the License.
8+
## You may obtain a copy of the License at
9+
##
10+
## http://www.apache.org/licenses/LICENSE-2.0
11+
##
12+
## Unless required by applicable law or agreed to in writing, software
13+
## distributed under the License is distributed on an "AS IS" BASIS,
14+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
## See the License for the specific language governing permissions and
16+
## limitations under the License.
17+
##-------------------------------------------------------------------------
18+
##
19+
## Author: Ashish Jabble
20+
##
21+
22+
set -e
23+
24+
USAGE="$(basename "$0") [-h] [-a] ...
25+
This script is used to create the RPM package for to support other additional libraries as separately such as mqtt
26+
27+
Arguments:
28+
-h - Display this help text
29+
-a - Remove all the archive versions"
30+
31+
while getopts ":ha" opt; do
32+
case "$opt" in
33+
a)
34+
if [ -d "./archive" ]; then
35+
echo -n "Cleaning the package archive folder..."
36+
rm -rf ./archive/*
37+
echo "Done."
38+
else
39+
echo "No archive folder, skipping cleanall"
40+
fi
41+
exit 0
42+
;;
43+
h)
44+
echo "${USAGE}"
45+
exit 0
46+
;;
47+
\?)
48+
echo "Invalid option -$OPTARG"
49+
exit 1
50+
;;
51+
:)
52+
echo "-$OPTARG requires an argument"
53+
exit 1
54+
esac
55+
done
56+
shift $((OPTIND -1))
57+
58+
ADDITIONAL_LIB_NAME=$1
59+
if [ "${ADDITIONAL_LIB_NAME}" = "" ]; then
60+
echo "You must specify additional library name to package. For example: mqtt"
61+
exit 1
62+
fi
63+
64+
# VERSION
65+
if [ -f scripts/${ADDITIONAL_LIB_NAME}/VERSION ]; then
66+
VERSION=`cat scripts/${ADDITIONAL_LIB_NAME}/VERSION | tr -d ' ' | grep "fledge_${ADDITIONAL_LIB_NAME}_version" | head -1 | sed -e 's/\(.*\)=\(.*\)/\2/g'`
67+
FLEDGE_VERSION=`cat scripts/${ADDITIONAL_LIB_NAME}/VERSION | tr -d ' ' | grep 'fledge_version' | head -1 | sed -e 's/\(.*\)version\([>=|>|<|<=|=]*\)\(.*\)/\2 \3/g'`
68+
else
69+
echo VERSION file is missing for ${ADDITIONAL_LIB_NAME} in "others/scripts/" directory
70+
exit 1
71+
fi
72+
73+
# Description
74+
if [ -f scripts/${ADDITIONAL_LIB_NAME}/Description ]; then
75+
DESCRIPTION=`cat "scripts/${ADDITIONAL_LIB_NAME}/Description"`
76+
else
77+
echo Description file is missing for ${ADDITIONAL_LIB_NAME} in "others/scripts/" directory
78+
exit 1
79+
fi
80+
81+
# requirements.sh
82+
if [ -f scripts/${ADDITIONAL_LIB_NAME}/requirements.sh ]; then
83+
./scripts/${ADDITIONAL_LIB_NAME}/requirements.sh
84+
else
85+
echo Requirement script is missing for ${ADDITIONAL_LIB_NAME} "others/scripts/" directory
86+
exit 1
87+
fi
88+
89+
GIT_ROOT=`pwd`
90+
ARCHIVE_PATH=${GIT_ROOT}/archive/RPM
91+
PKG_NAME="fledge-${ADDITIONAL_LIB_NAME}"
92+
ARCHITECTURE=`arch`
93+
PACKAGE_NAME="${PKG_NAME}-${VERSION}"
94+
BUILD_ROOT="${GIT_ROOT}/packages/build"
95+
96+
if [ ! -d "${ARCHIVE_PATH}/${ARCHITECTURE}" ]; then
97+
mkdir -p "${ARCHIVE_PATH}/${ARCHITECTURE}"
98+
fi
99+
100+
# Print the summary of findings
101+
echo "Additional ${ADDITIONAL_LIB_NAME} Package version is : ${VERSION}"
102+
echo "The Fledge required version is : ${FLEDGE_VERSION}"
103+
echo "The architecture is set as : ${ARCHITECTURE}"
104+
echo "The package root directory is : ${GIT_ROOT}"
105+
echo "The package will be built in : ${BUILD_ROOT}"
106+
echo "The package name is : ${PACKAGE_NAME}"
107+
echo
108+
109+
# First, create the BUILD_ROOT folder, if necessary
110+
if [ ! -L "${BUILD_ROOT}" -a ! -d "${BUILD_ROOT}" ]; then
111+
mkdir -p ${BUILD_ROOT}
112+
fi
113+
114+
# Check old copy of PACKAGE_NAME; if exists then remove
115+
if [ -d "${BUILD_ROOT}/${PACKAGE_NAME}" ]; then
116+
rm -rf ${BUILD_ROOT}/${PACKAGE_NAME}*
117+
fi
118+
119+
# Populate the package directory with RPM files
120+
echo -n "Populating the package and updating version file..."
121+
cd ${BUILD_ROOT}
122+
mkdir -p ${PACKAGE_NAME}
123+
cd ${PACKAGE_NAME}
124+
cp -R ${GIT_ROOT}/packages/RPM/* SPECS
125+
sed -i "s/__NAME__/${PKG_NAME}/g" SPECS/others.spec
126+
sed -i "s/__VERSION__/${VERSION}/g" SPECS/others.spec
127+
sed -i "s/__ARCH__/${ARCHITECTURE}/g" SPECS/others.spec
128+
sed -i "s/__REQUIRES__/fledge ${FLEDGE_VERSION}/g" SPECS/others.spec
129+
sed -i "s/__DESCRIPTION__/${DESCRIPTION}/g" SPECS/others.spec
130+
echo "Done."
131+
132+
# RPM file structure
133+
echo "Copying artifacts..."
134+
mkdir -p BUILDROOT
135+
cd BUILDROOT
136+
mkdir -p ${PACKAGE_NAME}-1.${ARCHITECTURE}
137+
cd ${PACKAGE_NAME}-1.${ARCHITECTURE}
138+
mkdir -p usr/local/lib64
139+
if [ "${ADDITIONAL_LIB_NAME}" == "mqtt" ]; then
140+
cp -R --preserve=links /usr/local/lib64/libpaho* usr/local/lib64
141+
fi
142+
# TODO: FOGL-3632 - Blocked with its compilation
143+
#if [ "${ADDITIONAL_LIB_NAME}" == "gcp" ]; then
144+
# cp -R --preserve=links /usr/local/lib64/libjwt* usr/local/lib64
145+
# cp -R --preserve=links /usr/local/lib64/libjansson* usr/local/lib64
146+
#fi
147+
echo "Done."
148+
find -L . -type f -exec echo '/'{} \; >> ../../SPECS/others.spec
149+
echo "Building the RPM package..."
150+
cd ${BUILD_ROOT}
151+
rpmbuild --define "_topdir ${BUILD_ROOT}/${PACKAGE_NAME}" --noclean -bb ${BUILD_ROOT}/${PACKAGE_NAME}/SPECS/others.spec
152+
echo "Building Complete."
153+
echo "Artifacts copied to "${ARCHIVE_PATH}/${ARCHITECTURE}
154+
PKG_NAME_WITH_EXT="${PACKAGE_NAME}-1.${ARCHITECTURE}.rpm"
155+
cp ${BUILD_ROOT}/${PACKAGE_NAME}/RPMS/${ARCHITECTURE}/${PKG_NAME_WITH_EXT} ${ARCHIVE_PATH}/${ARCHITECTURE}/${PKG_NAME_WITH_EXT}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%define __spec_install_pre /bin/true
2+
3+
Name: __NAME__
4+
Vendor: Dianomic Systems, Inc. <[email protected]>
5+
Version: __VERSION__
6+
Release: 1
7+
BuildArch: __ARCH__
8+
Summary: Generalized package for additional libraries
9+
License: Apache License
10+
Group: IOT
11+
URL: http://www.dianomic.com
12+
Prefix: /usr/local
13+
Requires: __REQUIRES__
14+
AutoReqProv: no
15+
16+
%description
17+
__DESCRIPTION__
18+
19+
%pre
20+
21+
%preun
22+
23+
%post
24+
25+
%postun
26+
27+
%clean
28+
29+
%changelog
30+
31+
%files

others/scripts/gcp/VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fledge_gcp_version=1.9.0
2-
fledge_version>=1.9
1+
fledge_gcp_version=1.9.1
2+
fledge_version>=1.9

others/scripts/mqtt/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fledge_mqtt_version=1.9.0
1+
fledge_mqtt_version=1.9.1
22
fledge_version>=1.9

others/scripts/mqtt/requirements.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,38 @@
2121
##
2222

2323
set -e
24+
os_name=`(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')`
25+
os_version=`(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')`
26+
echo "Platform is ${os_name}, Version: ${os_version}"
2427

28+
if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]]; then
29+
if [[ $os_name == *"Red Hat"* ]]; then
30+
sudo yum-config-manager --enable 'Red Hat Enterprise Linux Server 7 RHSCL (RPMs)'
31+
sudo yum install -y @development
32+
else
33+
sudo yum groupinstall "Development tools" -y
34+
sudo yum install -y centos-release-scl
35+
fi
36+
sudo yum install -y openssl-devel
37+
38+
# A gcc version newer than 4.9.0 is needed to properly use <regex>
39+
# the installation of these packages will not overwrite the previous compiler
40+
# the new one will be available using the command 'source scl_source enable devtoolset-7'
41+
# the previous gcc will be enabled again after a log-off/log-in.
42+
#
43+
sudo yum install -y yum-utils
44+
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
45+
sudo yum install -y devtoolset-7
46+
elif apt --version 2>/dev/null; then
47+
sudo apt install -y libssl-dev pkg-config
48+
else
49+
echo "Requirements are not supported for platform: ${os_name} and having version: ${os_version}"
50+
fi
51+
rm -rf paho.mqtt.c
2552
git clone https://github.com/eclipse/paho.mqtt.c.git
26-
sudo apt-get install libssl-dev pkg-config
2753
cd paho.mqtt.c
2854
mkdir build
2955
cd build
30-
cmake -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_WITH_SSL=TRUE ..
56+
cmake -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_WITH_SSL=FALSE ..
3157
make
3258
sudo make install

packages/RPM/SPECS/fledge.spec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,14 @@ copy_fledge_sudoer_file
462462
echo "Enabling Fledge service"
463463
enable_fledge_service
464464

465-
echo "Starting Fledge service"
466-
start_fledge_service
465+
# Skipping the start of fledge when package is upgraded,
466+
# because of other related packages upgrade transaction mechanism is causing issues in Fledge (FOGL-5506).
467+
if [ $1 == 2 ];then
468+
echo "Please start fledge once upgrade process is complete; using 'systemctl start fledge'"
469+
else
470+
echo "Starting Fledge service"
471+
start_fledge_service
472+
fi
467473

468474

469475
%postun

plugins/make_rpm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ do
201201
if [ ! -z "${service_notification_version}" ] ; then
202202
sed -i "s/fledge-service-notification/fledge-service-notification ${service_notification_version}/" SPECS/plugin.spec
203203
fi
204+
if [ -f "${GIT_ROOT}/additional_lib.version" ]; then
205+
while read line ; do
206+
if [ ! -z "$line" ]; then
207+
additional_lib_name=`echo ${line} | cut -d ":" -f1`
208+
additional_lib_version=`echo ${line} | cut -d ":" -f2 | sed -e 's/\([>=|>|<|<=|=]*\)\(.*\)/\1 \2/g'`
209+
echo "The Additional ${additional_lib_name} Library required version: ${additional_lib_version}"
210+
sed -i "s/fledge-${additional_lib_name}/fledge-${additional_lib_name} ${additional_lib_version}/" SPECS/plugin.spec
211+
fi
212+
done < "${GIT_ROOT}/additional_lib.version"
213+
fi
204214
cat > /tmp/sed.script.$$ << EOF
205215
/__DESCRIPTION__/ {
206216
r ${GIT_ROOT}/Description

0 commit comments

Comments
 (0)