Subject: [alpine-user] can't open a specific manual if there are multiple almost identical fnames

From: Svyatoslav Mishyn <[email-masked]>
Date: Fri, 2 Feb 2018 17:22:33 +0200

Hi,

just noticed by accident that cannot open in Alpine Linux some manuals
e.g. scandir(3).

I've installed 'man-pages' package which contains for some manuals two
versions: POSIX and Linux
(e.g.
https://pkgs.alpinelinux.org/contents?file=scandir.*&path=&name=man-pages&branch=edge&arch=x86_64 )
and installs them into the same subdir.

Then checked mandocdb that scandir(3) is there (also why are there
double slashes?).
/home/juef: sudo /usr/sbin/makewhatis -D -a -T utf8 /usr/share/man 2>&1 | grep scandir
/usr/share/man//man3/scandir.3.gz: Adding to database
/usr/share/man//man3/scandir.3p: Adding to database

(I've slightly modified mandoc (against CVS HEAD) to see a bit more.)

/home/juef/cvs/mandoc: ./man 3 scandir
sec: /usr/share/man/man3/scandir.3p
prio: 5; sec: 3/scandir.3p
resp->file: /usr/share/man/man3/scandir.3p
sec: /usr/share/man/man3/scandir.3.gz
prio: 5; sec: 3/scandir.3.gz
sec: /usr/share/man/man3/alphasort.3p
prio: 5; sec: 3/alphasort.3p

and

/home/juef/cvs/mandoc: ./man 3p scandir
sec: /usr/share/man/man3/scandir.3p
prio: 5; sec: 3/scandir.3p
resp->file: /usr/share/man/man3/scandir.3p
sec: /usr/share/man/man3/alphasort.3p
prio: 5; sec: 3/alphasort.3p

So, mandoc in that case always opens /usr/share/man/man3/scandir.3p
regardless of the section option.

Should mandoc handle such case?
Or should 'man-pages' package be fixed
(i.e. install POSIX manuals in man[0-3]p subdirs, by removing this block:
https://git.alpinelinux.org/cgit/aports/tree/main/man-pages/APKBUILD?id=eb6c8019412e3e5dbcb4112b33f4f89a8ec73dcb#n19
) ?

++ (just an experiment)
# pwd
/usr/share/man
# mkdir mann
# mv man3/scandir.3.gz mann
# /usr/sbin/makewhatis -D -a -T utf8 /usr/share/man

now, `man n scandir`, opens /usr/share/man/mann/scandir.3.gz
So, doesn't mandoc look at the file extention to determine its section?

BTW, POSIX manuals are not gzipped, see for example 3p section:
https://pkgs.alpinelinux.org/contents?file=*.3p&path=&name=man-pages&branch=edge&arch=x86_64

Also, is it possible to not apply less-specific patch if the less[1],
or less-fork[2] was installed beforehand?
https://git.alpinelinux.org/cgit/aports/tree/main/mdocml/pager.patch?id=ae43f02b3cdfb0f944bf352fa81911324ec594fb#n16

+++ Is there a possibility in apk to make a local search
by the file names for all packages including not installed?
Similar what web-interface[3] can do or CRUX's prt-get[4].

[1]: http://www.greenwoodsoftware.com/less/
[2]: https://github.com/gdamore/less-fork
[3]: https://pkgs.alpinelinux.org/contents
[4]: https://crux.nu/doc/prt-get%20-%20User%20Manual.html#info_fsearch

Thanks.

-- 
https://www.juef.space/
? Makefile.local
? config.h
? config.log
? configure.local
? demandoc
? mandoc
? soelim
Index: main.c
===================================================================
RCS file: /cvs/mandoc/main.c,v
retrieving revision 1.302
diff -u -r1.302 main.c
--- main.c	21 Aug 2017 15:42:58 -0000	1.302
+++ main.c	2 Feb 2018 15:18:18 -0000
@@ -412,16 +412,19 @@
 			else if (outmode == OUTMODE_ONE) {
 				/* Search for the best section. */
 				sec = res[i].file;
+				fprintf(stderr, "sec: %s\n", sec);
 				sec += strcspn(sec, "123456789");
 				if (sec[0] == '\0')
 					continue;
 				prio = sec_prios[sec[0] - '1'];
+				fprintf(stderr, "prio: %d; sec: %s\n", prio, sec);
 				if (sec[1] != '/')
 					prio += 10;
 				if (prio >= best_prio)
 					continue;
 				best_prio = prio;
 				resp = res + i;
+				fprintf(stderr, "resp->file: %s\n", resp->file);
 			}
 		}

---

From: Cág <[email-masked]>
Date: Fri, 02 Feb 2018 19:43:56 +0000

Svyatoslav Mishyn wrote:

> just noticed by accident that cannot open in Alpine Linux some
> manuals e.g. scandir(3).

Probably yes. man-db has the "-e" option for "extension". Anyway, if
you need a specific manual page you can use "mandoc -l
/usr/share/man/man3/scandir.3.gz".

> Or should 'man-pages' package be fixed
[...]
> So, doesn't mandoc look at the file extention to determine its

I made a man3p directory in /usr/share/man, then put scandir.3p there,
now "man scandir" opens the Linux manual page, "man 3p scandir" opens
the alphasort(3p) manual page.

The project itself becomes a mess on Alpine. You have manuals for POSIX
commands, and may suppose that they are for Busybox commands, that
occasionally don't comply with POSIX; unfortunately Busybox doesn't
have its own man pages. You have manuals for glibc functions that
are absent in musl. So, for stuff like kernel headers and system calls
I'm all for having a package.

> Similar what web-interface[3] can do or CRUX's prt-get[4].

Currently you can't search or view contents of an uninstalled package.
This is a nice feature to have though.
--
caóc

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Svyatoslav Mishyn <[email-masked]>
Date: Sat, 3 Feb 2018 13:33:35 +0200

> I'm all for having a package.

I have from time to time a desire to combine POSIX, Linux manuals +
manuals from OpenBSD, DragonflyBSD (maybe other OSes) all together,
merge them, clean up, and provide clean & beautiful manual pages for
Linux kernel and libc (probably musl-only?).

But the most tricky part, I think, would be licensing.
As maybe each manual will contain various licenses inside it.

-- 
https://www.juef.space/

---

From: William Pitcock <[email-masked]>
Date: Fri, 2 Feb 2018 14:27:43 -0600

Hello,

> Similar what web-interface[3] can do or CRUX's prt-get[4].

There is https://github.com/jessfraz/apk-file for now, but filelists
are a planned feature for apk-tools (probably 2.11 or 2.12 cycle).

William

---

---

From: Svyatoslav Mishyn <[email-masked]>
Date: Sat, 3 Feb 2018 12:54:20 +0200

> are a planned feature for apk-tools (probably 2.11 or 2.12 cycle).

Thanks, probably would be useful if there was some API (JSON?) for retrieving
file info from pkgs.alpinelinux.org/contents, as right now apk-file
simply parses HTML.

But, I suppose, when apk-tools will support it, API wouldn't be
interested and needed at all.

-- 
https://www.juef.space/