[MacPorts] #60557: xmltv reinplaces every file and directory

MacPorts noreply at macports.org
Tue May 26 12:09:02 UTC 2020


#60557: xmltv reinplaces every file and directory
------------------------+------------------------
 Reporter:  ryandesign  |      Owner:  ctreleaven
     Type:  defect      |     Status:  assigned
 Priority:  Normal      |  Milestone:
Component:  ports       |    Version:  2.6.2
 Keywords:  haspatch    |       Port:  xmltv
------------------------+------------------------
 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?

-- 
Ticket URL: <https://trac.macports.org/ticket/60557>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list