Skip to content

Commit de382af

Browse files
Merge pull request #20 from fledge-iot/FOGL-4771
FOGL-4771 additional libraries centralized scripts added in other directory
2 parents cdd6366 + 6d54665 commit de382af

File tree

9 files changed

+522
-0
lines changed

9 files changed

+522
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# Build
1212
packages/Debian/build/
1313
packages/RPM/build/
14+
others/paho.mqtt.c/
1415

1516
# Archived packages
1617
plugins/archive
1718
service/archive
19+
others/archive

others/README.rst

Lines changed: 310 additions & 0 deletions
Large diffs are not rendered by default.

others/make_deb

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/bash
2+
3+
##--------------------------------------------------------------------
4+
## Copyright (c) 2021 Dianomic Systems Inc.
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 Debian 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
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/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+
architecture=`arch`
90+
PKG_ROOT=`pwd`
91+
archive=${PKG_ROOT}/archive/DEBIAN
92+
pkg_name="fledge-${ADDITIONAL_LIB_NAME}"
93+
arch_name=$(dpkg --print-architecture)
94+
package_name="${pkg_name}-${version}-${architecture}"
95+
96+
if [ ! -d "${archive}/${architecture}" ]; then
97+
mkdir -p "${archive}/${architecture}/${package_name}"
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 will be built in : ${archive}/${architecture}"
105+
echo "The package name is : ${package_name}"
106+
echo
107+
108+
echo -n "Populating the package and updating version file..."
109+
cd "${archive}/${architecture}/${package_name}"
110+
mkdir -p DEBIAN
111+
cp -R ${PKG_ROOT}/packages/DEBIAN/* DEBIAN
112+
sed -i "s/__VERSION__/${version}/g" DEBIAN/control
113+
sed -i "s/__NAME__/${pkg_name}/g" DEBIAN/control
114+
sed -i "s/__ARCH__/${arch_name}/g" DEBIAN/control
115+
sed -i "s/__REQUIRES__/fledge (${fledge_version})/g" DEBIAN/control
116+
sed -i "s/__DESCRIPTION__/${description}/g" DEBIAN/control
117+
118+
# Debian file structure
119+
mkdir -p usr/local/lib
120+
if [ "${ADDITIONAL_LIB_NAME}" == "mqtt" ]; then
121+
cp -R --preserve=links /usr/local/lib/libpaho* usr/local/lib
122+
fi
123+
echo "Done."
124+
125+
# Build the package
126+
cd "${archive}/${architecture}"
127+
echo "Building the ${package_name} package..."
128+
dpkg-deb --build ${package_name}
129+
echo "Building Complete."

others/packages/DEBIAN/control

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: __NAME__
2+
Version: __VERSION__
3+
Section: devel
4+
Priority: optional
5+
Architecture: __ARCH__
6+
Depends: __REQUIRES__
7+
Conflicts:
8+
Maintainer: Dianomic Systems, Inc. <[email protected]>
9+
Homepage: http://www.dianomic.com
10+
Description: __DESCRIPTION__

others/packages/DEBIAN/postinst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
##--------------------------------------------------------------------
4+
## Copyright (c) 2021 Dianomic Systems Inc.
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+
##--------------------------------------------------------------------
20+
##
21+
## @postinst DEBIAN/postinst
22+
## This script is used to execute post installation tasks.
23+
##
24+
## Author: Ashish Jabble
25+
##
26+
##--------------------------------------------------------------------
27+
28+
set -e

others/scripts/mqtt/Description

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Paho MQTT C Client additional libraries.

others/scripts/mqtt/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fledge_mqtt_version=1.8.2
2+
fledge_version>=1.8
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env 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+
##
20+
## Author: Ashish Jabble
21+
##
22+
23+
set -e
24+
25+
git clone https://github.com/eclipse/paho.mqtt.c.git
26+
sudo apt-get install libssl-dev pkg-config
27+
cd paho.mqtt.c
28+
mkdir build
29+
cd build
30+
cmake -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_WITH_SSL=TRUE ..
31+
make
32+
sudo make install

plugins/make_deb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ do
135135
service_notification_version=`cat ${GIT_ROOT}/service_notification.version | tr -d ' ' | grep 'service_notification_version' | head -1 | sed -e 's/\(.*\)version\(.*\)/\2/g'`
136136
echo "The Service notification required version : ${service_notification_version}"
137137
fi
138+
if [ -f "${GIT_ROOT}/additional_lib.version" ]; then
139+
additional_lib_name=`cat additional_lib.version | cut -d ":" -f1`
140+
additional_lib_version=`cat additional_lib.version | cut -d ":" -f2`
141+
echo "The Additional ${additional_lib_name} Library required version : ${additional_lib_version}"
142+
fi
138143
echo
139144

140145
# Create the package directory. If a directory with the same name exists,
@@ -190,6 +195,9 @@ do
190195
sed -i "s/__DESCRIPTION__/${desc}/g" ${deb_path}/control
191196
if [ ! -z "${service_notification_version}" ] ; then
192197
sed -i "s/fledge-service-notification/fledge-service-notification (${service_notification_version})/" ${deb_path}/control
198+
fi
199+
if [ ! -z "${additional_lib_version}" ] ; then
200+
sed -i "s/fledge-${additional_lib_name}/fledge-${additional_lib_name} (${additional_lib_version})/" ${deb_path}/control
193201
fi
194202
# install notes
195203
if [ -f "${GIT_ROOT}/install_notes.txt" ]; then

0 commit comments

Comments
 (0)