forked from pool/phpMyAdmin
Accepting request 855568 from home:adkorte:branches:server:php:applications
- Use %apache_request_restart/%apache_restart_if_needed macros to restart apache in order to prevent unneccessary restarts - Package language files in separately - Put Apache configuration files in separate subpackage - Generate blowfish secret with openssl on non-openSUSE systems as pwgen is not available - Use system apache rpm macros OBS-URL: https://build.opensuse.org/request/show/855568 OBS-URL: https://build.opensuse.org/package/show/server:php:applications/phpMyAdmin?expand=0&rev=362
This commit is contained in:
parent
d5738e9737
commit
6a9f734080
@ -1,3 +1,26 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun Dec 13 13:06:16 UTC 2020 - Arjen de Korte <suse+build@de-korte.org>
|
||||||
|
|
||||||
|
- Use %apache_request_restart/%apache_restart_if_needed macros to restart
|
||||||
|
apache in order to prevent unneccessary restarts
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Dec 11 16:46:30 UTC 2020 - Arjen de Korte <suse+build@de-korte.org>
|
||||||
|
|
||||||
|
- Package language files in separately
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Dec 11 13:52:52 UTC 2020 - Arjen de Korte <suse+build@de-korte.org>
|
||||||
|
|
||||||
|
- Put Apache configuration files in separate subpackage
|
||||||
|
- Generate blowfish secret with openssl on non-openSUSE systems as
|
||||||
|
pwgen is not available
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Dec 10 21:18:42 UTC 2020 - Arjen de Korte <suse+build@de-korte.org>
|
||||||
|
|
||||||
|
- Use system apache rpm macros
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Nov 9 13:22:27 UTC 2020 - ecsos <ecsos@opensuse.org>
|
Mon Nov 9 13:22:27 UTC 2020 - ecsos <ecsos@opensuse.org>
|
||||||
|
|
||||||
|
135
phpMyAdmin.spec
135
phpMyAdmin.spec
@ -16,19 +16,13 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
%define apxs %{_sbindir}/apxs2
|
%define ap_docroot_old %{apache_serverroot}/htdocs
|
||||||
%define ap_sysconfdir %(%{apxs} -q SYSCONFDIR)
|
|
||||||
%define ap_serverroot %(%{apxs} -q PREFIX)
|
|
||||||
%define ap_docroot_old %{ap_serverroot}/htdocs
|
|
||||||
%define ap_docroot %{_datadir}
|
%define ap_docroot %{_datadir}
|
||||||
%define ap_tmpdir %{_localstatedir}/cache/%{name}
|
%define ap_tmpdir %{_localstatedir}/cache/%{name}
|
||||||
%define pma_config %{_sysconfdir}/%{name}/config.inc.php
|
%define pma_config %{_sysconfdir}/%{name}/config.inc.php
|
||||||
%if 0%{?suse_version}
|
%if !0%{?suse_version}
|
||||||
%define ap_usr wwwrun
|
%define apache_user nobody
|
||||||
%define ap_grp www
|
%define apache_group nogroup
|
||||||
%else
|
|
||||||
%define ap_usr nobody
|
|
||||||
%define ap_grp nogroup
|
|
||||||
%endif
|
%endif
|
||||||
Name: phpMyAdmin
|
Name: phpMyAdmin
|
||||||
Version: 5.0.4
|
Version: 5.0.4
|
||||||
@ -48,7 +42,7 @@ Source100: %{name}-rpmlintrc
|
|||||||
Patch0: %{name}-config.patch
|
Patch0: %{name}-config.patch
|
||||||
# Fix-SUSE: auto config for pma storage
|
# Fix-SUSE: auto config for pma storage
|
||||||
Patch1: %{name}-pma.patch
|
Patch1: %{name}-pma.patch
|
||||||
BuildRequires: apache2-devel
|
BuildRequires: apache-rpm-macros
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
#
|
#
|
||||||
Requires: php-bz2
|
Requires: php-bz2
|
||||||
@ -61,11 +55,11 @@ Requires: php-mbstring
|
|||||||
Requires: php-mysql
|
Requires: php-mysql
|
||||||
Requires: php-openssl
|
Requires: php-openssl
|
||||||
Requires: php-session
|
Requires: php-session
|
||||||
# FIXME: use proper Requires(pre/post/preun/...)
|
%if 0%{?is_opensuse}
|
||||||
PreReq: coreutils
|
Requires(post): pwgen
|
||||||
PreReq: grep
|
%else
|
||||||
PreReq: pwgen
|
Requires(post): openssl
|
||||||
PreReq: sed
|
%endif
|
||||||
Recommends: mod_php_any >= 7.4
|
Recommends: mod_php_any >= 7.4
|
||||||
Recommends: php-curl
|
Recommends: php-curl
|
||||||
Recommends: php-zip
|
Recommends: php-zip
|
||||||
@ -106,6 +100,23 @@ Currently phpMyAdmin can:
|
|||||||
* synchronize two databases residing on the same as well as remote servers
|
* synchronize two databases residing on the same as well as remote servers
|
||||||
(see FAQ 9.1)
|
(see FAQ 9.1)
|
||||||
|
|
||||||
|
%package apache
|
||||||
|
Summary: Apache configuration for %{name}
|
||||||
|
Group: Productivity/Networking/Web/Utilities
|
||||||
|
BuildRequires: apache-rpm-macros-control
|
||||||
|
BuildRequires: apache2
|
||||||
|
Requires: apache2
|
||||||
|
Requires(post): %{_sbindir}/a2enmod
|
||||||
|
Requires(post): %{_sbindir}/a2enflag
|
||||||
|
Requires(post): php
|
||||||
|
Requires(postun): %{_sbindir}/a2enflag
|
||||||
|
Supplements: packageand(apache2:%name)
|
||||||
|
|
||||||
|
%description apache
|
||||||
|
This subpackage contains the Apache configuration files
|
||||||
|
|
||||||
|
%lang_package
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}-all-languages
|
%setup -q -n %{name}-%{version}-all-languages
|
||||||
## rpmlint:
|
## rpmlint:
|
||||||
@ -151,15 +162,17 @@ sed -i -e "s,@docdir@,%{_docdir}/%{name},g" -e "s,@sysconfdir@,%{_sysconfdir}/%{
|
|||||||
# generate file list
|
# generate file list
|
||||||
find %{buildroot}%{ap_docroot}/%{name} -mindepth 1 -maxdepth 1 -type d | sed -e "s@$RPM_BUILD_ROOT@@" > FILELIST
|
find %{buildroot}%{ap_docroot}/%{name} -mindepth 1 -maxdepth 1 -type d | sed -e "s@$RPM_BUILD_ROOT@@" > FILELIST
|
||||||
find %{buildroot}%{ap_docroot}/%{name} -maxdepth 1 -type f | grep -v 'config.inc.php' | sed -e "s@$RPM_BUILD_ROOT@@" >> FILELIST
|
find %{buildroot}%{ap_docroot}/%{name} -maxdepth 1 -type f | grep -v 'config.inc.php' | sed -e "s@$RPM_BUILD_ROOT@@" >> FILELIST
|
||||||
install -D -m0644 %{SOURCE3} %{buildroot}%{ap_sysconfdir}/conf.d/%{name}.conf
|
install -D -m0644 %{SOURCE3} %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
|
||||||
install -D -m0644 %{SOURCE4} %{buildroot}%{ap_sysconfdir}/conf.d/%{name}.inc
|
install -D -m0644 %{SOURCE4} %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.inc
|
||||||
# fix paths in http config
|
# fix paths in http config
|
||||||
sed -i -e "s,@ap_docroot@,%{ap_docroot},g" -e "s,@name@,%{name},g" \
|
sed -i -e "s,@ap_docroot@,%{ap_docroot},g" -e "s,@name@,%{name},g" \
|
||||||
-e "s,@docdir@,%{_docdir},g" -e "s,@ap_sysconfdir@,%{ap_sysconfdir},g" -e "s,@ap_tmpdir@,%{ap_tmpdir},g" %{buildroot}%{ap_sysconfdir}/conf.d/%{name}.conf
|
-e "s,@docdir@,%{_docdir},g" -e "s,@ap_sysconfdir@,%{apache_sysconfdir},g" -e "s,@ap_tmpdir@,%{ap_tmpdir},g" %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
|
||||||
|
|
||||||
# rpmlint stuff
|
# rpmlint stuff
|
||||||
%fdupes %{buildroot}%{ap_docroot}/%{name}/libraries
|
%fdupes %{buildroot}%{ap_docroot}/%{name}
|
||||||
%fdupes %{buildroot}%{ap_docroot}/%{name}/themes
|
|
||||||
|
# find language files
|
||||||
|
%find_lang %{name} --all-name
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
# removing tmp/twig before ap_docroot change
|
# removing tmp/twig before ap_docroot change
|
||||||
@ -177,15 +190,15 @@ fi
|
|||||||
|
|
||||||
%preun
|
%preun
|
||||||
if [ $1 -eq 0 ]; then
|
if [ $1 -eq 0 ]; then
|
||||||
if [ -d "%{ap_docroot}/%{name}/tmp" ]; then
|
if [ -d "%{ap_docroot}/%{name}/tmp" ]; then
|
||||||
echo "info: removing %{ap_docroot}/%{name}/tmp for clean uninstall"
|
echo "info: removing %{ap_docroot}/%{name}/tmp for clean uninstall"
|
||||||
rm -rf "%{ap_docroot}/%{name}/tmp" || :
|
rm -rf "%{ap_docroot}/%{name}/tmp" || :
|
||||||
fi
|
fi
|
||||||
# Now the new tmpdir must also delete.
|
# Now the new tmpdir must also delete.
|
||||||
if [ -d "%{ap_tmpdir}" ]; then
|
if [ -d "%{ap_tmpdir}" ]; then
|
||||||
echo "info: removing %{ap_tmpdir} for clean uninstall"
|
echo "info: removing %{ap_tmpdir} for clean uninstall"
|
||||||
rm -rf "%{ap_tmpdir}" || :
|
rm -rf "%{ap_tmpdir}" || :
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%post
|
%post
|
||||||
@ -194,56 +207,54 @@ fi
|
|||||||
# install: 1
|
# install: 1
|
||||||
# update: 2
|
# update: 2
|
||||||
# set PmaAbsoluteUri ### generate blowfish secret
|
# set PmaAbsoluteUri ### generate blowfish secret
|
||||||
sed -i -e "s/\\\$cfg\['blowfish_secret'\] = ''/\$cfg['blowfish_secret'] = '`pwgen -s -1 46`'/" %{pma_config}
|
%if 0%{?is_opensuse}
|
||||||
|
sed -i -e "s|^\(\$cfg\['blowfish_secret'\] = '\)\(';\).*|\1$(pwgen -s -1 46)\2|" %{pma_config}
|
||||||
|
%else
|
||||||
|
sed -i -e "s|^\(\$cfg\['blowfish_secret'\] = '\)\(';\).*|\1$(openssl rand -base64 32)\2|" %{pma_config}
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%post apache
|
||||||
# enable required apache modules
|
# enable required apache modules
|
||||||
if [ -x %{_sbindir}/a2enmod ]; then
|
a2enmod -q version || a2enmod version
|
||||||
a2enmod -q version || a2enmod version
|
if start_apache2 -V | grep -q prefork; then
|
||||||
# get installed php_version (5 or 7)
|
php_version=$(php -r "echo 'php' . PHP_MAJOR_VERSION;")
|
||||||
# ap_mpm=$(awk '/Server MPM/ {print $3}' <<<$(start_apache2 -V))
|
echo "info: adding ${php_version} to APACHE_MODULES"
|
||||||
# php_version=$(awk -F[." "] '/cli/ {print $2}' <<< $(php -v))
|
a2enmod -q ${php_version} || a2enmod ${php_version}
|
||||||
php_version=$(php -v | sed -n 's/^PHP\ \([[:digit:]]\+\)\..*$/\1/p')
|
|
||||||
if [[ -n ${php_version} ]] && start_apache2 -V | grep -q prefork; then
|
|
||||||
echo "info: adding php${php_version} to APACHE_MODULES"
|
|
||||||
a2enmod -q "php${php_version}" || a2enmod "php${php_version}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
# enable phpMyAdmin flag
|
# enable phpMyAdmin flag
|
||||||
if [ -x %{_sbindir}/a2enflag ]; then
|
flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*")
|
||||||
flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*")
|
if [ $flag_find -eq 0 ]; then
|
||||||
if [ $flag_find -eq 0 ]; then
|
|
||||||
echo "info: adding %{name} to APACHE_SERVER_FLAGS"
|
echo "info: adding %{name} to APACHE_SERVER_FLAGS"
|
||||||
a2enflag %{name}
|
a2enflag %{name}
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
# We changed ap_docroot from %%{ap_docroot_old} to %%{ap_docroot} (/srv/www/htdocs to /usr/share)
|
# We changed ap_docroot from %%{ap_docroot_old} to %%{ap_docroot} (/srv/www/htdocs to /usr/share)
|
||||||
# If someone did 'manually' change the config file it won't be replaced by rpm
|
# If someone did 'manually' change the config file it won't be replaced by rpm
|
||||||
# Hence we backup the existing and place the new one
|
# Hence we backup the existing and place the new one
|
||||||
find=0
|
find=0
|
||||||
find=$(grep -cw %{ap_sysconfdir}/conf.d/%{name}.conf -e "%{ap_docroot_old}/%{name}") || :
|
find=$(grep -cw %{apache_sysconfdir}/conf.d/%{name}.conf -e "%{ap_docroot_old}/%{name}") || :
|
||||||
if [ $find -gt 0 ]; then
|
if [ $find -gt 0 ]; then
|
||||||
ap_date="$(date '+%Y%m%d-%H%M')"
|
ap_date="$(date '+%Y%m%d-%H%M')"
|
||||||
echo "creating backup of %{ap_sysconfdir}/conf.d/%{name}.conf to %{ap_sysconfdir}/conf.d/%{name}.conf.backup-${ap_date}"
|
echo "creating backup of %{apache_sysconfdir}/conf.d/%{name}.conf to %{apache_sysconfdir}/conf.d/%{name}.conf.backup-${ap_date}"
|
||||||
cp -a %{ap_sysconfdir}/conf.d/%{name}.conf %{ap_sysconfdir}/conf.d/%{name}.conf.backup-${ap_date}
|
cp -a %{apache_sysconfdir}/conf.d/%{name}.conf %{apache_sysconfdir}/conf.d/%{name}.conf.backup-${ap_date}
|
||||||
echo "copying %{ap_sysconfdir}/conf.d/%{name}.conf.rpmnew to %{ap_sysconfdir}/conf.d/%{name}.conf"
|
echo "copying %{apache_sysconfdir}/conf.d/%{name}.conf.rpmnew to %{apache_sysconfdir}/conf.d/%{name}.conf"
|
||||||
cp -a %{ap_sysconfdir}/conf.d/%{name}.conf.rpmnew %{ap_sysconfdir}/conf.d/%{name}.conf
|
cp -a %{apache_sysconfdir}/conf.d/%{name}.conf.rpmnew %{apache_sysconfdir}/conf.d/%{name}.conf
|
||||||
fi
|
fi
|
||||||
%restart_on_update apache2
|
|
||||||
#systemctl try-restart apache2 &>/dev/null
|
|
||||||
|
|
||||||
%postun
|
%postun apache
|
||||||
# only do on uninstall, not on update
|
# only do on uninstall, not on update
|
||||||
if [ $1 -eq 0 ]; then
|
if [ $1 -eq 0 ]; then
|
||||||
# disable phpMyAdmin flag
|
# disable phpMyAdmin flag
|
||||||
if [ -x %{_sbindir}/a2enflag ]; then
|
|
||||||
flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*")
|
flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*")
|
||||||
if [ $flag_find -eq 1 ]; then
|
if [ $flag_find -eq 1 ]; then
|
||||||
echo "info: removing %{name} from APACHE_SERVER_FLAGS"
|
echo "info: removing %{name} from APACHE_SERVER_FLAGS"
|
||||||
a2enflag -d %{name}
|
a2enflag -d %{name}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
%apache_request_restart
|
||||||
%restart_on_update apache2
|
|
||||||
#systemctl try-restart apache2 &>/dev/null
|
%posttrans apache
|
||||||
|
# restart apache instances after zypper or rpm transaction, if not have restarted already
|
||||||
|
%apache_restart_if_needed
|
||||||
|
|
||||||
%files -f FILELIST
|
%files -f FILELIST
|
||||||
%defattr(644,root,root,755)
|
%defattr(644,root,root,755)
|
||||||
@ -251,12 +262,18 @@ fi
|
|||||||
%license LICENSE
|
%license LICENSE
|
||||||
%doc README RELEASE-DATE*
|
%doc README RELEASE-DATE*
|
||||||
%doc examples doc sql
|
%doc examples doc sql
|
||||||
%dir %attr(0750,root,%{ap_grp}) %{_sysconfdir}/%{name}
|
%dir %attr(0750,root,%{apache_group}) %{_sysconfdir}/%{name}
|
||||||
%dir %attr(0770,root,www) %{ap_tmpdir}
|
%dir %attr(0770,root,%{apache_group}) %{ap_tmpdir}
|
||||||
%config(noreplace) %{_sysconfdir}/%{name}/config.inc.php
|
%config(noreplace) %{_sysconfdir}/%{name}/config.inc.php
|
||||||
%dir %{ap_docroot}/%{name}
|
%dir %{ap_docroot}/%{name}
|
||||||
%config(noreplace) %{ap_sysconfdir}/conf.d/%{name}.conf
|
%exclude %{ap_docroot}/%{name}/locale/*/LC_MESSAGES/phpmyadmin.mo
|
||||||
%config(noreplace) %{ap_sysconfdir}/conf.d/%{name}.inc
|
%exclude %{ap_docroot}/%{name}/vendor/phpmyadmin/sql-parser/locale/*/LC_MESSAGES/sqlparser.mo
|
||||||
%attr (755,root,root) %{ap_docroot}/%{name}/vendor/phpmyadmin/sql-parser/bin/*-query
|
%attr (755,root,root) %{ap_docroot}/%{name}/vendor/phpmyadmin/sql-parser/bin/*-query
|
||||||
|
|
||||||
|
%files apache
|
||||||
|
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
|
||||||
|
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.inc
|
||||||
|
|
||||||
|
%files lang -f %{name}.lang
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
Loading…
Reference in New Issue
Block a user