Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 664940

Summary: sys-apps/portage: File-directory replacement behavior leaves cruft on the filesystem
Product: Portage Development Reporter: Michał Górny <mgorny>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: major CC: burcheri.massimo+bugs-gentoo, gentoo, qa
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=326685
https://bugs.gentoo.org/show_bug.cgi?id=286895
https://bugs.gentoo.org/show_bug.cgi?id=668560
https://bugs.gentoo.org/show_bug.cgi?id=834600
Whiteboard:
Package list:
Runtime testing required: ---

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-08-31 07:29:26 UTC
* 
 * Installation of a directory is blocked by a file:
 *   '/usr/lib64/gimp/2.0/plug-ins/web-browser'
 * This file will be renamed to a different name:
 *   '/usr/lib64/gimp/2.0/plug-ins/web-browser.backup.0000'
 * 

Portage does not take care of managing/recording the 'backup' appropriately, and therefore anytime this occurs, users are left with a lot of cruft that won't be cleaned up automatically and that requires full manual intervention.  Furthermore, given that PMS specifically forbids doing this, developers aren't warned of the problem in time and ebuilds with such breakage are deployed to a lot of our user systems.

My suggestion would be to detect this kind of file collisions early, and fail hard when they happen.
Comment 1 Zac Medico gentoo-dev 2018-09-01 04:27:34 UTC
(In reply to Michał Górny from comment #0)
> My suggestion would be to detect this kind of file collisions early, and
> fail hard when they happen.

I suppose the natural way to resolve it would be a hard blocker? This could lead to difficult situations if critical system packages are involved, since it might not be practical to uninstall them in advance.

An alternative might be to have some kind of central registry for things that have to be moved for some reason, kind of like portage's preserve-libs registry.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-09-01 05:36:55 UTC
A hard blocker or pkg_preinst() magic, I suppose.
Comment 3 Zac Medico gentoo-dev 2018-09-01 09:21:15 UTC
Maybe something like this for pkg_preinst() magic:

src_install() {
	emake DESTDIR="${D}" install

	# Rename directory in ED, in order to bypass collision
	# protection and handle it manually.
	mv "${ED}/foo/bar"{,.new} || die
}

pkg_preinst() {
	# Remove file in EROOT that the directory collides with.
	rm -f "${EROOT}/foo/bar" || die

	# Following the collision protection check, reverse
	# src_install's rename in ED.
	mv "${ED}/foo/bar"{.new,} || die
}