Skip to content

Commit ccfd37d

Browse files
Merge pull request #15 from fledge-iot/1.8.1RC
1.8.1 rc
2 parents 2d7b9da + 660f24d commit ccfd37d

File tree

7 files changed

+176
-80
lines changed

7 files changed

+176
-80
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing to Fledge
2+
3+
The Fledge project welcomes contributions of any kind, please see [CONTRIBUTING.md](https://github.com/fledge-iot/fledge/blob/develop/CONTRIBUTING.md) in the main Fledge repository for details and guidance.

packages/Debian/aarch64/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Version: 1.0.0
33
Section: devel
44
Priority: optional
55
Architecture: arm64
6-
Depends: autoconf,libtool,libboost-dev,libboost-system-dev,libboost-thread-dev,libpq-dev,python3-pip,python3-setuptools,sqlite3,sudo,krb5-user,libcurl4-openssl-dev
6+
Depends: autoconf,automake,libtool,libboost-dev,libboost-system-dev,libboost-thread-dev,libpq-dev,python3-dev,python3-pip,python3-setuptools,sqlite3,sudo,krb5-user,libcurl4-openssl-dev
77
Conflicts:
88
Maintainer: Dianomic Systems, Inc. <[email protected]>
99
Homepage: http://www.dianomic.com

packages/Debian/armv7l/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Version: 1.0.0
33
Section: devel
44
Priority: optional
55
Architecture: armhf
6-
Depends: autoconf,libtool,libboost-dev,libboost-system-dev,libboost-thread-dev,libpq-dev,python3-pip,python3-setuptools,sqlite3,sudo,cpulimit,krb5-user,libcurl4-openssl-dev
6+
Depends: autoconf,ca-certificates,curl,libcurl4-openssl-dev,libtool,libboost-dev,libboost-system-dev,libboost-thread-dev,libpq-dev,python3-pip,python3-setuptools,sqlite3,sudo,cpulimit,krb5-user
77
Conflicts:
88
Maintainer: Dianomic Systems, Inc. <[email protected]>
99
Homepage: http://www.dianomic.com

packages/Debian/common/DEBIAN/postrm

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,24 @@ remove_fledge_sudoer_file() {
3535
rm -rf /etc/sudoers.d/fledge
3636
}
3737

38-
echo "Cleanup of files"
39-
remove_unused_files
40-
41-
echo "Remove fledge sudoers file"
42-
remove_fledge_sudoer_file
38+
case "$1" in
39+
remove|purge)
40+
echo "Cleanup of files"
41+
remove_unused_files
42+
echo "Remove fledge sudoers file"
43+
remove_fledge_sudoer_file
44+
;;
45+
disappear)
46+
;;
47+
upgrade)
48+
;;
49+
failed-upgrade)
50+
;;
51+
abort-install)
52+
;;
53+
abort-upgrade)
54+
;;
55+
*) echo "$0: didn't understand being called with \`$1'" 1>&2
56+
exit 0;;
57+
esac
58+
exit 0

packages/Debian/common/DEBIAN/preinst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ then
8484
exit 1
8585
fi
8686

87+
# Below workaround needed only when we upgrade from 1.8.0 ONLY
88+
# As Debian flow be like 1.8.0.prerm => .next.preinst => 1.8.0.postrm => .next.postinst
89+
sed -i -e 's/^remove_unused_files$/#remove_unused_files/' /var/lib/dpkg/info/fledge.postrm
90+
8791
# Persist current version in case of upgrade/downgrade
8892
installed_version=`dpkg -s ${PKG_NAME} | grep '^Version:' | awk '{print $2}'`
8993
if [ "${installed_version}" ]

packages/RPM/SPECS/fledge.spec

Lines changed: 121 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,30 @@ AutoReqProv: no
1919
%description
2020
Fledge, the open source platform for the Internet of Things
2121

22+
23+
## -------------------------------------------------------------------------------------------------
24+
## Scriptlet values which we must use in our scripts
25+
26+
## scriptlet install upgrade uninstall
27+
## %pre $1 == 1 $1 == 2 (N/A)
28+
## %post $1 == 1 $1 == 2 (N/A)
29+
## %preun (N/A) $1 == 1 $1 == 0
30+
## %postun (N/A) $1 == 1 $1 == 0
31+
32+
33+
## On upgrade, the scripts are run in the following order:
34+
35+
## %pre of new package
36+
## %post of new package
37+
## %preun of old package
38+
## %postun of old package
39+
40+
## --------------------------------------------------------------------------------------------------
41+
2242
%pre
2343
#!/usr/bin/env bash
2444

25-
##--------------------------------------------------------------------
45+
##---------------------------------------------------------------------------------------------------
2646
## Copyright (c) 2019 Dianomic Systems Inc.
2747
##
2848
## Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,23 +56,23 @@ Fledge, the open source platform for the Internet of Things
3656
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3757
## See the License for the specific language governing permissions and
3858
## limitations under the License.
39-
##--------------------------------------------------------------------
59+
##---------------------------------------------------------------------------------------------------
4060

41-
##--------------------------------------------------------------------
61+
##---------------------------------------------------------------------------------------------------
4262
##
43-
## This script is used to execute pre installation tasks.
63+
## The %pre scriptlet executes just before the package is to be installed.
4464
##
45-
## Author: Ivan Zoratti, Ashwin Gopalakrishnan, Massimiliano Pinto, Stefano Simonelli
65+
## Author: Ivan Zoratti, Ashwin Gopalakrishnan, Massimiliano Pinto, Stefano Simonelli, Ashish Jabble
4666
##
47-
##--------------------------------------------------------------------
67+
##---------------------------------------------------------------------------------------------------
4868

4969
set -e
5070

5171
PKG_NAME="fledge"
5272

5373
is_fledge_installed () {
5474
set +e
55-
rc=`rpm -qa 2> /dev/null | grep -Fx ${PKG_NAME}`
75+
rc=$(rpm -ql ${PKG_NAME} | grep 'fledge/bin/fledge$')
5676
echo $rc
5777
set -e
5878
}
@@ -86,29 +106,60 @@ exists_schema_change_path () {
86106
echo 1
87107
}
88108

89-
# main
109+
stop_fledge_service () {
110+
systemctl stop fledge
111+
}
90112

91-
# check if fledge is installed
92-
IS_FLEDGE_INSTALLED=$(is_fledge_installed)
113+
kill_fledge () {
114+
set +e
115+
fledge_script=$(get_fledge_script)
116+
fledge_status_output=$($fledge_script kill 2>&1)
117+
set -e
118+
}
93119

94-
# if fledge is installed...
95-
if [ "$IS_FLEDGE_INSTALLED" -eq "1" ]
96-
then
97-
echo "Fledge is already installed: this is an upgrade/downgrade."
120+
disable_fledge_service () {
121+
set +e
122+
/sbin/chkconfig fledge off
123+
set -e
124+
}
98125

99-
# exit if fledge is running
126+
remove_fledge_service_file () {
127+
rm -rf /etc/init.d/fledge
128+
}
129+
130+
reset_systemctl () {
131+
systemctl daemon-reload
132+
systemctl reset-failed
133+
}
134+
135+
# main
136+
if [ $1 == 1 ];then
137+
echo "pre scriptlet is called: ${PKG_NAME} is getting installed."
138+
# Add steps here for the fresh installed case for this scriptlet
139+
elif [ $1 == 2 ];then
140+
echo "pre scriptlet is called: ${PKG_NAME} is getting upgraded."
100141
IS_FLEDGE_RUNNING=$(is_fledge_running)
101142
if [ "$IS_FLEDGE_RUNNING" -eq "1" ]
102143
then
103-
echo "*** ERROR. Fledge is currently running. Stop Fledge and try again. ***"
104-
exit 1
144+
echo "${PKG_NAME} is currently running."
145+
echo "Stop ${PKG_NAME} service."
146+
stop_fledge_service
147+
echo "Kill ${PKG_NAME}."
148+
kill_fledge
105149
fi
106150

151+
echo "Disable ${PKG_NAME} service."
152+
disable_fledge_service
153+
echo "Remove ${PKG_NAME} service script"
154+
remove_fledge_service_file
155+
echo "Reset systemctl"
156+
reset_systemctl
157+
107158
# Persist current version in case of upgrade/downgrade
108159
installed_version=`rpm -qi ${PKG_NAME} | grep Version |awk '{print $3}'`
109160
if [ "${installed_version}" ]
110161
then
111-
# Persist current Fledge version: it will be removed by postinstall script
162+
# Persist current ${PKG_NAME} version: it will be removed by postinstall script
112163
this_dir=`pwd`
113164
cd /usr/local/fledge/
114165
echo "${installed_version}" > .current_installed_version
@@ -118,22 +169,20 @@ then
118169
# check schema version file, exit if schema change path does not exist
119170
CURRENT_VERSION_FILE=$(get_current_version_file)
120171
CURRENT_SCHEMA_VERSION=$(get_schema_version $CURRENT_VERSION_FILE)
121-
echo "Fledge currently has schema version $CURRENT_SCHEMA_VERSION"
172+
echo "${PKG_NAME} currently has schema version $CURRENT_SCHEMA_VERSION"
122173
EXISTS_SCHEMA_CHANGE_PATH=$(exists_schema_change_path)
123174
if [ "$EXISTS_SCHEMA_CHANGE_PATH" -eq "0" ]
124175
then
125176
echo "*** ERROR. There is no schema change path from the installed version to the new version. ***"
126177
exit 1
127178
fi
128-
129179
fi
130180

131181

132-
133182
%preun
134183
#!/usr/bin/env bash
135184

136-
##--------------------------------------------------------------------
185+
##--------------------------------------------------------------------------------
137186
## Copyright (c) 2019 Dianomic Systems Inc.
138187
##
139188
## Licensed under the Apache License, Version 2.0 (the "License");
@@ -147,15 +196,15 @@ fi
147196
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148197
## See the License for the specific language governing permissions and
149198
## limitations under the License.
150-
##--------------------------------------------------------------------
199+
##--------------------------------------------------------------------------------
151200

152-
##--------------------------------------------------------------------
201+
##--------------------------------------------------------------------------------
153202
##
154-
## This script is used to execute before the removal of files associated with the package.
203+
## The %preun scriptlet executes just before the package is to be erased.
155204
##
156-
## Author: Ivan Zoratti, Ashwin Gopalakrishnan, Stefano Simonelli
205+
## Author: Ivan Zoratti, Ashwin Gopalakrishnan, Stefano Simonelli, Ashish Jabble
157206
##
158-
##----------------------------------------------------------------------------------------
207+
##--------------------------------------------------------------------------------
159208

160209
set -e
161210

@@ -202,30 +251,33 @@ reset_systemctl () {
202251
}
203252

204253
# main
254+
if [ $1 == 1 ];then
255+
echo "preun scriptlet is called: ${PKG_NAME} is getting upgraded."
256+
elif [ $1 == 0 ];then
257+
echo "preun scriptlet is called: ${PKG_NAME} is getting removed/uninstalled."
258+
IS_FLEDGE_RUNNING=$(is_fledge_running)
259+
if [ "$IS_FLEDGE_RUNNING" -eq "1" ]
260+
then
261+
echo "${PKG_NAME} is currently running."
262+
echo "Stop ${PKG_NAME} service."
263+
stop_fledge_service
264+
echo "Kill ${PKG_NAME}."
265+
kill_fledge
266+
fi
205267

206-
IS_FLEDGE_RUNNING=$(is_fledge_running)
207-
208-
if [ "$IS_FLEDGE_RUNNING" -eq "1" ]
209-
then
210-
echo "Fledge is currently running."
211-
echo "Stop Fledge service."
212-
stop_fledge_service
213-
echo "Kill Fledge."
214-
kill_fledge
268+
echo "Disable ${PKG_NAME} service."
269+
disable_fledge_service
270+
echo "Remove ${PKG_NAME} service script"
271+
remove_fledge_service_file
272+
echo "Reset systemctl"
273+
reset_systemctl
215274
fi
216275

217-
echo "Disable Fledge service."
218-
disable_fledge_service
219-
echo "Remove Fledge service script"
220-
remove_fledge_service_file
221-
echo "Reset systemctl"
222-
reset_systemctl
223-
224276

225277
%post
226278
#!/usr/bin/env bash
227279

228-
##--------------------------------------------------------------------
280+
##----------------------------------------------------------------------------
229281
## Copyright (c) 2019 Dianomic Systems Inc.
230282
##
231283
## Licensed under the Apache License, Version 2.0 (the "License");
@@ -239,15 +291,15 @@ reset_systemctl
239291
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
240292
## See the License for the specific language governing permissions and
241293
## limitations under the License.
242-
##--------------------------------------------------------------------
294+
##----------------------------------------------------------------------------
243295

244-
##--------------------------------------------------------------------
296+
##----------------------------------------------------------------------------
245297
##
246-
## This script is used to execute post installation tasks.
298+
## The %post scriptlet executes just after the package is to be installed.
247299
##
248-
## Author: Ivan Zoratti, Massimiliano Pinto, Stefano Simonelli
300+
## Author: Ivan Zoratti, Massimiliano Pinto, Stefano Simonelli, Ashish Jabble
249301
##
250-
##--------------------------------------------------------------------
302+
##----------------------------------------------------------------------------
251303

252304
set -e
253305

@@ -274,7 +326,6 @@ copy_service_file() {
274326
}
275327

276328
enable_fledge_service() {
277-
278329
/sbin/chkconfig fledge on
279330
}
280331

@@ -351,9 +402,10 @@ install_pip3_packages () {
351402
fi
352403
source scl_source enable rh-python36
353404

354-
pip install -Ir /usr/local/fledge/python/requirements.txt
405+
# TODO: we may need with --no-cache-dir
406+
pip3 install -Ir /usr/local/fledge/python/requirements.txt
355407

356-
sudo bash -c 'source scl_source enable rh-python36;pip install dbus-python'
408+
sudo bash -c 'source scl_source enable rh-python36;pip3 install dbus-python'
357409
set -e
358410
}
359411

@@ -378,7 +430,6 @@ call_package_update_script () {
378430

379431

380432
# main
381-
382433
echo "Install python dependencies"
383434
install_pip3_packages
384435

@@ -418,7 +469,7 @@ start_fledge_service
418469
%postun
419470
#!/usr/bin/env bash
420471

421-
##--------------------------------------------------------------------
472+
##--------------------------------------------------------------------------
422473
## Copyright (c) 2019 Dianomic Systems Inc.
423474
##
424475
## Licensed under the Apache License, Version 2.0 (the "License");
@@ -432,17 +483,18 @@ start_fledge_service
432483
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
433484
## See the License for the specific language governing permissions and
434485
## limitations under the License.
435-
##--------------------------------------------------------------------
486+
##--------------------------------------------------------------------------
436487

437-
##--------------------------------------------------------------------
488+
##--------------------------------------------------------------------------
438489
##
439-
## This script is used to modifies links or other files associated with fledge, and/or removes files created by the package.
490+
## The %postun scriptlet executes just after the package is to be erased.
440491
##
441492
## Author: Ashish Jabble
442493
##
443-
##--------------------------------------------------------------------
494+
##--------------------------------------------------------------------------
444495

445496
set -e
497+
PKG_NAME="fledge"
446498

447499
remove_unused_files () {
448500
find /usr/local/fledge/ -maxdepth 1 -mindepth 1 -type d | egrep -v -w '(/usr/local/fledge/data)' | xargs rm -rf
@@ -452,11 +504,18 @@ remove_fledge_sudoer_file() {
452504
rm -rf /etc/sudoers.d/fledge
453505
}
454506

455-
echo "Cleanup of files"
456-
remove_unused_files
507+
# main
508+
if [ $1 == 1 ];then
509+
echo "postun scriptlet is called: ${PKG_NAME} is getting upgraded."
510+
# Add steps here for the upgrade case for this scriptlet
511+
elif [ $1 == 0 ];then
512+
echo "postun scriptlet is called: ${PKG_NAME} is getting removed/uninstalled."
513+
echo "Cleanup of files"
514+
remove_unused_files
515+
echo "Remove fledge sudoers file"
516+
remove_fledge_sudoer_file
517+
fi
457518

458-
echo "Remove fledge sudoers file"
459-
remove_fledge_sudoer_file
460519

461520
%files
462521
%{install_path}/*

0 commit comments

Comments
 (0)