2009-10-29 12:36:59 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-07-20 07:10:37 +02:00
|
|
|
#Pandora FMS - https://pandorafms.com
|
2009-10-29 12:36:59 +01:00
|
|
|
# ==================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
2009-10-29 12:36:59 +01:00
|
|
|
# Please see http:#pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public License
|
|
|
|
# as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2022-09-30 01:00:20 +02:00
|
|
|
pandora_version="7.0NG.764-220930"
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2010-11-25 23:48:13 +01:00
|
|
|
package_pear=0
|
2010-05-19 18:29:14 +02:00
|
|
|
package_pandora=1
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2010-05-19 18:29:14 +02:00
|
|
|
for param in $@
|
|
|
|
do
|
|
|
|
if [ $param = "-h" -o $param = "--help" ]
|
|
|
|
then
|
|
|
|
echo "For only make packages of pear type +pear"
|
|
|
|
echo "For not make packages of pear type -pear"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $param = "+pear" ]
|
|
|
|
then
|
|
|
|
package_pandora=0
|
|
|
|
fi
|
|
|
|
if [ $param = "-pear" ]
|
|
|
|
then
|
|
|
|
package_pear=0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $package_pandora -eq 1 ]
|
2009-10-29 12:36:59 +01:00
|
|
|
then
|
2010-05-19 18:29:14 +02:00
|
|
|
echo "Test if you have all the needed tools to make the packages."
|
|
|
|
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
|
|
|
if [ $? = 1 ]
|
|
|
|
then
|
2020-01-08 19:45:50 +01:00
|
|
|
if [ "$DPKG_DEB" == "" ]; then
|
|
|
|
echo "No found \"dpkg-deb\" aplication, please install."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ">> Using dockerized version of dpkg-deb: "
|
|
|
|
echo " $DPKG_DEB"
|
|
|
|
# Use dockerized app.
|
|
|
|
USE_DOCKER_APP=1
|
2010-05-19 18:29:14 +02:00
|
|
|
else
|
|
|
|
echo "Found \"dpkg-debs\"."
|
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
fi
|
|
|
|
|
2010-05-19 18:29:14 +02:00
|
|
|
if [ $package_pear -eq 1 ]
|
2009-10-29 12:36:59 +01:00
|
|
|
then
|
2010-05-19 18:29:14 +02:00
|
|
|
whereis dh-make-pear | cut -d":" -f2 | grep dh-make-pear > /dev/null
|
|
|
|
if [ $? = 1 ]
|
|
|
|
then
|
|
|
|
echo " \"dh-make-pear\" aplication not found, please install."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Found \"dh-make-pear\"."
|
|
|
|
fi
|
|
|
|
|
|
|
|
whereis fakeroot | cut -d":" -f2 | grep fakeroot > /dev/null
|
|
|
|
if [ $? = 1 ]
|
|
|
|
then
|
|
|
|
echo " \"fakeroot\" aplication not found, please install."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Found \"fakeroot\"."
|
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2020-01-08 19:45:50 +01:00
|
|
|
whereis dpkg-buildpackage | cut -d":" -f2 | grep dpkg-buildpackage > /dev/null
|
|
|
|
if [ $? = 1 ]
|
|
|
|
then
|
|
|
|
echo " \"dpkg-buildpackage\" aplication not found, please install."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Found \"dpkg-buildpackage\"."
|
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
fi
|
|
|
|
|
2009-11-03 18:15:06 +01:00
|
|
|
cd ..
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2009-11-06 21:05:51 +01:00
|
|
|
echo "Make a \"temp_package\" temporary dir for job."
|
2010-05-19 18:29:14 +02:00
|
|
|
mkdir -p temp_package
|
|
|
|
if [ $package_pandora -eq 1 ]
|
|
|
|
then
|
2022-07-20 07:10:37 +02:00
|
|
|
mkdir -p temp_package/var/www/html/pandora_console
|
|
|
|
mkdir -p temp_package/var/log/pandora
|
2015-11-16 17:29:58 +01:00
|
|
|
mkdir -p temp_package/etc/logrotate.d
|
2022-07-20 07:10:37 +02:00
|
|
|
mkdir -p temp_package/etc/init.d
|
2010-05-19 18:29:14 +02:00
|
|
|
|
|
|
|
echo "Make directory system tree for package."
|
2022-07-20 07:10:37 +02:00
|
|
|
cp -R $(ls | grep -v temp_package | grep -v DEBIAN | grep -v pandorafms.console_$pandora_version.deb) temp_package/var/www/html/pandora_console
|
2010-05-19 18:29:14 +02:00
|
|
|
cp -R DEBIAN temp_package
|
2015-11-16 17:29:58 +01:00
|
|
|
cp -aRf pandora_console_logrotate_ubuntu temp_package/etc/logrotate.d/pandora_console
|
2022-07-20 07:10:37 +02:00
|
|
|
cp -aRf pandora_websocket_engine temp_package/etc/init.d/
|
|
|
|
find temp_package/var/www/html/pandora_console -name ".svn" | xargs rm -Rf
|
|
|
|
rm -Rf temp_package/var/www/html/pandora_console/pandora_console.spec
|
2010-05-20 15:05:34 +02:00
|
|
|
chmod 755 -R temp_package/DEBIAN
|
2010-12-16 17:18:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
echo "Remove the SVN files and other temp files."
|
|
|
|
for item in `find temp_package`
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
echo $item | grep "svn" > /dev/null
|
|
|
|
#last command success
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
rm -rf $item
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $item | grep "make_deb_package.sh" > /dev/null
|
|
|
|
#last command success
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
rm -rf $item
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "END"
|
2010-05-19 18:29:14 +02:00
|
|
|
|
|
|
|
echo "Calculate md5sum for md5sums package control file."
|
2022-07-20 07:10:37 +02:00
|
|
|
FILES=`find temp_package`
|
|
|
|
while read item
|
2010-05-19 18:29:14 +02:00
|
|
|
do
|
|
|
|
echo -n "."
|
2022-07-20 07:10:37 +02:00
|
|
|
if [ ! -d "$item" ]
|
2009-10-29 12:36:59 +01:00
|
|
|
then
|
2022-07-20 07:10:37 +02:00
|
|
|
echo "$item" | grep "DEBIAN" > /dev/null
|
2010-05-19 18:29:14 +02:00
|
|
|
#last command success
|
|
|
|
if [ $? -eq 1 ]
|
|
|
|
then
|
2022-07-20 07:10:37 +02:00
|
|
|
md5=`md5sum "$item" | cut -d" " -f1`
|
2010-05-19 18:29:14 +02:00
|
|
|
|
|
|
|
#delete "temp_package" in the path
|
|
|
|
final_path=${item#temp_package}
|
|
|
|
echo $md5" "$final_path >> temp_package/DEBIAN/md5sums
|
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
fi
|
2022-07-20 07:10:37 +02:00
|
|
|
done < <(echo "$FILES")
|
2010-05-19 18:29:14 +02:00
|
|
|
echo "END"
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2010-05-19 18:29:14 +02:00
|
|
|
echo "Make the package \"Pandorafms console\"."
|
2020-01-08 19:45:50 +01:00
|
|
|
if [ "$USE_DOCKER_APP" == "1" ]; then
|
2022-07-20 07:10:37 +02:00
|
|
|
eval $DPKG_DEB --root-owner-group --build temp_package
|
2020-01-08 19:45:50 +01:00
|
|
|
else
|
2022-07-20 07:10:37 +02:00
|
|
|
dpkg-deb --root-owner-group --build temp_package
|
2020-01-08 19:45:50 +01:00
|
|
|
fi
|
2010-05-20 15:05:34 +02:00
|
|
|
mv temp_package.deb pandorafms.console_$pandora_version.deb
|
2010-05-19 18:29:14 +02:00
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2010-05-19 18:29:14 +02:00
|
|
|
if [ $package_pear -eq 1 ]
|
|
|
|
then
|
|
|
|
echo "Make the package \"php-xml-rpc\"."
|
|
|
|
cd temp_package
|
2019-02-28 17:12:31 +01:00
|
|
|
dh-make-pear --maintainer "ÁRTICA ST <info@artica.es>" XML_RPC
|
2010-05-19 18:29:14 +02:00
|
|
|
cd php-xml-rpc-*
|
|
|
|
dpkg-buildpackage -rfakeroot
|
|
|
|
cd ..
|
|
|
|
mv php-xml-rpc*.deb ..
|
|
|
|
cd ..
|
|
|
|
fi
|
2009-10-29 12:36:59 +01:00
|
|
|
|
2009-11-03 18:15:06 +01:00
|
|
|
|
2009-11-06 21:05:51 +01:00
|
|
|
echo "Delete the \"temp_package\" temporary dir for job."
|
2009-11-10 01:55:12 +01:00
|
|
|
rm -Rf temp_package
|
|
|
|
|
2010-05-20 15:05:34 +02:00
|
|
|
echo "DONE: Package ready at: ../pandorafms.console_$pandora_version.deb"
|