File iobroker.spec of Package iobroker
#
# spec file for package iobroker
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define iobrokerhome /srv/iobroker
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
Name: iobroker
Version: 3.1.0
Release: 0
Summary: Smarthome Automation
License: MIT
Group: Productivity/Networking/Other
Url: http://iobroker.net
Source0: %{name}-%{version}.tar.gz
Source1: %{name}.sysconfig
Source2: %{name}.service
Source3: %{name}.apache.conf
Source4: %{name}.firewalld
Source5: %{name}.susefirewall
Source90: README.SUSE
Source99: %{name}-rpmlintrc
###Patch0: %%{name}-shebang.patch
BuildRequires: systemd-rpm-macros
BuildRequires: nodejs-packaging
BuildRequires: dos2unix
BuildRequires: pwdutils
BuildRequires: apache2
%if 0%{?suse_version} >= 1500
Buildrequires: firewall-macros
Buildrequires: firewalld
%endif
Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd
Requires(post): %fillup_prereq
Requires: nodejs12
Requires: npm12
Conflicts: iobroker.install_after
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{?nodejs_requires}
%description
ioBroker is an integration platform for the Internet of Things.
Focused on Building Automation, Smart Metering, Ambient Assisted Living,
Process Automation, Visualization and Data Logging.
This installs the necessary ioBroker adapters to start and run ioBroker.
Other adapters can install at runtime in admin adpater.
%prep
%setup -q -c -n %{name}-%{version}
###%%patch0 -p1
install -m644 %{S:90} .
# rpmlintrc
for file in .gitignore .gitmodules .keep .travis.yml .npmignore .eslintrc .eslintignore .jshintrc .jscsrc *.md~ *.bak *.un~ *.orig *.rej *.swp ; do
find . -name $file -delete
done
# find . -type f | xargs dos2unix -ic | xargs dos2unix
for file in LICENSE README.md Makefile *.txt *.dat *.js *.json *.md* *.conf *.sha1 *.css *.xml *.cmd *.node.d *.map *.cpp *.h *.coffee LICENSE-jsbn; do
x=$(find . -type f -name $file -executable)
if [ -n "$x" ] ; then
chmod -x $x
fi
done
# don't need in package
rm -rf node_modules/usb/libusb/INSTALL
rm -rf node_modules/iobroker.js-controller/reinstall.sh
rm -rf install.sh
rm -rf reinstall.sh
rm -rf iobroker.service
#
find . -type f -exec sed -i -e 's|\/usr\/bin\/env python|\/usr\/bin\/python|g' {} \;
find . -type f -exec sed -i -e 's|\/usr\/bin\/env node|\/usr\/bin\/node|g' {} \;
find . -type f -exec sed -i -e 's|\/usr\/bin\/env sh|\/bin\/sh|g' {} \;
find . -type f -exec sed -i -e 's|\/usr\/bin\/env bash|\/bin\/bash|g' {} \;
find . -type f -exec sed -i -e 's|\/usr\/bin\/env perl|\/usr\/bin\/perl|g' {} \;
%build
###npm prune --production
###npm rebuild
%install
# ioBroker
install -d -m 755 %{buildroot}%{iobrokerhome}
cp -a * %{buildroot}%{iobrokerhome}
rm -rf %{buildroot}%{iobrokerhome}/README.SUSE
# sysconfig
install -d -m 755 %{buildroot}%{_fillupdir}
install -D -m 644 %{S:1} %{buildroot}%{_fillupdir}/sysconfig.iobroker
# systemd
install -D -m 644 %{S:2} %{buildroot}%{_unitdir}/iobroker.service
install -d -m 755 %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rciobroker
# apache
install -D -m 644 %{S:3} %{buildroot}%{_sysconfdir}/apache2/conf.d/iobroker.conf
# firwall
%if 0%{?suse_version} >= 1500
# firewalld
install -d %{buildroot}/usr/lib/firewalld/services/
install -D -m 0644 %{S:4} %{buildroot}/usr/lib/firewalld/services/%{name}.xml
%else
# susefirewall
install -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/
install -D -m 644 %{S:5} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/iobroker
%endif
%pre
%service_add_pre iobroker.service
# add user and group
if ! getent group iobroker >/dev/null; then
%{_sbindir}/groupadd -r iobroker
fi
if ! getent passwd iobroker >/dev/null; then
%{_sbindir}/useradd -r -g iobroker -d /srv/iobroker -s /bin/false -c "ioBroker ioT Server" iobroker
# need user iobroker in group dialout for serialport
%{_sbindir}/usermod -a -G dialout iobroker
%{_sbindir}/usermod -p --unlock iobroker
fi
%post
%service_add_post iobroker.service
%{fillup_only -n iobroker}
# generate iobroker-data dir with ground setup
if [ "$1" == 1 ] ; then
echo "Initial iobroker-data..."
###rm -rf %{iobrokerhome}/iobroker-data
cd %{iobrokerhome}
./iobroker setup first
chown -R iobroker:iobroker %{iobrokerhome}/iobroker-data
# disable phone home
echo "Starting iobroker to disable PhoneHome..."
systemctl start iobroker
./iobroker plugin disable sentry
systemctl stop iobroker
echo "Stoping iobroker after disable PhoneHome (sentry plugin) again..."
fi
%preun
%service_del_preun iobroker.service
%postun
%service_del_postun iobroker.service
if [ $1 -eq 0 ]; then
%{_sbindir}/userdel iobroker
%{_sbindir}/groupdel iobroker
rm -rf %{iobrokerhome}
rm -rf %{_sysconfdir}/sysconfig/iobroker
else
true
fi
%files
%defattr(-,root,root)
%doc README.SUSE
%config(noreplace) %{_sysconfdir}/apache2/conf.d/iobroker.conf
%if 0%{?suse_version} >= 1500
%config(noreplace) /usr/lib/firewalld/services/%{name}.xml
%else
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/iobroker
%endif
%{_fillupdir}/sysconfig.iobroker
%{_sbindir}/rciobroker
%{_unitdir}/iobroker.service
%defattr(-,iobroker,iobroker)
%config(noreplace) %{iobrokerhome}/package-lock.json
%config(noreplace) %{iobrokerhome}/package.json
%config(noreplace) %{iobrokerhome}/iobroker-data/iobroker.json
%config(noreplace) %{iobrokerhome}/iobroker-data/objects.json
%config(noreplace) %{iobrokerhome}/iobroker-data/states.json
%{iobrokerhome}
%changelog