Эх сурвалжийг харах

Added preformatted man pages

Man pages, including the localized versions, are correctly preformatted
using groff, which is removed from the final image along with the original
man page sources.

Non-localized whatis/apropos summaries are also generated.

Man pages from 0/2/3 sections are removed.
Maxim Kammerer 11 жил өмнө
parent
commit
8a7d1d97c0

+ 1 - 0
doc/changelog.txt

@@ -18,6 +18,7 @@
   * Added "gentoo=xkms" boot parameter for forcing X modesetting driver
   * More robust Xorg autoconfiguration with sequential fallbacks
   * Added ASCII virtual keyboard table for OTFE password entry
+  * Added preformatted man pages
 
   * Replaced Epiphany with Firefox
   * Added proxychains, a heterogeneous chaining proxyfier

+ 2 - 0
src/etc/env.d/99man

@@ -0,0 +1,2 @@
+MANWIDTH=80
+MANPAGER="less -isRL"

+ 3 - 1
src/etc/locale.gen

@@ -4,9 +4,11 @@
 #
 # Supported combinations: /usr/share/i18n/SUPPORTED
 # "locale-gen" rebuilds the locales into /usr/lib/locale/locale-archive
+#
+# "gen-man-cache" uses first matching locale (for e.g., "en", "ru", etc.)
 
-en_GB.UTF-8 UTF-8
 en_US.UTF-8 UTF-8
+en_GB.UTF-8 UTF-8
 en_CA.UTF-8 UTF-8
 en_AU.UTF-8 UTF-8
 en_NZ.UTF-8 UTF-8

+ 18 - 8
src/etc/man.conf

@@ -25,19 +25,28 @@ MANPATH_MAP	/usr/local/sbin		/usr/local/share/man
 #
 NOCACHE
 
-# Useful paths
-TROFF		/usr/bin/groff -KUTF-8 -Tps -mandoc
+# Normal invocation
 NROFF		GROFF_ENCODING=UTF-8 /usr/bin/nroff -mandoc
-JNROFF		/usr/bin/groff -KUTF-8 -Tnippon -mandocj
+NEQN		/usr/bin/geqn -Tutf8
+
+# PostScript (man -t)
+TROFF		/usr/bin/groff -KUTF-8 -Tps -mandoc
 EQN		/usr/bin/geqn -Tps
-NEQN		/usr/bin/geqn -Tlatin1
+
+# Japanese
+JNROFF		/usr/bin/groff -KUTF-8 -Tnippon -mandocj
 JNEQN		/usr/bin/geqn -Tnippon
+
+# MANROFFSEQ=t (default), r, p
 TBL		/usr/bin/gtbl
-# COL		/usr/bin/col
 REFER		/usr/bin/refer
 PIC		/usr/bin/pic
+
+# MANROFFSEQ=c (default - disabled), v, g
+# COL		/usr/bin/col
 VGRIND		
 GRAP		
+
 PAGER		/usr/bin/less -isR
 BROWSER		/usr/bin/less -isR
 HTMLPAGER	/bin/cat
@@ -46,9 +55,10 @@ CAT		/bin/cat
 # Comparing pages for "man -a"
 CMP		/usr/bin/cmp -s
 
-# Compress cat pages
-COMPRESS	/usr/bin/xz
-COMPRESS_EXT	.xz
+# Don't compress cat pages
+# COMPRESS	/usr/bin/xz
+# COMPRESS_EXT	.xz
+COMPRESS
 
 # Default manual sections (and order) to search if -S is not specified
 # and the MANSECT environment variable is not set.

+ 4 - 1
src/etc/portage/make.conf

@@ -49,7 +49,7 @@ VIDEO_CARDS="${VIDEO_CARDS} modesetting nouveau virtualbox qxl"
 # Middle-eastern: Arabic, Hebrew
 # African:        Amharic
 # LINGUAS="en en_GB fr de es eu pt it ru uk hi pa kn gu bn te ta si ml zh ja ko th vi ne ar he am"
-# (see also: /etc/locale.gen, /root/config/rootfs.includes, /root/helpers/gen-locale-menu)
+# (see also: /etc/locale.gen, /root/helpers/{gen-man-cache,gen-locale-menu}, /root/config/rootfs.includes)
 LINGUAS="en ru"
 
 # GRUB EFI
@@ -61,6 +61,9 @@ KBUILD_OUTPUT=/usr/src/linux-main
 # Don't create a dedicated games user (owning /usr/games)
 GAMES_USER_DED=root
 
+# Don't compress man pages (pointless with SquashFS)
+PORTAGE_COMPRESS=""
+
 # Miscellaneous options
 EMERGE_LOG_DIR="/var/log/portage"
 PORT_LOGDIR="/var/log/portage"

+ 0 - 2
src/etc/portage/profile/packages.off

@@ -8,8 +8,6 @@
 -*virtual/os-headers
 -*sys-apps/busybox
 
--*virtual/man
--*sys-apps/man-pages
 -*sys-apps/texinfo
 
 -*sys-apps/elfix

+ 1 - 1
src/root/config/rootfs-cp.excludes

@@ -14,7 +14,7 @@
 /usr/lib/klibc/
 
 # Documentation
-/usr/share/man/**/*.*
+/usr/share/man/man[023]*/
 /usr/share/info/**
 /usr/share/doc/**
 /usr/share/gtk-doc/**

+ 1 - 1
src/root/config/rootfs.excludes

@@ -1,7 +1,6 @@
 # Exclusions: copy -> clean
 
 # Documentation directories
-/usr/share/man/
 /usr/share/info/
 /usr/share/doc/
 /usr/share/help/
@@ -67,6 +66,7 @@
 /usr/share/unimaps/
 /usr/share/keymaps/**
 /usr/share**/locale/*/
+/usr/share**/man/*/
 /usr/share/fc-lang/
 /usr/share/mime/packages/
 /usr/share/themes/*/**

+ 3 - 1
src/root/config/rootfs.includes

@@ -8,9 +8,10 @@
 /usr/lib/GraphicsMagick-[0-9]**.la
 /usr/lib/mpg123/*.la
 
-# Include fontconfig and gstreamer cache
+# Include fontconfig, gstreamer and man pages cache
 /var/cache/fontconfig/***
 /var/cache/gstreamer/***
+/var/cache/man/***
 
 # Pruned directories exceptions
 /usr/bin/rc-config
@@ -24,6 +25,7 @@
 /usr/share**/locale/C/***
 /usr/share**/locale/en*/***
 /usr/share**/locale/ru*/***
+/usr/share**/man/ru*/
 /usr/share/themes/*/index.theme
 /usr/share/themes/*/gtk-*/***
 /usr/share/themes/*/openbox-*/***

+ 3 - 0
src/root/config/rootfs.nosuid

@@ -30,6 +30,9 @@
 /usr/bin/readcd
 /usr/sbin/rscsi
 
+# man does not use cache
+/usr/bin/man
+
 # POSIX.1e capabilities
 /sbin/unix_chkpwd cap_dac_read_search+ep
 /bin/ping         cap_net_raw+ep

+ 70 - 0
src/root/helpers/gen-man-cache

@@ -0,0 +1,70 @@
+#!/bin/sh -e
+
+noroot="sudo -n -u nobody"
+
+locales=/etc/locale.gen
+width=${MANWIDTH:-80}
+
+conf=/etc/man.conf
+man=/usr/share/man
+cache=/var/cache/man
+
+
+# "clean" parameter removes catpages for non-existing man pages
+if [ "$1" = clean ]; then
+    find ${cache} -type f | while read catpage; do
+        manpage=`echo "${catpage}" | sed "s:^${cache}:${man}:; s:/cat\([0-9]\):/man\1:"`
+        if [ ! -e "${manpage}" ]; then
+            rm "${catpage}"
+        fi
+    done
+
+    # Regenerate summaries (does not work for localized man pages)
+    sect=`find ${man} -mindepth 1 -maxdepth 1 -type d -name 'man*' ! -name 'man[023]*' -printf '%P\n' \
+          | sed 's/^man//' | sort | tr '\n' : | sed 's/:$//'`
+    MANSECT="${sect}" makewhatis ${man}
+
+    exit
+fi
+
+linguas=`portageq envvar LINGUAS`
+
+
+# Enable cache usage and clean cache directory
+sed -i 's/^NOCACHE/##&/' ${conf}
+rm -rf ${cache}
+mkdir ${cache}
+
+
+# Generate man catpages for each language in LINGUAS
+for lang in ${linguas}; do
+    # Root language-specific man directory ("en" is a special case)
+    mandir=${man} catdir=${cache}
+    if [ ${lang} != en ]; then
+        mandir=${mandir}/${lang}
+        catdir=${catdir}/${lang}
+        mkdir ${catdir}
+    fi
+
+    # Pick first matching locale (e.g., "en_US.UTF-8")
+    loc=`sed -n "/^${lang}[._]/{s/[[:blank:]].*//p; q}" ${locales}`
+
+    # Go over all section-specific directories
+    for sec in `find ${mandir} -mindepth 1 -maxdepth 1 -type d -name 'man*' ! -name 'man[023]*' -printf '%P\n'`; do
+        sec=${sec#man}
+
+        # Create corresponding catpages directory
+        mkdir ${catdir}/cat${sec}
+
+        # Generate catpages (directly via groff)
+        for page in `find ${mandir}/man${sec} -mindepth 1 -maxdepth 1 ! -type d -printf '%P\n'`; do
+            # soelim must be invoked explicitly for correct localization
+            # echo Compiling ${mandir}/man${sec}/"${page}"
+            cat ${mandir}/man${sec}/"${page}" \
+                | ${noroot} soelim -I${mandir}/man${sec} -I${mandir} -I${man}/man${sec} -I${man} \
+                | ${noroot} GROFF_ENCODING=UTF-8 GROFF_TYPESETTER=utf8 LC_MESSAGES=${loc} LC_CTYPE=${loc} \
+                  groff -mandoc -t -rLL=${width}n -rLT=${width}n \
+                > ${catdir}/cat${sec}/"${page}" 2>/dev/null
+        done
+    done
+done

+ 1 - 0
src/root/mkimage

@@ -33,6 +33,7 @@ fi
 
 
 sinfo "Pruning the temporary copy"
+chattr -f -a ${live}/tmp/.private || :
 rsync -aHAXS -x -i --delete-excluded        \
     --include-from=${rootfspfx}.includes    \
     --exclude-from=${rootfspfx}.excludes    \

+ 11 - 0
src/root/setup-copy

@@ -53,6 +53,13 @@ ${helpdir}/flt-ebuild net-misc/vpnc         '\<dev-lang/perl\>'
 # [debianutils]          ca-certificates:  update-ca-certificates
 ${helpdir}/flt-ebuild app-misc/ca-certificates '\<sys-apps/debianutils\>'
 
+# [groff]                man:  not needed with preformatted pages
+${helpdir}/flt-ebuild sys-apps/man '\<(sys-apps/groff|app-doc/heirloom-doctools)\>'
+
+
+sinfo "Generating man pages cache"
+${helpdir}/gen-man-cache
+
 
 sinfo "Unmerging build and temporary dependencies"
 mv /etc/portage/profile/packages{.off,}
@@ -126,6 +133,10 @@ find /usr/share -mindepth 3 -type d -name hicolor \
     -exec gtk-update-icon-cache -q -f -i -t {} \;
 
 
+sinfo "Trimming man pages cache"
+${helpdir}/gen-man-cache clean
+
+
 sinfo "Regenerating fonts cache"
 fc-cache -fs