File pihole-admin-lte.spec of Package pihole-admin-lte

#
# spec file for package pi-hole
#
# Copyright (c) 2020 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/
#

# TODO: auth.php has lighttpd.log as some kind of fallback. This thing needs to be handled somehow. Probably introduce a var to config file for this?
# TODO: dashboard’s ajax queries seems to be blocking somehow. Investigate.
# TODO: api.php?summary is called like all the time. I think there needs to be some sense how often that is queried, as the page may just be running all the time.
# TODO: ask upstream if indentation should be standardised? Now both 4 spaces and tab indentation is used in different files.

%define         web_files_location /srv/www/pihole

Name:           pihole-admin-lte
%define         official_name AdminLTE
Version:        6.5
# %%() replace causes errors like “can't expand %%(...)”. This is due some bug according search engines.
%global         real_version %(echo "%{version}" | sed -r 's/v(.*)/\\1/')
%define         real_nameversion %{official_name}-%{real_version}
Release:        0
Summary:        Pi-hole Dashboard for stats and more
License:        EUPL-1.2
# TODO: check what group would be better
Group:          Productivity/Networking/Other
Url:            https://pi-hole.net/
Source0:        %{official_name}-%{version}.tar.gz
Source1:        nginx.conf
Source2:        lighttpd.conf
Source3:        SUSE.readme
Source5:        php-fpm-www.conf
Source6:        pihole.apparmor
# TODO: contribute patches to upstream
Patch1:         savesettings.php-better-error-handling.patch
Patch4:         FTL.php-socket-error-handling.patch
Patch5:         FTL.php-improve-get-response-ftl.patch
Patch7:         fix_command_execution.patch
Patch9:         buffering_fixes.patch
# Contribution patches ends here.
Patch8:         fix_sudo_commands.patch
%define         php_ver 7
Requires:       user(pihole)
Requires:       php7-openssl
Suggests:       pi-hole
Suggests:       pihole-ftl
BuildRequires: fdupes
BuildRoot:      %{_tmppath}/%{real_nameversion}-build
BuildArch:      noarch

%description
Pi-hole®'s Web interface (based off of AdminLTE) provides a central location to manage your Pi-hole and review the statistics generated by FTLDNS™.

* Easy-to-interpret: simple graphs and beautiful colors make Pi-hole's stats easy to understand
* Responsive: looks great on desktop, tablets, and mobile devices
* Useful: control and configure your Pi-hole with our settings
* Insightful: use the query log, audit log, or long-term stats to gain insight into your networks activity

%package config-nginx
Summary:        Pi-hole AdminLTE configuration files for nginx
Group:          Productivity/Networking/Web/Utilities
Requires:       nginx
Supplements:    packageand(nginx:pihole-admin-lte)
Recommends:     %{name}-config-php-fpm

%description config-nginx
If you want to run Pi-hole AdminLTE via nginx and PHP-FPM, just install this
package to get some easy to understand/adaptable configuration files
that make it easy to setup AdminLTE with Nginx.

%files config-nginx
%defattr(-,root,root)
%dir %{_sysconfdir}/nginx
%dir %{_sysconfdir}/nginx/conf.d
%ghost %config(noreplace) %{_sysconfdir}/nginx/conf.d/adminlte.conf
%config %{_sysconfdir}/nginx/conf.d/adminlte.conf.in

%package config-php-fpm
Summary:   Pi-hole AdminLTE configuration files for PHP-FPM
Group:     Productivity/Networking/Web/Utilities
Requires:  php-fpm
Supplements:    packageand(php-fpm:pihole-admin-lte)

%description config-php-fpm
If you want to run Pi-hole AdminLTE via PHP-FPM, just install this package to get
some easy to understand/adaptable configuration files that make it easy
to run AdminLTE via PHP-FPM.

%files config-php-fpm
%defattr(-,root,root)
%dir %{_sysconfdir}/php7
%dir %{_sysconfdir}/php7/fpm
%dir %{_sysconfdir}/php7/fpm/php-fpm.d
%attr(0775, pihole, pihole) %dir /var/log/pihole/
%config(noreplace) %{_sysconfdir}/php7/fpm/php-fpm.d/%{name}.conf.in

%prep
%setup -q -n %{real_nameversion}
# %%patch -P 1 -p1
# %%patch -P 4 -p1
# %%patch -P 5 -p1
# %%patch -P 7 -p1
# %%patch -P 8 -p1
# %%patch -P 9 -p1

%build
# Nothing to do.

%install

install -Dm644 %{S:3} %{buildroot}/%{_docdir}/%{name}/SUSE.readme

install -dm755 %{buildroot}%{web_files_location}/admin

cp -dpr --no-preserve=ownership %{_builddir}/%{real_nameversion}/* %{buildroot}%{web_files_location}/admin/

rm %{buildroot}%{web_files_location}/admin/CONTRIBUTING.md
rm %{buildroot}%{web_files_location}/admin/README.md
rm %{buildroot}%{web_files_location}/admin/LICENSE

# Nginx configuration
# TODO: like with Moodle, I guess I could generate correct FPM paths here... https://build.opensuse.org/package/view_file/Education/moodle3_8/moodle3_8.spec?expand=1
install -D -m 0644 %{S:1} %{buildroot}%{_sysconfdir}/nginx/conf.d/adminlte.conf.in

# PHP-FPM configuration
install -D -m 0644 %{S:5} %{buildroot}%{_sysconfdir}/php%{php_ver}/fpm/php-fpm.d/%{name}.conf.in
install -dm775 %{buildroot}%{_var}/log/pihole

# SUSE 15-SP4 added a profile for php-fpm.
# Add a file to allow socket usage.
%if 0%{?sle_version} >= 150400
install -D -m 0644 %{S:6} %{buildroot}%{_sysconfdir}/apparmor.d/php-fpm.d/pihole
%endif

# These probably are useless for end user.
rm %{buildroot}%{web_files_location}/admin/scripts/vendor/daterangepicker.min.js.map
rm %{buildroot}%{web_files_location}/admin/scripts/vendor/bootstrap-select.min.js.map
rm %{buildroot}%{web_files_location}/admin/scripts/vendor/bootstrap-toggle.min.js.map
rm %{buildroot}%{web_files_location}/admin/scripts/vendor/chartjs-adapter-moment.min.js.map

%fdupes %buildroot

%files
%defattr(-,root,root,-)

# This one is admin/LICENSE
%license LICENSE
# SUSE.readme
%doc SUSE.readme
%doc README.md
%doc CONTRIBUTING.md

%if 0%{?sle_version} >= 150400
# Adding for convenience.
%dir /etc/apparmor.d
# I don’t want to own this but php-fpm seems not to own it either...
%dir /etc/apparmor.d/php-fpm.d
%{_sysconfdir}/apparmor.d/php-fpm.d/pihole
%endif

# SLE 16.0 seems not to provide /srv/www/.
%if 0%{?suse_version} == 1600
%dir /srv/www
%endif

%dir %{web_files_location}
%dir %{web_files_location}/admin

# TODO: these maybe shouldn’t be installed?
%{web_files_location}/admin/package-lock.json
%{web_files_location}/admin/package.json
%{web_files_location}/admin/composer.json
%{web_files_location}/admin/composer.lock
%{web_files_location}/admin/phpstan.neon.dist

%{web_files_location}/admin/*.php
%dir %{web_files_location}/admin/img
%{web_files_location}/admin/img/boxed-bg.png
%{web_files_location}/admin/img/boxed-bg-dark.png
%{web_files_location}/admin/img/pihole_icon.svg
%dir %{web_files_location}/admin/img/favicons
%{web_files_location}/admin/img/favicons/*.png
%{web_files_location}/admin/img/favicons/*.svg
%{web_files_location}/admin/img/favicons/favicon.ico
%{web_files_location}/admin/img/favicons/manifest.json
%{web_files_location}/admin/img/logo.svg
%dir %{web_files_location}/admin/scripts/pi-hole
%dir %{web_files_location}/admin/scripts/pi-hole/js
%{web_files_location}/admin/scripts/pi-hole/js/*.js
%dir %{web_files_location}/admin/scripts/pi-hole/php
%{web_files_location}/admin/scripts/pi-hole/php/*.php
%dir %{web_files_location}/admin/style
%{web_files_location}/admin/style/pi-hole.css

# TODO: instead of these bundles, probably need to find out a way to install them as separate packages

%dir %{web_files_location}/admin/scripts
%dir %{web_files_location}/admin/scripts/vendor
%{web_files_location}/admin/scripts/vendor/*.js
%license %{web_files_location}/admin/scripts/vendor/LICENSE
%{web_files_location}/admin/scripts/vendor/qrcode.php

%dir %{web_files_location}/admin/style/vendor/font-awesome
%dir %{web_files_location}/admin/style/vendor/font-awesome/js
%{web_files_location}/admin/style/vendor/font-awesome/js/all.min.js

%dir %{web_files_location}/admin/style/themes/
%{web_files_location}/admin/style/themes/default-auto.css
%{web_files_location}/admin/style/themes/default-dark.css
%{web_files_location}/admin/style/themes/default-darker.css
%{web_files_location}/admin/style/themes/default-light.css
%{web_files_location}/admin/style/themes/high-contrast-dark.css
%{web_files_location}/admin/style/themes/high-contrast.css
%{web_files_location}/admin/style/themes/lcars.css
%{web_files_location}/admin/style/themes/lcars-picard.css

%dir %{web_files_location}/admin/style/vendor
%{web_files_location}/admin/style/vendor/AdminLTE.min.css
%{web_files_location}/admin/style/vendor/datatables.min.css
%{web_files_location}/admin/style/vendor/datatables_extensions.min.css
%{web_files_location}/admin/style/vendor/animate.min.css
%license %{web_files_location}/admin/style/vendor/LICENSE
%{web_files_location}/admin/style/vendor/js-warn.css
%{web_files_location}/admin/style/vendor/daterangepicker.min.css

%dir %{web_files_location}/admin/style/vendor/bootstrap
%dir %{web_files_location}/admin/style/vendor/bootstrap/js
%{web_files_location}/admin/style/vendor/bootstrap/js/bootstrap.min.js
%dir %{web_files_location}/admin/style/vendor/bootstrap/css
%{web_files_location}/admin/style/vendor/bootstrap/css/bootstrap.min.css
%{web_files_location}/admin/style/vendor/bootstrap/css/bootstrap.min.css.map
%dir %{web_files_location}/admin/style/vendor/bootstrap/fonts
%{web_files_location}/admin/style/vendor/bootstrap/fonts/glyphicons-halflings-*

%{web_files_location}/admin/style/vendor/bootstrap-select.min.css
%{web_files_location}/admin/style/vendor/bootstrap-toggle.min.css

%dir %{web_files_location}/admin/style/vendor/fonts
%dir %{web_files_location}/admin/style/vendor/fonts/antonio
%{web_files_location}/admin/style/vendor/fonts/antonio/antonio.css
%{web_files_location}/admin/style/vendor/fonts/antonio/antonio-v1-latin-ext_latin-*.woff
%{web_files_location}/admin/style/vendor/fonts/antonio/antonio-v1-latin-ext_latin-*.woff2
%dir %{web_files_location}/admin/style/vendor/fonts/ubuntu-mono
%{web_files_location}/admin/style/vendor/fonts/ubuntu-mono/ubuntu-mono.css
%{web_files_location}/admin/style/vendor/fonts/ubuntu-mono/ubuntu-mono-v10-latin-ext_latin-*.woff
%{web_files_location}/admin/style/vendor/fonts/ubuntu-mono/ubuntu-mono-v10-latin-ext_latin-*.woff2

%{web_files_location}/admin/style/vendor/icheck-bootstrap.min.css
%{web_files_location}/admin/style/vendor/icheck-material.min.css

%{web_files_location}/admin/style/vendor/select2.min.css

%dir %{web_files_location}/admin/style/vendor/SourceSansPro
%{web_files_location}/admin/style/vendor/SourceSansPro/source-sans-pro-*.woff
%{web_files_location}/admin/style/vendor/SourceSansPro/source-sans-pro-*.woff2
%{web_files_location}/admin/style/vendor/SourceSansPro/SourceSansPro.css

%changelog