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?
Created attachment 25140 [details] Ebuild for brokage-1.0
Good point... :-)
*** This bug has been marked as a duplicate of 14983 ***