Opened 4 years ago
Closed 4 years ago
#60557 closed defect (fixed)
xmltv reinplaces every file and directory
Reported by: | ryandesign (Ryan Carsten Schmidt) | Owned by: | ctreleaven (Craig Treleaven) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.6.2 |
Keywords: | haspatch | Cc: | |
Port: | xmltv |
Description
The xmltv Portfile contains this code:
post-patch { fs-traverse f ${worksrcpath} { reinplace -locale C -q "s|#!/usr/bin/perl|#!${perl5.bin}|" ${f} } }
fs-traverse
will return every file and directory in the given directory. reinplace
only works on files, not directories. Apparently when told to work on a directory, it experiences an internal error and leaves an empty temporary file behind in the directory, so the above code block will create 62 such empty temporary files throughout the directory structure, one per directory. You should avoid this by checking whether the found item is a file before using reinplace
on it.
reinplace
uses sed
under the hood and sed
is only defined to operate on text files. A text file is defined as ending with a newline. But the above code block will invoke reinplace
on binary files too. Even though no replacements are needed in those files, sed
will modify them to add a newline at the end if one was not already there. Depending on the file format and which program is reading them, the files may now be considered to be corrupted. You should avoid this by invoking reinplace
only on the set of files that need the replacement. Ordinarily I would limit the search to only the applicable file extensions but I see that unfortunately this project contains a bazillion perl scripts most of whose filenames don't have any extension. The best I can think of at the moment is to exclude the known binary extensions.
With that in mind, how about the attached patch?
Attachments (1)
Change History (3)
Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)
Attachment: | xmltv.diff added |
---|
comment:1 Changed 4 years ago by ctreleaven (Craig Treleaven)
Status: | assigned → accepted |
---|
comment:2 Changed 4 years ago by ctreleaven (Craig Treleaven)
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Thanks Ryan. I knew that blind reinplace wasn't a great approach and I appreciate the patch. I will apply it and I also took your suggestion from the mailing list to look at eliminating the call to perl5.setup. That brought up another issue. In destroot, without perl5.setup, the default is 'make install' where it is 'make pure_install' otherwise. Certain files in the distribution (notably under blib/share) were NOT being installed with 'make pure_install. I'm seeking clarification from the xmltv project to ensure that 'make install' is the right way to go.