We discussed this in #gentoo-pms the other day but filing a bug so we don't lose track of it, as I don't think we clearly document the requirement (or at least a suggestion if we consider this to be a Portage hack, we can put it in devmanual instead) that pkg_preinst should be idempotent. In bug 899648, I hit a problem with a quickpkg'd app-editors/emacs because its pkg_preinst adjusts the image on initial merge and doesn't expect to be run again. Running quickpkg then creates a binary package *based on the modified image on the system* and pkg_preinst will be run again when the quickpkg-generated binary package is installed. It's unclear if pkg_preinst's requirements should be adjusted or if we should just document better (e.g. devmanual, maybe phrasing adjustment in PMS to call out a pitfall) that pkg_preinst should be idempotent. See also PMS "11.3 The State of the System Between Functions" at https://dev.gentoo.org/~ulm/pms/head/pms.html#section-11.3. So: - Should we allow pkg_preinst to be run more than once in PMS? - Should we document in PMS that pkg_preinst might need special care because of this, and therefore be idempotent?
fwiw nvidia-drivers modifies a "${ED}"/etc file so that it gets the current system's GID for the video group (replaces @VIDEOGID@) However I don't want to install that file with @VIDEOGID@ and sed it /after/ in postinst, plus want it to go through etc-update/dispatch-conf rather than modify live system as users could've done a lot with that file So being idempotent would be rather inconvenient here. For the sake of quickpkg, I can at least ensure it won't fail if ran twice, but the GID won't be updated a 2nd time.
(In reply to Ionen Wolkens from comment #1) > So being idempotent would be rather inconvenient here. For the sake of > quickpkg, I can at least ensure it won't fail if ran twice, but the GID > won't be updated a 2nd time. By that bit, it also does another check with a temporary uninstalled file that will be missing from the quickpkg (and then `rm || die` will fail). Albeit I can just skip this check if the file is missing.
I'd rather keep the spec strict (i.e. the package manager must not run a phase twice), and document this in the devmanual instead. Is there any way to fix quickpkg? Alternatively, indicate in the created binpkg that pkg_preinst and pkg_postinst must not be executed again when installing it?
This also affects call order. PMS says that pkg_preinst must be executed before pkg_postinst, but when installing a quickpackaged binpkg, the effective call order is preinst, postinst, preinst, postinst.