Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 40744 - Portage cannot unmerge a package if one of the files contains two consecutive spaces in the filename.
Summary: Portage cannot unmerge a package if one of the files contains two consecutive...
Status: RESOLVED DUPLICATE of bug 14983
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-07 10:43 UTC by Jonathan Hitchcock
Modified: 2005-07-17 13:06 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ebuild for brokage-1.0 (brokage-1.0.ebuild,431 bytes, text/plain)
2004-02-07 10:49 UTC, Jonathan Hitchcock
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Hitchcock 2004-02-07 10:43:03 UTC
I am currently writing a script to clean cruft off a portage system, so I have to parse the CONTENTS files in /var/db/pkg.  I was wondering how to parse each line, and realised that splitting on a space is not sufficient.  It would work for:

obj /usr/include/asm/apicdef.h 42ee0944d3cc232dcaf712517dddcc96 1075918796

But not for a filename with spaces in it, which gets stored as, e.g.:

obj /usr/share/doc/foo/Long name.txt d41d8cd98f00b204e9800998ecf8427e 1076177498

While I was testing this, however, I made a quick package that had files with spaces in their names (can't think of any offhand, really), and perchanced upon a rather nasty bug.

If a filename has two consecutive spaces in it, it gets merged fine.  However, unmerging it (and presumably doing anything else where portage has to examine the CONTENTS file for the package and do something to the files therein) is a problem, because portage seems to split the line on whitespace, and then reconstruct the elements from that split.  In doing so, all whitespace is reduced to one single space.  Presumably this would be a problem if the filename contained a tab, or a newline, or something, too (can you *do* that?).

As a result, it cannot clean up all the files in the package.

I have made an example pseudo-package that demonstrates this.  I will attach the ebuild, put it into your /usr/local/portage (in app-misc, or something), create the digest for it, and emerge it.  It will fetch the source from my site:

$ emerge brokage       
Calculating dependencies ...done!
>>> emerge (1 of 1) app-misc/brokage-1.0 to /
>>> md5 src_uri ;-) brokage-1.0.tar.bz2
>>> Unpacking source...
>>> Unpacking brokage-1.0.tar.bz2 to /var/tmp/portage/brokage-1.0/work
>>> Source unpacked.
nostrip

>>> Install brokage-1.0 into /var/tmp/portage/brokage-1.0/image/ category app-misc
man:
>>> Completed installing into /var/tmp/portage/brokage-1.0/image/
>>> Merging app-misc/brokage-1.0 to /
--- /usr/
--- /usr/share/
>>> /usr/share/foo
>>> /usr/share/stupidly long and  inconsistent  filename
>>> /usr/share/bar baz
 * Caching service dependencies...                                        [ ok ]>>> app-misc/brokage-1.0 merged.

That's great.

Then unmerge it:

# emerge -C brokage

 app-misc/brokage
    selected: 1.0
   protected: none
     omitted: none

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

>>> Waiting 5 seconds before starting...
>>> (Control-C to abort)...
>>> Unmerging in: 5 4 3 2 1 
>>> Unmerging app-misc/brokage-1.0...
No package files given... Grabbing a set.
--- !found obj /usr/share/stupidly long and inconsistent filename
<<<        obj /usr/share/foo
<<<        obj /usr/share/bar baz
--- !empty dir /usr/share
--- !empty dir /usr
 * Caching service dependencies...                                        [ ok ]
 * GNU info directory index is up-to-date.


See, it didn't find the object?

$ ls /usr/share/stup*
/usr/share/stupidly long and  inconsistent  filename

It's still there.

I suggest portage parses the CONTENTS files using a regex?
Comment 1 Jonathan Hitchcock 2004-02-07 10:49:08 UTC
Created attachment 25140 [details]
Ebuild for brokage-1.0
Comment 2 Radek Podgorny 2004-02-07 11:19:03 UTC
Good point... :-)
Comment 3 Marius Mauch (RETIRED) gentoo-dev 2004-02-07 19:12:21 UTC

*** This bug has been marked as a duplicate of 14983 ***