Bug 239686 - sysutils/lsof: Fix broken man page
Summary: sysutils/lsof: Fix broken man page
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Larry Rosenman
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2019-08-07 03:50 UTC by Jamie Landeg-Jones
Modified: 2019-08-23 03:54 UTC (History)
2 users (show)

See Also:
koobs: maintainer-feedback+
koobs: merge-quarterly?


Attachments
patch-Makefile - fix the man page before install (627 bytes, patch)
2019-08-07 03:50 UTC, Jamie Landeg-Jones
no flags Details | Diff
svn-diff-manpage-lsof (476 bytes, patch)
2019-08-07 07:16 UTC, Walter Schwarzenfeld
no flags Details | Diff
svn-diff-manpage-lsof-v2 (477 bytes, patch)
2019-08-07 07:33 UTC, Walter Schwarzenfeld
no flags Details | Diff
svn-diff-manpage-new-patch (6.20 KB, patch)
2019-08-07 15:13 UTC, Walter Schwarzenfeld
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Landeg-Jones 2019-08-07 03:50:27 UTC
Created attachment 206316 [details]
patch-Makefile - fix the man page before install

"man lsof" returns no such man page exists.

The man page does exist, but it uses the ".so" include directive. This directive tries to include additional files, which exist in the stagedir, but not on install.

This patch uses 'mandoc' to pre-process the ".so" directive at build time. It also includes a SED kludge to fix a weird error.

The result of this patch is:

* 04:48 (303) "lsof-4.93.2" root@thompson# sed 's/\\$/\\DUMMY/' Lsof.8 | mandoc -man -T man | sed 's/DUMMY$//' |  diff - Lsof.8
1,2c1
< .ds VN 4.93.2
<
---
> .so ./version
78,82c77
<       Apple Darwin 9 and Mac OS X 10.[567]
<       FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
<       Linux 2.1.72 and above for x86-based systems
<       Solaris 9, 10 and 11
<
---
> .so ./00DIALECTS
4533d4527
<

The patch is attached:

cheers, Jamie
Comment 1 Walter Schwarzenfeld freebsd_triage 2019-08-07 07:16:07 UTC
Created attachment 206321 [details]
svn-diff-manpage-lsof

The patch of Jamie does not work.
Comment 2 Walter Schwarzenfeld freebsd_triage 2019-08-07 07:33:59 UTC
Created attachment 206323 [details]
svn-diff-manpage-lsof-v2

Misses "1" in the REINPLACE_CMD.
Comment 3 Jamie Landeg-Jones 2019-08-07 11:42:19 UTC
Hi. In which way doesn't it work? It works fine for me.

Your solution is better than nothing, but it causes the included bits to be dropped.

cheers
Comment 4 Walter Schwarzenfeld freebsd_triage 2019-08-07 11:52:05 UTC
It produces the original error:
man lsof
No manual entry for lsof
Comment 5 Walter Schwarzenfeld freebsd_triage 2019-08-07 12:26:13 UTC
I don't understand this part
${SED}  's/\\$$/\\DUMMY/'

You try replace \$ with \DUMMY. But there is no \$ in the code.
Comment 6 Jamie Landeg-Jones 2019-08-07 12:38:51 UTC
What version of freebsd are you running? Does it have "mandoc"?

I verified by re-downloading the patch from this attachment and patching against a fresh port checkout. giving:

% l /usr/local/man/man8/lsof.8.gz
40 -r--r--r--  1 root  wheel  - 37,611  7 Aug 12:58 /usr/local/man/man8/lsof.8.gz

I'm using 12-stable

--------- 

The offending line is line 8. The "$" is the RE for end of line, hence the match is for '/' as the last character of a line.

For some reason, the trailing '/' causes the conversion by "mandoc" to get corrupted. Hence the kludge to change it for "dummy", do the conversion, then put it back again.

I don't know if it's the fault of mandoc, or the manpage itself - I am not familiar with mdoc / man / roff formatting.

Hence the kludge.

The before/after diff is shown in my first comment.

Without the sed kludge, this diff is instead:

13:36 (14) "lsof-4.93.2" jamie@thompson%  mandoc -man -T man Lsof.8 | diff - Lsof.8
1,2c1
< .ds VN 4.93.2
<
---
> .so ./version
7c6
< .if !\n(.g \{.   if !\n()P .nr )P 1v
---
> .   if !\n()P .nr )P 1v
78,82c77
<       Apple Darwin 9 and Mac OS X 10.[567]
<       FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
<       Linux 2.1.72 and above for x86-based systems
<       Solaris 9, 10 and 11
<
---
> .so ./00DIALECTS
4533d4527
<

That "if..." line is corrupted, and man terminates at that point, showing an empty man page containing just the header and footer.
Comment 7 Jamie Landeg-Jones 2019-08-07 12:40:15 UTC
Sorry, obviously I mean the match is for '\' as the last character of the line, not '/'
Comment 8 Walter Schwarzenfeld freebsd_triage 2019-08-07 12:42:26 UTC
I have 11.2-amd64. Has mandoc.
Comment 9 Jamie Landeg-Jones 2019-08-07 12:46:47 UTC
What's the file size/datestamp of the file?

% l /usr/local/man/man8/lsof.8.gz
40 -r--r--r--  1 root  wheel  - 37,611  7 Aug 12:58 /usr/local/man/man8/lsof.8.gz
Comment 10 Walter Schwarzenfeld freebsd_triage 2019-08-07 12:52:17 UTC
-r--r--r--  1 root  wheel  37519  7 Aug. 14:49 /usr/local/man/man8/lsof.8.gz
Comment 11 Jamie Landeg-Jones 2019-08-07 13:54:14 UTC
That's the size of the unpatched file, presumably:

SHA256 (/snapshots/weekly/0/usr/local/man/man8/lsof.8.gz) = 5fb2865609d8809861acec482b6d24f76005ab6fcfd925042a41ebc5e0dbcdac

Do you get the command appearing in "make stage" ?

14:53 (14) "lsof" root@thompson# make stage
===>  Staging for lsof-4.93.2_3,8
===>   Generating temporary packing list
install  -s -m 555 /scratch/root/ports_base/usr/ports/sysutils/lsof/work/lsof-4.93.2/lsof /scratch/root/ports_base/usr/ports/sysutils/lsof/work/stage/usr/local/sbin
(cd /scratch/root/ports_base/usr/ports/sysutils/lsof/work/lsof-4.93.2 && /usr/bin/sed 's/\\$/\\DUMMY/' Lsof.8 | mandoc -T man | /usr/bin/sed 's/DUMMY$//' > /scratch/root/ports_base/usr/ports/sysutils/lsof/work/lsof-4.93.2/lsof.8)
install  -m 444 /scratch/root/ports_base/usr/ports/sysutils/lsof/work/lsof-4.93.2/lsof.8 /scratch/root/ports_base/usr/ports/sysutils/lsof/work/stage/usr/local/man/man8/lsof.8
install  -m 555 /scratch/root/ports_base/usr/ports/sysutils/lsof/work/lsof-4.93.2/scripts/* /scratch/root/ports_base/usr/ports/sysutils/lsof/work/stage/usr/local/share/lsof
====> Compressing man pages (compress-man)
Comment 12 Walter Schwarzenfeld freebsd_triage 2019-08-07 14:02:45 UTC
sha256 is irrelevant, I am using portsnap and not svn.

Yes, I see the command, if I "make stage".
Comment 13 Walter Schwarzenfeld freebsd_triage 2019-08-07 15:13:51 UTC
Created attachment 206335 [details]
svn-diff-manpage-new-patch

This should work, I think.
Comment 14 Jamie Landeg-Jones 2019-08-08 00:02:24 UTC
portsnap or svn are not relevant (I use portsnap too) - the sha256 was not of the source files, but the resultant lsof.8.gz file (to show that yours hadn't altered)

... No, your new patch just hardcode-includes the manual page for the old 4.89 version.

I've tested my patch on 12-stable, 11.1, and a freshly installed 11.3 with no changes, and it works - maybe you should investigate why yours doesn't?

#
# uname -a
FreeBSD catmin 11.3-RELEASE FreeBSD 11.3-RELEASE #0 r349754: Fri Jul  5 04:45:24 UTC 2019     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
#
# sed 's/\\$/\\DUMMY/' Lsof.8 | mandoc -man -T man | sed 's/DUMMY$//' |  diff - Lsof.8
1,2c1
< .ds VN 4.93.2
<
---
> .so ./version
78,82c77
<       Apple Darwin 9 and Mac OS X 10.[567]
<       FreeBSD 8.[234], 9.0 and 1[012].0 for AMD64-based systems
<       Linux 2.1.72 and above for x86-based systems
<       Solaris 9, 10 and 11
<
---
> .so ./00DIALECTS
4533d4527
<
Comment 15 Walter Schwarzenfeld freebsd_triage 2019-08-08 00:11:21 UTC
Last try worked with your patch. Don't ask me what changed. Any non-printable character or something else.
Comment 16 Jamie Landeg-Jones 2019-08-08 00:26:10 UTC
Sorry, I didn't mean to sound rude.

It would be useful to see why this doesnt' work for you:

# sed 's/\\$/\\DUMMY/' Lsof.8 | mandoc -man -T man | sed 's/DUMMY$//' |  diff - Lsof.8


as it may affect others too. locale? environment?
Comment 17 Walter Schwarzenfeld freebsd_triage 2019-08-08 00:33:17 UTC
> as it may affect others too. locale? environment?
maybe, I have:

ANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES=C
LC_ALL=
Comment 18 Jamie Landeg-Jones 2019-08-08 01:37:46 UTC
That made no difference for me...

So, to recap, you're saying this produces no output? :

# mandoc  -Tman Lsof.8 |diff - Lsof.8
Comment 19 Walter Schwarzenfeld freebsd_triage 2019-08-08 01:45:28 UTC
I never said.

You patch seemed produce no manpage.
But as I wrote, this is now working.

Let it be. If it was a non-printing character, a paiste thing or a locale thing, you will never find out.
Comment 20 Jamie Landeg-Jones 2019-08-08 01:56:32 UTC
:-) As long as it works now!
Comment 21 commit-hook freebsd_committer 2019-08-10 22:45:07 UTC
A commit references this bug:

Author: ler
Date: Sat Aug 10 22:44:29 UTC 2019
New revision: 508510
URL: https://svnweb.freebsd.org/changeset/ports/508510

Log:
  sysutils/lsof: fix build on -current, fix man page

  - fix build post r350531 [0]
  - fix manpage. [1]

  PR:	239686 [1], 239754 [0]
  Submitted by:	yasu@utahime.org [0], jamie@catflap.org [1]

Changes:
  head/sysutils/lsof/Makefile
  head/sysutils/lsof/files/patch-dialects_freebsd_dsock.c
Comment 22 Larry Rosenman freebsd_committer 2019-08-10 22:45:07 UTC
committed, thanks!
Comment 23 Jamie Landeg-Jones 2019-08-11 18:36:18 UTC
Cheers Larry and Walter!