commit:     ef0386227889557b516d86fd395417b20aa5c4a1
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 28 01:30:26 2016 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Thu Jan 28 14:45:37 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef038622

dev-lang/php: call `eselect php cleanup` in pkg_postinst and pkg_postrm.

We have two bugs (432962 and 572436) regarding stale eselect symlinks.

The first issue is that removal of an old slot does not update the
eselect-php symlinks to point to a newer slot. Thus, if a user
upgrades slots and depcleans the old one, his symlinks (and thus PHP)
are left broken until eselect-php is run manually. This is fixed by
running `eselect php cleanup` in pkg_postrm, since removal of the
old slot will trigger a cleanup (which updates the symlink).

The second issue is that disabling a SAPI would leave behind a broken
symlink. For example, if the "cgi" SAPI was once used but the user has
reinstalled PHP with USE="-cgi", then the old eselect-php symlink for
php-cgi would be left behind. This is fixed by running `eselect php
cleanup` in pkg_postinst, since that will be triggered after the
reinstall finishes, at which point the php-cgi symlink will be dead
and thus get removed.

Gentoo-Bug: 432962
Gentoo-Bug: 572436

Package-Manager: portage-2.2.26

 .../{php-5.6.17-r3.ebuild => php-5.6.17-r4.ebuild}  | 21 ++++++++++++++++++---
 .../{php-7.0.2-r3.ebuild => php-7.0.2-r4.ebuild}    | 21 ++++++++++++++++++---
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/dev-lang/php/php-5.6.17-r3.ebuild 
b/dev-lang/php/php-5.6.17-r4.ebuild
similarity index 96%
rename from dev-lang/php/php-5.6.17-r3.ebuild
rename to dev-lang/php/php-5.6.17-r4.ebuild
index 7d9db68..4180cd6 100644
--- a/dev-lang/php/php-5.6.17-r3.ebuild
+++ b/dev-lang/php/php-5.6.17-r4.ebuild
@@ -76,7 +76,7 @@ IUSE="${IUSE} bcmath berkdb bzip2 calendar cdb cjk
        +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
 
 DEPEND="
-       >=app-eselect/eselect-php-0.7.1-r3[apache2?,fpm?]
+       >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
        >=dev-libs/libpcre-8.32[unicode]
        apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
                <www-servers/apache-2.4[threads=] ) )"
@@ -764,6 +764,13 @@ pkg_postinst() {
                fi
        done
 
+       # Remove dead symlinks for SAPIs that were just disabled. For
+       # example, if the user has the cgi SAPI enabled, then he has an
+       # eselect-php symlink for it. If he later reinstalls PHP with
+       # USE="-cgi", that symlink will break. This call to eselect is
+       # supposed to remove that dead link per bug 572436.
+       eselect php cleanup || die
+
        elog "Make sure that PHP_TARGETS in ${EPREFIX}/etc/make.conf includes"
        elog "php${SLOT/./-} in order to compile extensions for the ${SLOT} 
ABI."
        elog
@@ -786,7 +793,15 @@ pkg_postinst() {
        elog
 }
 
-pkg_prerm() {
-       # This returns "1" on success so we can't "|| die" here.
+pkg_postrm() {
+       # This serves two purposes. First, if we have just removed the last
+       # installed version of PHP, then this will remove any dead symlinks
+       # belonging to eselect-php. Second, if a user upgrades slots from
+       # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
+       # his existing symlinks to point to the new 7.0 installation. The
+       # latter is bug 432962.
+       #
+       # Note: the eselect-php package may not be installed at this point,
+       # so we can't die() if this command fails.
        eselect php cleanup
 }

diff --git a/dev-lang/php/php-7.0.2-r3.ebuild b/dev-lang/php/php-7.0.2-r4.ebuild
similarity index 96%
rename from dev-lang/php/php-7.0.2-r3.ebuild
rename to dev-lang/php/php-7.0.2-r4.ebuild
index 8d8f27c..e30254f 100644
--- a/dev-lang/php/php-7.0.2-r3.ebuild
+++ b/dev-lang/php/php-7.0.2-r4.ebuild
@@ -76,7 +76,7 @@ IUSE="${IUSE} bcmath berkdb bzip2 calendar cdb cjk
        +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
 
 DEPEND="
-       >=app-eselect/eselect-php-0.8.2[apache2?,fpm?]
+       >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
        >=dev-libs/libpcre-8.32[unicode]
        apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
                <www-servers/apache-2.4[threads=] ) )"
@@ -756,6 +756,13 @@ pkg_postinst() {
                fi
        done
 
+       # Remove dead symlinks for SAPIs that were just disabled. For
+       # example, if the user has the cgi SAPI enabled, then he has an
+       # eselect-php symlink for it. If he later reinstalls PHP with
+       # USE="-cgi", that symlink will break. This call to eselect is
+       # supposed to remove that dead link per bug 572436.
+       eselect php cleanup || die
+
        elog "Make sure that PHP_TARGETS in ${EPREFIX}/etc/make.conf includes"
        elog "php${SLOT/./-} in order to compile extensions for the ${SLOT} 
ABI."
        elog
@@ -778,7 +785,15 @@ pkg_postinst() {
        elog
 }
 
-pkg_prerm() {
-       # This returns "1" on success so we can't "|| die" here.
+pkg_postrm() {
+       # This serves two purposes. First, if we have just removed the last
+       # installed version of PHP, then this will remove any dead symlinks
+       # belonging to eselect-php. Second, if a user upgrades slots from
+       # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
+       # his existing symlinks to point to the new 7.0 installation. The
+       # latter is bug 432962.
+       #
+       # Note: the eselect-php package may not be installed at this point,
+       # so we can't die() if this command fails.
        eselect php cleanup
 }

Reply via email to