[MacPorts] #61288: Manpage symlink to symlink doesn't get recreated to compressed version
MacPorts
noreply at macports.org
Thu Oct 8 07:12:50 UTC 2020
#61288: Manpage symlink to symlink doesn't get recreated to compressed version
-----------------------------+------------------------
Reporter: ballapete | Owner: ryandesign
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: base | Version: 2.6.3
Resolution: | Keywords:
Port: graphviz-devel |
-----------------------------+------------------------
Comment (by ryandesign):
MacPorts uses a two-pass process to compress manpages. First, it traverses
the man directory, (re)compressing any manpage files it finds, and adding
any symlinks to a list. In the second pass, it processes each symlink from
the list. If the symlink destination is not a .gz file, it checks whether
the destination plus the .gz suffix exists. If so, it deletes the symlink
and makes a new one pointing to the .gz file, and adds a .gz suffix to the
name of the symlink as well if it didn't have one.
The problem arises when a chain of symlinks is used, depending on the
order in which the symlinks are processed, which is whatever order
`readdir` returns them in. Assuming that order is alphabetical, then in
the case of graphviz, dot2gxl.1 is processed first. Its destination is
gv2gxl.1, which is also a symlink but MacPorts doesn't check that. It
checks if gv2gxl.1.gz exists, which at this point it does not, so it
doesn't change dot2gxl.1. Later it processes gv2gxl.1 which points to
gxl2gv.1, which was a real file until MacPorts replaced it with the
compressed gxl2gv.1.gz in the first pass. It checks if gxl2gv.1.gz exists,
which it does, so it deletes gv2gxl.1 and creates gv2gxl.1.gz pointing to
gxl2gv.1.gz, breaking the dot2gxl.1 symlink.
The solution might be to rewrite this as a three-pass process. The first
pass would add all manpage files to one list, and for each symlink would
check if its destination exists and if so add the symlink and its
destination to a second list. The second pass would (re)compress all
manpage files from the first list. The third pass would repoint symlinks
using the second list. By having the first pass only record information
about the state of the directory without changing it, we avoid any
problems of breaking chains of symlinks, regardless what order we're
processing the files.
--
Ticket URL: <https://trac.macports.org/ticket/61288#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list