dev-lang/php: call `eselect php cleanup` in pkg_postinst and pkg_postrm.
authorMichael Orlitzky <mjo@gentoo.org>
Thu, 28 Jan 2016 01:30:26 +0000 (20:30 -0500)
committerMichael Orlitzky <mjo@gentoo.org>
Thu, 28 Jan 2016 14:45:37 +0000 (09:45 -0500)
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

dev-lang/php/php-5.6.17-r4.ebuild [moved from dev-lang/php/php-5.6.17-r3.ebuild with 96% similarity]
dev-lang/php/php-7.0.2-r4.ebuild [moved from dev-lang/php/php-7.0.2-r3.ebuild with 96% similarity]

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 7d9db68573e19de3fd9a47f86f09dda02480067a..4180cd623ef39d4f120ed76d588c0e95dfb4a924 100644 (file)
@@ -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
 }
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 8d8f27cbf89a47664033f2fd92d0500f54e91463..e30254fd950b24f50f4344d6c614f5c191118e4e 100644 (file)
@@ -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
 }