app-shells/zsh: Bump to version 5.6.2
[gentoo.git] / app-shells / zsh / zsh-5.5.1-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit flag-o-matic prefix
7
8 if [[ ${PV} == 9999* ]] ; then
9         inherit git-r3 autotools
10         EGIT_REPO_URI="git://git.code.sf.net/p/zsh/code"
11 else
12         KEYWORDS="alpha amd64 arm arm64 ~hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
13         SRC_URI="https://www.zsh.org/pub/${P}.tar.gz
14                 doc? ( https://www.zsh.org/pub/${P}-doc.tar.xz )"
15 fi
16
17 DESCRIPTION="UNIX Shell similar to the Korn shell"
18 HOMEPAGE="https://www.zsh.org/"
19
20 LICENSE="ZSH gdbm? ( GPL-2 )"
21 SLOT="0"
22 IUSE="caps debug doc examples gdbm maildir pcre static unicode"
23
24 RDEPEND="
25         >=sys-libs/ncurses-5.1:0=
26         static? ( >=sys-libs/ncurses-5.7-r4:0=[static-libs] )
27         caps? ( sys-libs/libcap )
28         pcre? (
29                 >=dev-libs/libpcre-3.9
30                 static? ( >=dev-libs/libpcre-3.9[static-libs] )
31         )
32         gdbm? ( sys-libs/gdbm:= )
33         !<sys-apps/baselayout-2.4.1
34 "
35 DEPEND="sys-apps/groff
36         ${RDEPEND}"
37 PDEPEND="
38         examples? ( app-doc/zsh-lovers )
39 "
40 if [[ ${PV} == 9999* ]] ; then
41         DEPEND+=" app-text/yodl
42                 doc? (
43                         sys-apps/texinfo
44                         app-text/texi2html
45                         virtual/latex-base
46                 )"
47 fi
48
49 src_prepare() {
50         if [[ ${PV} != 9999* ]]; then
51                 # fix zshall problem with soelim
52                 ln -s Doc man1 || die
53                 mv Doc/zshall.1 Doc/zshall.1.soelim || die
54                 soelim Doc/zshall.1.soelim > Doc/zshall.1 || die
55
56                 # add openrc specific options for init.d completion
57                 eapply "${FILESDIR}"/${PN}-5.3-init.d-gentoo.diff
58         fi
59
60         eapply_user
61
62         if [[ ${PV} == 9999* ]] ; then
63                 sed -i "/^VERSION=/s/=.*/=${PV}/" Config/version.mk || die
64                 eautoreconf
65         fi
66 }
67
68 src_configure() {
69         local myconf=(
70                 --bindir="${EPREFIX}"/bin
71                 --libdir="${EPREFIX}"/usr/$(get_libdir)
72                 --enable-etcdir="${EPREFIX}"/etc/zsh
73                 --enable-runhelpdir="${EPREFIX}"/usr/share/zsh/${PV%_*}/help
74                 --enable-fndir="${EPREFIX}"/usr/share/zsh/${PV%_*}/functions
75                 --enable-site-fndir="${EPREFIX}"/usr/share/zsh/site-functions
76                 --enable-function-subdirs
77                 --with-tcsetpgrp
78                 $(use_enable maildir maildir-support)
79                 $(use_enable pcre)
80                 $(use_enable caps cap)
81                 $(use_enable unicode multibyte)
82                 $(use_enable gdbm )
83         )
84
85         if use static ; then
86                 myconf+=( --disable-dynamic )
87                 append-ldflags -static
88         fi
89         if use debug ; then
90                 myconf+=(
91                         --enable-zsh-debug
92                         --enable-zsh-mem-debug
93                         --enable-zsh-mem-warning
94                         --enable-zsh-secure-free
95                         --enable-zsh-hash-debug
96                 )
97         fi
98
99         if [[ ${CHOST} == *-darwin* ]]; then
100                 myconf+=( --enable-libs=-liconv )
101                 append-ldflags -Wl,-x
102         fi
103
104         econf "${myconf[@]}"
105
106         if use static ; then
107                 # compile all modules statically, see Bug #27392
108                 # removed cap and curses because linking failes
109                 sed -e "s,link=no,link=static,g" \
110                         -e "/^name=zsh\/cap/s,link=static,link=no," \
111                         -e "/^name=zsh\/curses/s,link=static,link=no," \
112                         -i "${S}"/config.modules || die
113                 if ! use gdbm ; then
114                         sed -i '/^name=zsh\/db\/gdbm/s,link=static,link=no,' \
115                                 "${S}"/config.modules || die
116                 fi
117         fi
118 }
119
120 src_compile() {
121         default
122
123         if [[ ${PV} == 9999* ]] && use doc ; then
124                 emake -C Doc everything
125         fi
126 }
127
128 src_test() {
129         addpredict /dev/ptmx
130         local i
131         for i in C02cond.ztst V08zpty.ztst X02zlevi.ztst Y01completion.ztst Y02compmatch.ztst Y03arguments.ztst ; do
132                 rm "${S}"/Test/${i} || die
133         done
134         emake check
135 }
136
137 src_install() {
138         emake DESTDIR="${D}" install $(usex doc "install.info" "")
139
140         insinto /etc/zsh
141         export PREFIX_QUOTE_CHAR='"' PREFIX_EXTRA_REGEX="/EUID/s,0,${EUID},"
142         newins "$(prefixify_ro "${FILESDIR}"/zprofile-4)" zprofile
143
144         keepdir /usr/share/zsh/site-functions
145         insinto /usr/share/zsh/${PV%_*}/functions/Prompts
146         newins "${FILESDIR}"/prompt_gentoo_setup-1 prompt_gentoo_setup
147
148         local i
149
150         # install miscellaneous scripts (bug #54520)
151         sed -e "s:/usr/local/bin/perl:${EPREFIX}/usr/bin/perl:g" \
152                 -e "s:/usr/local/bin/zsh:${EPREFIX}/bin/zsh:g" \
153                 -i {Util,Misc}/* || die
154         for i in Util Misc ; do
155                 insinto /usr/share/zsh/${PV%_*}/${i}
156                 doins ${i}/*
157         done
158
159         # install header files (bug #538684)
160         insinto /usr/include/zsh
161         doins config.h Src/*.epro
162         for i in Src/{zsh.mdh,*.h} ; do
163                 sed -e 's@\.\./config\.h@config.h@' \
164                         -e 's@#\(\s*\)include "\([^"]\+\)"@#\1include <zsh/\2>@' \
165                         -i "${i}"
166                 doins "${i}"
167         done
168
169         dodoc ChangeLog* META-FAQ NEWS README config.modules
170
171         if use doc ; then
172                 pushd "${WORKDIR}/${PN}-${PV%_*}" >/dev/null
173                 docinto html
174                 dodoc Doc/*.html
175                 insinto /usr/share/doc/${PF}
176                 doins Doc/zsh.{dvi,pdf}
177                 popd >/dev/null
178         fi
179
180         docinto StartupFiles
181         dodoc StartupFiles/z*
182 }
183
184 pkg_postinst() {
185         if [[ -z ${REPLACING_VERSIONS} ]] ; then
186                 echo
187                 elog "If you want to enable Portage completions and Gentoo prompt,"
188                 elog "emerge app-shells/gentoo-zsh-completions and add"
189                 elog "  autoload -U compinit promptinit"
190                 elog "  compinit"
191                 elog "  promptinit; prompt gentoo"
192                 elog "to your ~/.zshrc"
193                 echo
194                 elog "Also, if you want to enable cache for the completions, add"
195                 elog "  zstyle ':completion::complete:*' use-cache 1"
196                 elog "to your ~/.zshrc"
197                 echo
198                 elog "Note that a system zprofile startup file is installed. This will override"
199                 elog "PATH and possibly other variables that a user may set in ~/.zshenv."
200                 elog "Custom PATH settings and similar overridden variables can be moved to ~/.zprofile"
201                 elog "or other user startup files that are sourced after the system zprofile."
202                 echo
203                 elog "If PATH must be set in ~/.zshenv to affect things like non-login ssh shells,"
204                 elog "one method is to use a separate path-setting file that is conditionally sourced"
205                 elog "in ~/.zshenv and also sourced from ~/.zprofile. For more information, see the"
206                 elog "zshenv example in ${EROOT}/usr/share/doc/${PF}/StartupFiles/."
207                 echo
208                 elog "See https://wiki.gentoo.org/wiki/Zsh/HOWTO for more introduction documentation."
209                 echo
210         fi
211 }