]> git.draconx.ca Git - gentoo-fixes.git/blob - sys-apps/man/man-1.6g-r1.ebuild
sys-apps/man: Fix borken Gentoo man-1.6g-echo-escape.patch
[gentoo-fixes.git] / sys-apps / man / man-1.6g-r1.ebuild
1 # Copyright © 2018 Nick Bowler
2 # License GPLv2+: GNU General Public License version 2 or any later version.
3 # This is free software: you are free to change and distribute it.
4 # There is NO WARRANTY, to the extent permitted by law.
5 #
6 # This a modified version of the original ebuild from Gentoo GNU/Linux,
7 # covered by the following copyright and permission notice:
8 #
9 #   Copyright 1999-2018 Gentoo Foundation
10 #   Distributed under the terms of the GNU General Public License v2
11
12 EAPI="6"
13
14 inherit eutils prefix toolchain-funcs user
15
16 DESCRIPTION="Standard commands to read man pages"
17 HOMEPAGE="http://primates.ximian.com/~flucifredi/man/"
18 SRC_URI="http://primates.ximian.com/~flucifredi/man/${P}.tar.gz"
19
20 LICENSE="GPL-2"
21 SLOT="0"
22 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd"
23 IUSE="+lzma nls selinux"
24
25 DEPEND="nls? ( sys-devel/gettext )"
26 RDEPEND="|| ( >=sys-apps/groff-1.19.2-r1 app-doc/heirloom-doctools )
27         !sys-apps/man-db
28         !<app-arch/lzma-4.63
29         lzma? ( app-arch/xz-utils )
30         selinux? ( sec-policy/selinux-makewhatis )"
31
32 pkg_setup() {
33         enewgroup man 15
34         enewuser man 13 -1 /usr/share/man man
35 }
36
37 PATCHES=(
38         "${FILESDIR}"/man-1.6f-man2html-compression-2.patch
39         "${FILESDIR}"/man-1.6-cross-compile.patch
40         "${FILESDIR}"/man-1.6f-unicode.patch #146315
41         "${FILESDIR}"/man-1.6c-cut-duplicate-manpaths.patch
42         "${FILESDIR}"/man-1.5m2-apropos.patch
43         "${FILESDIR}"/man-1.6g-fbsd.patch #138123
44         "${FILESDIR}"/man-1.6e-headers.patch
45         "${FILESDIR}"/man-1.6f-so-search-2.patch
46         "${FILESDIR}"/man-1.6g-compress.patch #205147
47         "${FILESDIR}"/man-1.6f-parallel-build.patch #207148 #258916
48         "${FILESDIR}"/man-1.6g-xz.patch #302380
49         "${FILESDIR}"/man-1.6f-makewhatis-compression-cleanup.patch #331979
50         "${FILESDIR}"/man-1.6g-nonportable-echo.patch #651038
51 )
52
53 src_prepare() {
54         # make sure `less` handles escape sequences #287183
55         sed -i -e '/^DEFAULTLESSOPT=/s:"$:R":' configure
56         default
57 }
58
59 echoit() { echo "$@" ; "$@" ; }
60 src_configure() {
61         strip-linguas $(eval $(grep ^LANGUAGES= configure) ; echo ${LANGUAGES//,/ })
62
63         unset NLSPATH #175258
64
65         tc-export CC BUILD_CC
66
67         local mylang=
68         if use nls ; then
69                 if [[ -z ${LINGUAS} ]] ; then
70                         mylang="all"
71                 else
72                         mylang="${LINGUAS// /,}"
73                 fi
74         else
75                 mylang="none"
76         fi
77         export COMPRESS
78         if use lzma ; then
79                 COMPRESS="${EPREFIX}"/usr/bin/xz
80         else
81                 COMPRESS="${EPREFIX}"/bin/bzip2
82         fi
83
84         if [[ -n ${EPREFIX} ]]; then
85                 hprefixify configure || die
86                 sed -i \
87                         -e "s/man_user=root/man_user=$(id -u)/"  \
88                         -e "s/man_group=man/man_group=$(id -g)/" \
89                         configure || die "Failed to disable suid/sgid options for man"
90                 sed -i -e 's:/usr/bin:@bindir@:' man2html/Makefile.in || die
91         fi
92
93         echoit \
94         ./configure \
95                 -bindir="${EPREFIX}"/usr/bin \
96                 -confdir="${EPREFIX}"/etc \
97                 +sgid +fhs \
98                 +lang ${mylang} \
99                 || die "configure failed"
100 }
101
102 src_install() {
103         unset NLSPATH #175258
104
105         emake PREFIX="${D}" install || die "make install failed"
106         dosym man /usr/bin/manpath
107
108         dodoc LSM README* TODO
109
110         # makewhatis only adds man-pages from the last 24hrs
111         exeinto /etc/cron.daily
112         newexe "${FILESDIR}"/makewhatis.cron makewhatis
113
114         keepdir /var/cache/man
115         [[ -z ${EPREFIX} ]] && diropts -m0775 -g man
116         local mansects=$(grep ^MANSECT "${ED}"/etc/man.conf | cut -f2-)
117         for x in ${mansects//:/ } ; do
118                 keepdir /var/cache/man/cat${x}
119         done
120 }
121
122 pkg_postinst() {
123         einfo "Forcing sane permissions onto ${ROOT}var/cache/man (Bug #40322)"
124         chown -R root:man "${ROOT}"/var/cache/man
125         chmod -R g+w "${ROOT}"/var/cache/man
126         [[ -e ${ROOT}/var/cache/man/whatis ]] \
127                 && chown root:0 "${ROOT}"/var/cache/man/whatis
128
129         echo
130
131         local f files=$(ls "${ROOT}"/etc/cron.{daily,weekly}/makewhatis{,.cron} 2>/dev/null)
132         for f in ${files} ; do
133                 [[ ${f} == */etc/cron.daily/makewhatis ]] && continue
134                 [[ $(md5sum "${f}") == "8b2016cc778ed4e2570b912c0f420266 "* ]] \
135                         && rm -f "${f}"
136         done
137         files=$(ls "${ROOT}"etc/cron.{daily,weekly}/makewhatis{,.cron} 2>/dev/null)
138         if [[ ${files/$'\n'} != ${files} ]] ; then
139                 ewarn "You have multiple makewhatis cron files installed."
140                 ewarn "You might want to delete all but one of these:"
141                 ewarn ${files}
142         fi
143
144         if has_version app-doc/heirloom-doctools; then
145                 ewarn "Please note that the /etc/man.conf file installed will not"
146                 ewarn "work with heirloom's nroff by default (yet)."
147                 ewarn ""
148                 ewarn "Check app-doc/heirloom-doctools elog messages for the proper"
149                 ewarn "configuration."
150         fi
151 }