diff --git a/make_packages.sh b/make_packages.sh index a357b3499..a413a9d4a 100755 --- a/make_packages.sh +++ b/make_packages.sh @@ -41,40 +41,40 @@ if [ "$1" != "only_clean" ] ; then echo "Building DEB package" # Create sources for DEB package python3 setup.py --command-packages=stdeb.command bdist_deb - sudo find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; +# find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; + echo 1 # Adding the files, scripts and permissions - sudo cp -r for_build/etc deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway - sudo cp -r for_build/var deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway - sudo cp -r -a for_build/DEBIAN deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway - sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/ -R - sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/var/ -R - sudo chmod 775 deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst - sudo chmod +x deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/postinst - sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst + cp -r for_build/etc deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway + cp -r for_build/var deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway + cp -r -a for_build/DEBIAN deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway + chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/ -R + chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/var/ -R + chmod 775 deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst + chmod +x deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/postinst + chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst # Bulding Deb package dpkg-deb -b deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/ cp deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway.deb . # Create sources for RPM Package echo 'Building RPM package' - sudo find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; +# find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; python3 setup.py bdist_rpm - sudo find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; +# find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; cp build/bdist.linux-x86_64/rpm/* /home/$CURRENT_USER/rpmbuild/ -r # Adding the file, scripts and permissions cp for_build/etc/systemd/system/thingsboard-gateway.service /home/$CURRENT_USER/rpmbuild/SOURCES/ - sudo find thingsboard_gateway/ -name "*.pyc" -exec rm -f {} \; cp -r thingsboard_gateway/extensions for_build/etc/thingsboard-gateway/ cd for_build/etc/thingsboard-gateway || echo 0 > /dev/null tar -zcvf configs.tar.gz config/* tar -zcvf extensions.tar.gz extensions/* - mv configs.tar.gz ../../../ + mv configs.tar.gz ../../../ -f cd ../../../ rm /home/$CURRENT_USER/rpmbuild/SOURCES/configs.tar.gz cp configs.tar.gz /home/$CURRENT_USER/rpmbuild/SOURCES/ # Bulding RPM Package cp thingsboard-gateway.spec /home/$CURRENT_USER/rpmbuild/SPECS/ rpmbuild -ba thingsboard-gateway.spec - sudo cp /home/$CURRENT_USER/rpmbuild/RPMS/noarch/*.rpm . - sudo mv thingsboard-gateway-$CURRENT_VERSION-1.noarch.rpm python3-thingsboard-gateway.rpm - sudo chown $CURRENT_USER. *.rpm + cp /home/$CURRENT_USER/rpmbuild/RPMS/noarch/*.rpm . + mv thingsboard-gateway-$CURRENT_VERSION-1.noarch.rpm python3-thingsboard-gateway.rpm + chown $CURRENT_USER. *.rpm fi \ No newline at end of file diff --git a/setup.py b/setup.py index 56024c16d..37125573f 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: long_description = f.read() -VERSION = "2.7" +VERSION = "2.8" setup( version=VERSION, diff --git a/thingsboard-gateway.spec b/thingsboard-gateway.spec index 64828339e..d2732df6b 100644 --- a/thingsboard-gateway.spec +++ b/thingsboard-gateway.spec @@ -1,6 +1,6 @@ %define name thingsboard-gateway -%define version 2.7 -%define unmangled_version 2.7 +%define version 2.8 +%define unmangled_version 2.8 %define release 1 Summary: Thingsboard Gateway for IoT devices. @@ -29,27 +29,26 @@ The Thingsboard IoT Gateway is an open-source solution that allows you to integr sudo find $(python3 -c "from thingsboard_gateway import __path__; print(str(__path__[0])+'/extensions')") -name "*.pyc" -exec rm -f {} \; %build -sudo mkdir -p $RPM_BUILD_ROOT/etc/thingsboard-gateway || echo "ThingsBoard config folder already exists" -sudo mkdir -p $RPM_BUILD_ROOT/var/lib/thingsboard_gateway || echo "ThingsBoard user home directory already exists" -sudo mkdir -p $RPM_BUILD_ROOT/var/lib/thingsboard_gateway/extensions || echo 0 > /dev/null -sudo mkdir -p $RPM_BUILD_ROOT/var/log/thingsboard-gateway || echo "ThingsBoard log directory already exists" +mkdir -p $RPM_BUILD_ROOT/etc/thingsboard-gateway || echo "ThingsBoard config folder already exists" +mkdir -p $RPM_BUILD_ROOT/var/lib/thingsboard_gateway || echo "ThingsBoard user home directory already exists" +mkdir -p $RPM_BUILD_ROOT/var/lib/thingsboard_gateway/extensions || echo 0 > /dev/null +mkdir -p $RPM_BUILD_ROOT/var/log/thingsboard-gateway || echo "ThingsBoard log directory already exists" sudo chown -R thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/log/thingsboard-gateway sudo install -p -D -m 644 %{SOURCE0} $RPM_BUILD_ROOT/etc/systemd/system/thingsboard-gateway.service sudo install -p -D -m 755 %{SOURCE1} $RPM_BUILD_ROOT/etc/thingsboard-gateway/ -sudo tar -xvf %{SOURCE1} -C $RPM_BUILD_ROOT/etc/thingsboard-gateway/ +sudo /usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/etc/thingsboard-gateway -R +sudo /usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/log/thingsboard-gateway -R +sudo /usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/lib/thingsboard_gateway -R # sudo find $(python3 -c "from thingsboard_gateway import __path__; print(str(__path__[0])+'/extensions')") \( -iname '*' ! -iname "*.pyc" \) -exec cp {} $RPM_BUILD_ROOT/var/lib/thingsboard_gateway/extensions \; # sudo cp -r $(python3 -c "from thingsboard_gateway import __path__; print(str(__path__[0])+'/extensions')") $RPM_BUILD_ROOT/var/lib/thingsboard_gateway/ -%install -find %{buildroot} -name ".pyc" -delete +# %install +# sudo find %{buildroot} -name ".pyc" -delete %post /usr/bin/sed -i 's/\.\/logs/\/var\/log\/thingsboard-gateway/g' /etc/thingsboard-gateway/config/logs.conf >> /etc/thingsboard-gateway/config/logs.conf /usr/bin/rm -rf $RPM_BUILD_ROOT/etc/thingsboard-gateway/thingsboard-gateway /usr/bin/rm -f $RPM_BUILD_ROOT/etc/thingsboard-gateway/configs.tar.gz -/usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/etc/thingsboard-gateway -R -/usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/log/thingsboard-gateway -R -/usr/bin/chown thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/lib/thingsboard_gateway -R /usr/bin/systemctl enable thingsboard-gateway.service /usr/bin/systemctl start thingsboard-gateway.service @@ -61,11 +60,11 @@ sudo rm -rf $RPM_BUILD_ROOT /etc/thingsboard-gateway/ /var/log/thingsboard-gateway/ /var/lib/thingsboard_gateway/ -%exclude /usr/local/lib/python3.8 +%exclude /usr/local/lib/* %exclude /usr/local/bin/thingsboard-gateway +%exclude /usr/local/bin/tb-gateway-configurator %defattr(-,thingsboard_gateway,thingsboard_gateway) - %postun systemctl stop thingsboard-gateway userdel thingsboard_gateway