Skip to content

Commit

Permalink
Improvements for package generating
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Jan 3, 2020
1 parent 72f5396 commit 72524f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions make_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fi


CURRENT_USER=$USER
export PYTHONDONTWRITEBYTECODE=1

if [ "$1" != "only_clean" ] ; then
echo "Building DEB package"
Expand Down Expand Up @@ -63,14 +64,14 @@ if [ "$1" != "only_clean" ] ; then
# Adding the file, scripts and permissions
cp for_build/etc/systemd/system/thingsboard-gateway.service /home/$CURRENT_USER/rpmbuild/SOURCES/
# cd for_build/etc/thingsboard-gateway/
cp -r thingsboard_gateway/extensions for_build/etc/thingsboard-gateway/
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/*
# cp -r extensions /home/$CURRENT_USER/rpmbuild/SOURCES/
tar -zcvf extensions.tar.gz extensions/*
mv configs.tar.gz ../../../
mv extensions.tar.gz /home/$CURRENT_USER/rpmbuild/SOURCES/extensions.tar.gz
# mv extensions.tar.gz /home/$CURRENT_USER/rpmbuild/SOURCES/extensions.tar.gz
cd ../../../
rm /home/$CURRENT_USER/rpmbuild/SOURCES/configs.tar.gz
cp configs.tar.gz /home/$CURRENT_USER/rpmbuild/SOURCES/
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'simplejson',
'pyrsistent'
],
download_url='https://github.com/thingsboard/thingsboard-gateway/archive/2.0.tar.gz',
download_url='https://github.com/thingsboard/thingsboard-gateway/archive/2.0.0.1.tar.gz',
entry_points={
'console_scripts': [
'thingsboard-gateway = thingsboard_gateway.tb_gateway:daemon'
Expand Down
18 changes: 11 additions & 7 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.0
%define unmangled_version 2.0
%define version 2.0.0.1
%define unmangled_version 2.0.0.1
%define release 1

Summary: Thingsboard Gateway for IoT devices.
Expand All @@ -25,21 +25,23 @@ The Thingsboard IoT Gateway is an open-source solution that allows you to integr

%pre
/usr/bin/getent passwd thingsboard_gateway || /usr/sbin/useradd -c "ThingsBoard-Gateway Service" -r -U -d /var/lib/thingsboard_gateway thingsboard_gateway && passwd -d thingsboard_gateway
/usr/bin/pip3 install thingsboard-gateway
/usr/bin/pip3 install thingsboard-gateway==%{version}
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"
sudo chown -R thingsboard_gateway:thingsboard_gateway $RPM_BUILD_ROOT/var/log/thingsboard-gateway
# sudo pip3 install 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 find $(python3 -c "from thingsboard_gateway import __path__; print(str(__path__[0])+'/extensions')") -name "*.pyc" -exec rm -f {} \;
# sudo find $(python3 -c "from thingsboard_gateway import __path__; print(str(__path__[0])+'/extensions')") -name '*' -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/
# 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

%post
/usr/bin/sed -i 's/\.\/logs/\/var\/log\/thingsboard-gateway/g' /etc/thingsboard-gateway/config/logs.conf >> /etc/thingsboard-gateway/config/logs.conf
Expand All @@ -59,6 +61,8 @@ sudo rm -rf $RPM_BUILD_ROOT
/etc/thingsboard-gateway/
/var/log/thingsboard-gateway/
/var/lib/thingsboard_gateway/
%exclude /usr/local/lib/python3.7
%exclude /usr/local/bin/thingsboard-gateway
%defattr(-,thingsboard_gateway,thingsboard_gateway)


Expand Down

0 comments on commit 72524f3

Please sign in to comment.