浏览代码

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 年之前
父节点
当前提交
8a7d1d97c0

+ 1 - 0
doc/changelog.txt

@@ -18,6 +18,7 @@
   * Added "gentoo=xkms" boot parameter for forcing X modesetting driver
   * Added "gentoo=xkms" boot parameter for forcing X modesetting driver
   * More robust Xorg autoconfiguration with sequential fallbacks
   * More robust Xorg autoconfiguration with sequential fallbacks
   * Added ASCII virtual keyboard table for OTFE password entry
   * Added ASCII virtual keyboard table for OTFE password entry
+  * Added preformatted man pages
 
 
   * Replaced Epiphany with Firefox
   * Replaced Epiphany with Firefox
   * Added proxychains, a heterogeneous chaining proxyfier
   * 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
 # Supported combinations: /usr/share/i18n/SUPPORTED
 # "locale-gen" rebuilds the locales into /usr/lib/locale/locale-archive
 # "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_US.UTF-8 UTF-8
+en_GB.UTF-8 UTF-8
 en_CA.UTF-8 UTF-8
 en_CA.UTF-8 UTF-8
 en_AU.UTF-8 UTF-8
 en_AU.UTF-8 UTF-8
 en_NZ.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
 NOCACHE
 
 
-# Useful paths
-TROFF		/usr/bin/groff -KUTF-8 -Tps -mandoc
+# Normal invocation
 NROFF		GROFF_ENCODING=UTF-8 /usr/bin/nroff -mandoc
 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
 EQN		/usr/bin/geqn -Tps
-NEQN		/usr/bin/geqn -Tlatin1
+
+# Japanese
+JNROFF		/usr/bin/groff -KUTF-8 -Tnippon -mandocj
 JNEQN		/usr/bin/geqn -Tnippon
 JNEQN		/usr/bin/geqn -Tnippon
+
+# MANROFFSEQ=t (default), r, p
 TBL		/usr/bin/gtbl
 TBL		/usr/bin/gtbl
-# COL		/usr/bin/col
 REFER		/usr/bin/refer
 REFER		/usr/bin/refer
 PIC		/usr/bin/pic
 PIC		/usr/bin/pic
+
+# MANROFFSEQ=c (default - disabled), v, g
+# COL		/usr/bin/col
 VGRIND		
 VGRIND		
 GRAP		
 GRAP		
+
 PAGER		/usr/bin/less -isR
 PAGER		/usr/bin/less -isR
 BROWSER		/usr/bin/less -isR
 BROWSER		/usr/bin/less -isR
 HTMLPAGER	/bin/cat
 HTMLPAGER	/bin/cat
@@ -46,9 +55,10 @@ CAT		/bin/cat
 # Comparing pages for "man -a"
 # Comparing pages for "man -a"
 CMP		/usr/bin/cmp -s
 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
 # Default manual sections (and order) to search if -S is not specified
 # and the MANSECT environment variable is not set.
 # 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
 # Middle-eastern: Arabic, Hebrew
 # African:        Amharic
 # 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"
 # 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"
 LINGUAS="en ru"
 
 
 # GRUB EFI
 # GRUB EFI
@@ -61,6 +61,9 @@ KBUILD_OUTPUT=/usr/src/linux-main
 # Don't create a dedicated games user (owning /usr/games)
 # Don't create a dedicated games user (owning /usr/games)
 GAMES_USER_DED=root
 GAMES_USER_DED=root
 
 
+# Don't compress man pages (pointless with SquashFS)
+PORTAGE_COMPRESS=""
+
 # Miscellaneous options
 # Miscellaneous options
 EMERGE_LOG_DIR="/var/log/portage"
 EMERGE_LOG_DIR="/var/log/portage"
 PORT_LOGDIR="/var/log/portage"
 PORT_LOGDIR="/var/log/portage"

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

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

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

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

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

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

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

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

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

@@ -30,6 +30,9 @@
 /usr/bin/readcd
 /usr/bin/readcd
 /usr/sbin/rscsi
 /usr/sbin/rscsi
 
 
+# man does not use cache
+/usr/bin/man
+
 # POSIX.1e capabilities
 # POSIX.1e capabilities
 /sbin/unix_chkpwd cap_dac_read_search+ep
 /sbin/unix_chkpwd cap_dac_read_search+ep
 /bin/ping         cap_net_raw+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"
 sinfo "Pruning the temporary copy"
+chattr -f -a ${live}/tmp/.private || :
 rsync -aHAXS -x -i --delete-excluded        \
 rsync -aHAXS -x -i --delete-excluded        \
     --include-from=${rootfspfx}.includes    \
     --include-from=${rootfspfx}.includes    \
     --exclude-from=${rootfspfx}.excludes    \
     --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
 # [debianutils]          ca-certificates:  update-ca-certificates
 ${helpdir}/flt-ebuild app-misc/ca-certificates '\<sys-apps/debianutils\>'
 ${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"
 sinfo "Unmerging build and temporary dependencies"
 mv /etc/portage/profile/packages{.off,}
 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 {} \;
     -exec gtk-update-icon-cache -q -f -i -t {} \;
 
 
 
 
+sinfo "Trimming man pages cache"
+${helpdir}/gen-man-cache clean
+
+
 sinfo "Regenerating fonts cache"
 sinfo "Regenerating fonts cache"
 fc-cache -fs
 fc-cache -fs