diff --git a/phpMyAdmin.changes b/phpMyAdmin.changes index d74aadc..0343b9e 100644 --- a/phpMyAdmin.changes +++ b/phpMyAdmin.changes @@ -1,3 +1,26 @@ +------------------------------------------------------------------- +Sun Dec 13 13:06:16 UTC 2020 - Arjen de Korte + +- 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 + +- Package language files in separately + +------------------------------------------------------------------- +Fri Dec 11 13:52:52 UTC 2020 - Arjen de Korte + +- 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 + +- Use system apache rpm macros + ------------------------------------------------------------------- Mon Nov 9 13:22:27 UTC 2020 - ecsos diff --git a/phpMyAdmin.spec b/phpMyAdmin.spec index 547c0ff..aafe53f 100644 --- a/phpMyAdmin.spec +++ b/phpMyAdmin.spec @@ -16,19 +16,13 @@ # -%define apxs %{_sbindir}/apxs2 -%define ap_sysconfdir %(%{apxs} -q SYSCONFDIR) -%define ap_serverroot %(%{apxs} -q PREFIX) -%define ap_docroot_old %{ap_serverroot}/htdocs +%define ap_docroot_old %{apache_serverroot}/htdocs %define ap_docroot %{_datadir} %define ap_tmpdir %{_localstatedir}/cache/%{name} %define pma_config %{_sysconfdir}/%{name}/config.inc.php -%if 0%{?suse_version} -%define ap_usr wwwrun -%define ap_grp www -%else -%define ap_usr nobody -%define ap_grp nogroup +%if !0%{?suse_version} +%define apache_user nobody +%define apache_group nogroup %endif Name: phpMyAdmin Version: 5.0.4 @@ -48,7 +42,7 @@ Source100: %{name}-rpmlintrc Patch0: %{name}-config.patch # Fix-SUSE: auto config for pma storage Patch1: %{name}-pma.patch -BuildRequires: apache2-devel +BuildRequires: apache-rpm-macros BuildRequires: fdupes # Requires: php-bz2 @@ -61,11 +55,11 @@ Requires: php-mbstring Requires: php-mysql Requires: php-openssl Requires: php-session -# FIXME: use proper Requires(pre/post/preun/...) -PreReq: coreutils -PreReq: grep -PreReq: pwgen -PreReq: sed +%if 0%{?is_opensuse} +Requires(post): pwgen +%else +Requires(post): openssl +%endif Recommends: mod_php_any >= 7.4 Recommends: php-curl Recommends: php-zip @@ -106,6 +100,23 @@ Currently phpMyAdmin can: * synchronize two databases residing on the same as well as remote servers (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 %setup -q -n %{name}-%{version}-all-languages ## rpmlint: @@ -151,15 +162,17 @@ sed -i -e "s,@docdir@,%{_docdir}/%{name},g" -e "s,@sysconfdir@,%{_sysconfdir}/%{ # 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} -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 %{SOURCE4} %{buildroot}%{ap_sysconfdir}/conf.d/%{name}.inc +install -D -m0644 %{SOURCE3} %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf +install -D -m0644 %{SOURCE4} %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.inc # fix paths in http config 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 -%fdupes %{buildroot}%{ap_docroot}/%{name}/libraries -%fdupes %{buildroot}%{ap_docroot}/%{name}/themes +%fdupes %{buildroot}%{ap_docroot}/%{name} + +# find language files +%find_lang %{name} --all-name %pre # removing tmp/twig before ap_docroot change @@ -177,15 +190,15 @@ fi %preun if [ $1 -eq 0 ]; then -if [ -d "%{ap_docroot}/%{name}/tmp" ]; then - echo "info: removing %{ap_docroot}/%{name}/tmp for clean uninstall" - rm -rf "%{ap_docroot}/%{name}/tmp" || : -fi -# Now the new tmpdir must also delete. -if [ -d "%{ap_tmpdir}" ]; then - echo "info: removing %{ap_tmpdir} for clean uninstall" - rm -rf "%{ap_tmpdir}" || : -fi + if [ -d "%{ap_docroot}/%{name}/tmp" ]; then + echo "info: removing %{ap_docroot}/%{name}/tmp for clean uninstall" + rm -rf "%{ap_docroot}/%{name}/tmp" || : + fi + # Now the new tmpdir must also delete. + if [ -d "%{ap_tmpdir}" ]; then + echo "info: removing %{ap_tmpdir} for clean uninstall" + rm -rf "%{ap_tmpdir}" || : + fi fi %post @@ -194,56 +207,54 @@ fi # install: 1 # update: 2 # 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 -if [ -x %{_sbindir}/a2enmod ]; then - a2enmod -q version || a2enmod version - # get installed php_version (5 or 7) - # ap_mpm=$(awk '/Server MPM/ {print $3}' <<<$(start_apache2 -V)) - # php_version=$(awk -F[." "] '/cli/ {print $2}' <<< $(php -v)) - 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 +a2enmod -q version || a2enmod version +if start_apache2 -V | grep -q prefork; then + php_version=$(php -r "echo 'php' . PHP_MAJOR_VERSION;") + echo "info: adding ${php_version} to APACHE_MODULES" + a2enmod -q ${php_version} || a2enmod ${php_version} fi # enable phpMyAdmin flag -if [ -x %{_sbindir}/a2enflag ]; then - flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*") - if [ $flag_find -eq 0 ]; then - echo "info: adding %{name} to APACHE_SERVER_FLAGS" - a2enflag %{name} - fi +flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*") +if [ $flag_find -eq 0 ]; then + echo "info: adding %{name} to APACHE_SERVER_FLAGS" + a2enflag %{name} fi # 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 # Hence we backup the existing and place the new one 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 -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}" -cp -a %{ap_sysconfdir}/conf.d/%{name}.conf %{ap_sysconfdir}/conf.d/%{name}.conf.backup-${ap_date} -echo "copying %{ap_sysconfdir}/conf.d/%{name}.conf.rpmnew to %{ap_sysconfdir}/conf.d/%{name}.conf" -cp -a %{ap_sysconfdir}/conf.d/%{name}.conf.rpmnew %{ap_sysconfdir}/conf.d/%{name}.conf + ap_date="$(date '+%Y%m%d-%H%M')" + echo "creating backup of %{apache_sysconfdir}/conf.d/%{name}.conf to %{apache_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 %{apache_sysconfdir}/conf.d/%{name}.conf.rpmnew to %{apache_sysconfdir}/conf.d/%{name}.conf" + cp -a %{apache_sysconfdir}/conf.d/%{name}.conf.rpmnew %{apache_sysconfdir}/conf.d/%{name}.conf fi -%restart_on_update apache2 -#systemctl try-restart apache2 &>/dev/null -%postun +%postun apache # only do on uninstall, not on update if [ $1 -eq 0 ]; then -# disable phpMyAdmin flag -if [ -x %{_sbindir}/a2enflag ]; then + # disable phpMyAdmin flag flag_find=$(grep -cw /etc/sysconfig/apache2 -e "^APACHE_SERVER_FLAGS=.*%{name}.*") if [ $flag_find -eq 1 ]; then echo "info: removing %{name} from APACHE_SERVER_FLAGS" a2enflag -d %{name} fi fi -fi -%restart_on_update apache2 -#systemctl try-restart apache2 &>/dev/null +%apache_request_restart + +%posttrans apache +# restart apache instances after zypper or rpm transaction, if not have restarted already +%apache_restart_if_needed %files -f FILELIST %defattr(644,root,root,755) @@ -251,12 +262,18 @@ fi %license LICENSE %doc README RELEASE-DATE* %doc examples doc sql -%dir %attr(0750,root,%{ap_grp}) %{_sysconfdir}/%{name} -%dir %attr(0770,root,www) %{ap_tmpdir} +%dir %attr(0750,root,%{apache_group}) %{_sysconfdir}/%{name} +%dir %attr(0770,root,%{apache_group}) %{ap_tmpdir} %config(noreplace) %{_sysconfdir}/%{name}/config.inc.php %dir %{ap_docroot}/%{name} -%config(noreplace) %{ap_sysconfdir}/conf.d/%{name}.conf -%config(noreplace) %{ap_sysconfdir}/conf.d/%{name}.inc +%exclude %{ap_docroot}/%{name}/locale/*/LC_MESSAGES/phpmyadmin.mo +%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 +%files apache +%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf +%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.inc + +%files lang -f %{name}.lang + %changelog