Skip to content

Commit 164bf82

Browse files
Merge pull request #51 from fledge-iot/FOGL-4103
FOGL-4103 additional libs support added in RPM plugins packaging
2 parents 4a9756e + e8a4481 commit 164bf82

File tree

2 files changed

+62
-39
lines changed

2 files changed

+62
-39
lines changed

plugins/make_rpm

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ while getopts ":hcab:" opt; do
4444
;;
4545
a)
4646
if [ -d "./archive" ]; then
47-
echo -n "Cleaning the package archieve folder..."
47+
echo -n "Cleaning the package archive folder..."
4848
rm -rf ./archive/*
4949
echo "Done."
5050
else
@@ -249,50 +249,75 @@ EOF
249249
cp -R ${GIT_ROOT}/python .
250250
cp -R ${GIT_ROOT}/VERSION.${plugin_type}.${plugin_name} ./python/fledge/plugins/${plugin_type}/${plugin_name}
251251
else
252-
(cd ${GIT_ROOT};
253-
if [ -f requirements.sh ]; then
254-
./requirements.sh
255-
fi
256-
if [ -f build.sh ]; then
257-
./build.sh
258-
else
259-
mkdir -p build; cd build; cmake ..; make
260-
fi)
261-
mkdir -p "plugins/${plugin_type_install}/${plugin_install_dirname}"
262-
cp -R --preserve=links ${GIT_ROOT}/build/lib* "plugins/${plugin_type_install}/${plugin_install_dirname}" 2>/dev/null || \
263-
cp -R --preserve=links ${GIT_ROOT}/*.json "plugins/${plugin_type_install}/${plugin_install_dirname}" 2>/dev/null || \
264-
echo "Unable to find libraries in ${GIT_ROOT}/build and json config files in ${GIT_ROOT}, cannot proceed..."
265-
252+
(cd ${GIT_ROOT};
253+
if [ -f requirements.sh ]; then
254+
./requirements.sh
255+
fi
256+
if [ -f build.sh ]; then
257+
./build.sh
258+
else
259+
mkdir -p build; cd build; cmake ..; make
260+
fi)
261+
mkdir -p "plugins/${plugin_type_install}/${plugin_install_dirname}"
262+
cp -R --preserve=links ${GIT_ROOT}/build/lib* "plugins/${plugin_type_install}/${plugin_install_dirname}" 2>/dev/null || \
263+
cp -R --preserve=links ${GIT_ROOT}/*.json "plugins/${plugin_type_install}/${plugin_install_dirname}" 2>/dev/null || \
264+
echo "Unable to find libraries in ${GIT_ROOT}/build and json config files in ${GIT_ROOT}, cannot proceed..."
265+
if [ "${additional_libs}" != "" ]; then
266+
echo "Additional libs adding for ${plugin_name}..."
267+
cd -
268+
for i in $(echo ${additional_libs} | sed "s/,/ /g")
269+
do
270+
if [[ "${i}" == *":"* ]]; then
271+
libs=`echo ${i} | sed "s/:/ /g"`
272+
ITER=0
273+
for j in $(echo ${libs} | sed "s/ / /g")
274+
do
275+
if [[ ${ITER} = "0" ]]; then
276+
echo "Directory is :"${j}
277+
dir=${j}
278+
echo "DIR is :"${dir}
279+
mkdir -p ${dir}
280+
else
281+
echo "File is :"${j}
282+
cp -R --preserve=links ${j} ${dir}
283+
fi
284+
ITER=$(expr $ITER + 1)
285+
done
286+
else
287+
echo "Either directory or filename argument is missing for ${i} input. Also use syntax <dirname:libfullpath> and a comma separated list if multiple entries"
288+
exit 1
289+
fi
290+
done
291+
cd -
292+
fi
266293
fi
267294
echo "Done."
268295

269-
cd ..
270-
find -L . -type f -exec echo '%{install_path}/'{} \; >> ../../../../SPECS/plugin.spec
296+
cd ../../../
297+
find -L . -type f -exec echo '/'{} \; >> ${BUILD_ROOT}/${package_name}/SPECS/plugin.spec
271298

272-
# Build the package
273-
cd "${BUILD_ROOT}"
299+
# Build the package
300+
echo "Building the new package..."
301+
rpmbuild --define "_topdir ${BUILD_ROOT}/${package_name}" --noclean -bb ${BUILD_ROOT}/${package_name}/SPECS/plugin.spec
302+
echo "Building Complete."
274303

275-
echo "Building the new package..."
276-
rpmbuild --define "_topdir ${BUILD_ROOT}/${package_name}" --noclean -bb ${BUILD_ROOT}/${package_name}/SPECS/plugin.spec
277-
echo "Building Complete."
304+
fullname="${package_name}.${arch}.rpm"
278305

279-
fullname="${package_name}.${arch}.rpm"
306+
# Save the old versions
307+
existing_pkgs=`find ${archive}/${arch} -maxdepth 1 -name "${fullname}.????" | wc -l`
308+
existing_pkgs=$((existing_pkgs+1))
309+
new_stored_pkg=$(printf "${fullname}.%04d" "${existing_pkgs}")
280310

281-
# Save the old versions
282-
existing_pkgs=`find ${archive}/${arch} -maxdepth 1 -name "${fullname}.????" | wc -l`
283-
existing_pkgs=$((existing_pkgs+1))
284-
new_stored_pkg=$(printf "${fullname}.%04d" "${existing_pkgs}")
285-
286-
if [ -e "${archive}/${arch}/${fullname}" ]; then
287-
echo "Saving the old package as ${new_stored_pkg}"
288-
mv "${archive}/${arch}/${fullname}" "${archive}/${arch}/${new_stored_pkg}"
289-
fi
311+
if [ -e "${archive}/${arch}/${fullname}" ]; then
312+
echo "Saving the old package as ${new_stored_pkg}"
313+
mv "${archive}/${arch}/${fullname}" "${archive}/${arch}/${new_stored_pkg}"
314+
fi
290315

291-
cp ${BUILD_ROOT}/${package_name}/RPMS/${arch}/${fullname} ${archive}/${arch}/${fullname}
316+
cp ${BUILD_ROOT}/${package_name}/RPMS/${arch}/${fullname} ${archive}/${arch}/${fullname}
292317

293-
rm -rf /tmp/${REPO_NAME}
294-
shift
295-
REPO_NAME=$1
296-
cd ${PKG_ROOT}
318+
rm -rf /tmp/${REPO_NAME}
319+
shift
320+
REPO_NAME=$1
321+
cd ${PKG_ROOT}
297322
done
298323
exit 0

plugins/packages/RPM/SPECS/plugin.spec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Group: IOT
1111
URL: http://www.dianomic.com
1212
VCS: __VCS__
1313

14-
%define install_path /usr/local
15-
1614
Prefix: /usr/local
1715
Requires: __REQUIRES__
1816
AutoReqProv: no

0 commit comments

Comments
 (0)