Skip to content

Commit

Permalink
For release
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Sep 30, 2021
1 parent 758db25 commit 4280541
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
32 changes: 16 additions & 16 deletions make_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 13 additions & 14 deletions thingsboard-gateway.spec
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 4280541

Please sign in to comment.