zsh: upgraded package to upstream

Upgraded app-shells/zsh to version 5.8 on amd64

Note: this was previously in chromiumos-overlay at version 5.0.1, but
does not need CrOS-specific modification, so moving back to
portage-stable.  The intent is to remove from chromiumos-overlay once
this lands.

This package is only installed by developers who want it in their
chroot for convenience, not by default in the chroot, nor on any
devices.

BUG=None
TEST=sudo emerge app-shells/zsh
     Run zsh in chroot, observe its normal operation

Change-Id: I1be9be1b3cd67b96d9f015f66974f229bcd9a943
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2510777
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/app-shells/zsh/Manifest b/app-shells/zsh/Manifest
new file mode 100644
index 0000000..37076af
--- /dev/null
+++ b/app-shells/zsh/Manifest
@@ -0,0 +1,2 @@
+DIST zsh-5.8-doc.tar.xz 3088696 BLAKE2B f738bf15b137e84df91fff8500b6c309884d8a1777e3158807f6028a411ae3f345e6ccba49bdff04c6607c4eb06fc2913313e84e1f78be0a0f92d23e46ba87db SHA512 38cc549818eb9c6952051b714dd2008d99605aba4ca4f614e62b033c9b067dd2031fff766ac5c1efe5bb52eae32bd482dea5df2b2d46decb7ecdb458f3da9d52
+DIST zsh-5.8.tar.xz 3193284 BLAKE2B b1186dd27aede3318763d7c42253e919e60d00a018d085b2de7e8d985c872e9756a3ce112f623a088ec0878abd7a38d04dfa5ec552ef0f0a72e623191a7ba5e3 SHA512 96198ecef498b7d7945fecebbe6bf14065fa8c5d81a7662164579eba8206b79575812d292adea1864bc7487ac0818ba900e25f9ab3802449340de80417c2c533
diff --git a/app-shells/zsh/files/prompt_gentoo_setup-1 b/app-shells/zsh/files/prompt_gentoo_setup-1
new file mode 100644
index 0000000..046e2d8
--- /dev/null
+++ b/app-shells/zsh/files/prompt_gentoo_setup-1
@@ -0,0 +1,33 @@
+# gentoo prompt theme
+
+prompt_gentoo_help () {
+  cat <<'EOF'
+This prompt is color-scheme-able.  You can invoke it thus:
+
+  prompt gentoo [<promptcolor> [<usercolor> [<rootcolor>]]]
+
+EOF
+}
+
+prompt_gentoo_setup () {
+  local prompt_gentoo_prompt=${1:-'blue'}
+  local prompt_gentoo_user=${2:-'green'}
+  local prompt_gentoo_root=${3:-'red'}
+
+  if [ "$USER" = 'root' ]
+  then
+    local base_prompt="%B%F{$prompt_gentoo_root}%m%k "
+  else
+    local base_prompt="%B%F{$prompt_gentoo_user}%n@%m%k "
+  fi
+  local post_prompt="%b%f%k"
+
+  #setopt noxtrace localoptions
+
+  local path_prompt="%B%F{$prompt_gentoo_prompt}%1~"
+  typeset -g PS1="$base_prompt$path_prompt %# $post_prompt"
+  typeset -g PS2="$base_prompt$path_prompt %_> $post_prompt"
+  typeset -g PS3="$base_prompt$path_prompt ?# $post_prompt"
+}
+
+prompt_gentoo_setup "$@"
diff --git a/app-shells/zsh/files/zprofile-4 b/app-shells/zsh/files/zprofile-4
new file mode 100644
index 0000000..2e33b11
--- /dev/null
+++ b/app-shells/zsh/files/zprofile-4
@@ -0,0 +1,42 @@
+# /etc/zsh/zprofile
+
+# Load environment settings from profile.env, which is created by
+# env-update from the files in /etc/env.d
+if [ -e /etc/profile.env ] ; then
+	. /etc/profile.env
+fi
+
+# You should override these in your ~/.zprofile (or equivalent) for per-user
+# settings.  For system defaults, you can add a new file in /etc/profile.d/.
+export EDITOR=${EDITOR:-/bin/nano}
+export PAGER=${PAGER:-/usr/bin/less}
+
+# 077 would be more secure, but 022 is generally quite realistic
+umask 022
+
+# Set up PATH depending on whether we're root or a normal user.
+# There's no real reason to exclude sbin paths from the normal user,
+# but it can make tab-completion easier when they aren't in the
+# user's PATH to pollute the executable namespace.
+#
+# It is intentional in the following line to use || instead of -o.
+# This way the evaluation can be short-circuited and calling whoami is
+# avoided.
+if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
+	# Check to make sure ROOTPATH is sane before we use it.
+	# https://bugs.gentoo.org/656400
+	if [[ :${ROOTPATH}: == *:/usr/sbin:* ]]; then
+		PATH="${ROOTPATH}"
+	fi
+fi
+export PATH
+unset ROOTPATH
+
+shopts=$-
+setopt nullglob
+for sh in /etc/profile.d/*.sh ; do
+	[ -r "$sh" ] && . "$sh"
+done
+unsetopt nullglob
+set -$shopts
+unset sh shopts
diff --git a/app-shells/zsh/files/zsh-5.3-init.d-gentoo.diff b/app-shells/zsh/files/zsh-5.3-init.d-gentoo.diff
new file mode 100644
index 0000000..9deafd0
--- /dev/null
+++ b/app-shells/zsh/files/zsh-5.3-init.d-gentoo.diff
@@ -0,0 +1,31 @@
+--- zsh-5.3/Completion/Unix/Command/_init_d
++++ zsh-5.3/Completion/Unix/Command/_init_d
+@@ -1,6 +1,6 @@
+ #compdef -p */(init|rc[0-9S]#).d/*
+ 
+-local cmds script
++local cmds script opts
+ local -a flags
+ 
+ _compskip=all
+@@ -102,10 +102,18 @@
+ 
+ script=$words[1]
+ [[ $script = */* ]] || script="$(_init_d_fullpath "$script")"
++[[ ! -f $script ]] &&
++    { _message "${words[1]:t} is not an init script" && return }
++
+ 
+ cmds=( $(_init_d_get_cmds) ) || return 1
+ 
+-(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds ||
+-    cmds=(start stop)
++(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds
++opts=(start stop restart pause zap status ineed iuse needsme usesme broken)
++
++# If we didn't get $cmds from a zstyle, then read init script for opts.
++# If script doesn't specify opts, then default to the standard opts.
++(( $#cmds )) || cmds=( ${(eQz)${(M)${(f)"$( <$script)"}:#[[:blank:]]#opts=*}#*=} )
++(( $#cmds )) || cmds=($opts)
+ 
+ _arguments -s -A "-*" $flags ':init.d command:_sub_commands $cmds'
diff --git a/app-shells/zsh/files/zsh-5.7.1-ncurses_colors.patch b/app-shells/zsh/files/zsh-5.7.1-ncurses_colors.patch
new file mode 100644
index 0000000..3dc2a7d
--- /dev/null
+++ b/app-shells/zsh/files/zsh-5.7.1-ncurses_colors.patch
@@ -0,0 +1,37 @@
+From 7ce49801cc8ebc6f3a343ee5b829007f8cfb2bce Mon Sep 17 00:00:00 2001
+From: Lars Wendler <polynomial-c@gentoo.org>
+Date: Wed, 11 Dec 2019 14:56:25 +0100
+Subject: [PATCH] configure.ac: check for has_colors symbol in curses lib
+
+Otherwise zsh/curses module won't get built if ncurses was built with
+separate tinfo lib.
+One could still force-build the module but loading it later yields the
+following error message:
+
+  failed to load module `zsh/curses': /usr/lib64/zsh/5.7.1/zsh/curses.so:
+  undefined symbol: COLORS
+
+That is because the final linker call requires -lncurses(w) but it only
+contains -ltinfo(w).
+
+Reported-by: Tetja Rediske <tetja@tetja.de>
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ configure.ac | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index 5513e25f1..792ad4db0 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -814,6 +814,7 @@ AC_SEARCH_LIBS(tgetent, [$termcap_curses_order],
+ This is probably a library called 'curses' or 'ncurses'.  You may
+ need to install a package called 'curses-devel' or 'ncurses-devel' on your
+ system."], 255))
++AC_SEARCH_LIBS(has_colors, [$termcap_curses_order])
+ AC_CHECK_HEADERS(curses.h, [],
+ [AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris,
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[]])],[ac_cv_header_curses_h=yes
+-- 
+2.24.1
+
diff --git a/app-shells/zsh/metadata.xml b/app-shells/zsh/metadata.xml
new file mode 100644
index 0000000..f3a8264
--- /dev/null
+++ b/app-shells/zsh/metadata.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+  <maintainer type="person">
+    <email>polynomial-c@gentoo.org</email>
+    <name>Lars Wendler</name>
+  </maintainer>
+  <longdescription>
+  Zsh is a shell designed for interactive use, although it is also a
+  powerful scripting language. Many of the useful features of bash, ksh,
+  and tcsh were incorporated into zsh; many original features were
+  added.
+</longdescription>
+</pkgmetadata>
diff --git a/app-shells/zsh/zsh-5.8.ebuild b/app-shells/zsh/zsh-5.8.ebuild
new file mode 100644
index 0000000..147fb2f
--- /dev/null
+++ b/app-shells/zsh/zsh-5.8.ebuild
@@ -0,0 +1,221 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools flag-o-matic prefix
+
+if [[ ${PV} == 9999* ]] ; then
+	inherit git-r3
+	EGIT_REPO_URI="https://git.code.sf.net/p/zsh/code"
+else
+	KEYWORDS="*"
+	SRC_URI="https://www.zsh.org/pub/${P}.tar.xz
+		https://www.zsh.org/pub/old/${P}.tar.xz
+		mirror://sourceforge/${PN}/${P}.tar.xz
+		doc? (
+			https://www.zsh.org/pub/${P}-doc.tar.xz
+			mirror://sourceforge/${PN}/${P}-doc.tar.xz
+		)"
+fi
+
+DESCRIPTION="UNIX Shell similar to the Korn shell"
+HOMEPAGE="https://www.zsh.org/"
+
+LICENSE="ZSH gdbm? ( GPL-2 )"
+SLOT="0"
+IUSE="caps debug doc examples gdbm maildir pcre static unicode"
+
+RDEPEND="
+	>=sys-libs/ncurses-5.1:0=
+	static? ( >=sys-libs/ncurses-5.7-r4:0=[static-libs] )
+	caps? ( sys-libs/libcap )
+	pcre? (
+		>=dev-libs/libpcre-3.9
+		static? ( >=dev-libs/libpcre-3.9[static-libs] )
+	)
+	gdbm? ( sys-libs/gdbm:= )
+	!<sys-apps/baselayout-2.4.1
+"
+DEPEND="sys-apps/groff
+	${RDEPEND}"
+PDEPEND="
+	examples? ( app-doc/zsh-lovers )
+"
+if [[ ${PV} == 9999* ]] ; then
+	DEPEND+=" app-text/yodl
+		doc? (
+			sys-apps/texinfo
+			app-text/texi2html
+			virtual/latex-base
+		)"
+fi
+
+PATCHES=(
+	"${FILESDIR}/${PN}-5.7.1-ncurses_colors.patch"
+)
+
+src_prepare() {
+	if [[ ${PV} != 9999* ]]; then
+		# fix zshall problem with soelim
+		ln -s Doc man1 || die
+		mv Doc/zshall.1 Doc/zshall.1.soelim || die
+		soelim Doc/zshall.1.soelim > Doc/zshall.1 || die
+
+		# add openrc specific options for init.d completion
+		eapply "${FILESDIR}"/${PN}-5.3-init.d-gentoo.diff
+	fi
+
+	default
+
+	hprefixify configure.ac
+	if [[ ${PV} == 9999* ]] ; then
+		sed -i "/^VERSION=/s/=.*/=${PV}/" Config/version.mk || die
+	fi
+	eautoreconf
+}
+
+src_configure() {
+	local myconf=(
+		--bindir="${EPREFIX}"/bin
+		--libdir="${EPREFIX}"/usr/$(get_libdir)
+		--enable-etcdir="${EPREFIX}"/etc/zsh
+		--enable-runhelpdir="${EPREFIX}"/usr/share/zsh/${PV%_*}/help
+		--enable-fndir="${EPREFIX}"/usr/share/zsh/${PV%_*}/functions
+		--enable-site-fndir="${EPREFIX}"/usr/share/zsh/site-functions
+		--enable-function-subdirs
+		--with-tcsetpgrp
+		--with-term-lib="$(usex unicode 'tinfow ncursesw' 'tinfo ncurses')"
+		$(use_enable maildir maildir-support)
+		$(use_enable pcre)
+		$(use_enable caps cap)
+		$(use_enable unicode multibyte)
+		$(use_enable gdbm)
+	)
+
+	if use static ; then
+		myconf+=( --disable-dynamic )
+		append-ldflags -static
+	fi
+	if use debug ; then
+		myconf+=(
+			--enable-zsh-debug
+			--enable-zsh-mem-debug
+			--enable-zsh-mem-warning
+			--enable-zsh-secure-free
+			--enable-zsh-hash-debug
+		)
+	fi
+
+	if [[ ${CHOST} == *-darwin* ]]; then
+		myconf+=( --enable-libs=-liconv )
+		append-ldflags -Wl,-x
+	fi
+
+	econf "${myconf[@]}"
+
+	if use static ; then
+		# compile all modules statically, see Bug #27392
+		# removed cap and curses because linking failes
+		sed -e "s,link=no,link=static,g" \
+			-e "/^name=zsh\/cap/s,link=static,link=no," \
+			-e "/^name=zsh\/curses/s,link=static,link=no," \
+			-i "${S}"/config.modules || die
+		if ! use gdbm ; then
+			sed -i '/^name=zsh\/db\/gdbm/s,link=static,link=no,' \
+				"${S}"/config.modules || die
+		fi
+	fi
+}
+
+src_compile() {
+	default
+
+	if [[ ${PV} == 9999* ]] && use doc ; then
+		emake -C Doc everything
+	fi
+}
+
+src_test() {
+	addpredict /dev/ptmx
+	local i
+	for i in C02cond.ztst V08zpty.ztst X02zlevi.ztst Y01completion.ztst Y02compmatch.ztst Y03arguments.ztst ; do
+		rm "${S}"/Test/${i} || die
+	done
+	emake check
+}
+
+src_install() {
+	emake DESTDIR="${D}" install $(usex doc "install.info" "")
+
+	insinto /etc/zsh
+	export PREFIX_QUOTE_CHAR='"' PREFIX_EXTRA_REGEX="/EUID/s,0,${EUID},"
+	newins "$(prefixify_ro "${FILESDIR}"/zprofile-4)" zprofile
+
+	keepdir /usr/share/zsh/site-functions
+	insinto /usr/share/zsh/${PV%_*}/functions/Prompts
+	newins "${FILESDIR}"/prompt_gentoo_setup-1 prompt_gentoo_setup
+
+	local i
+
+	# install miscellaneous scripts (bug #54520)
+	sed -e "s:/usr/local/bin/perl:${EPREFIX}/usr/bin/perl:g" \
+		-e "s:/usr/local/bin/zsh:${EPREFIX}/bin/zsh:g" \
+		-i {Util,Misc}/* || die
+	for i in Util Misc ; do
+		insinto /usr/share/zsh/${PV%_*}/${i}
+		doins ${i}/*
+	done
+
+	# install header files (bug #538684)
+	insinto /usr/include/zsh
+	doins config.h Src/*.epro
+	for i in Src/{zsh.mdh,*.h} ; do
+		sed -e 's@\.\./config\.h@config.h@' \
+			-e 's@#\(\s*\)include "\([^"]\+\)"@#\1include <zsh/\2>@' \
+			-i "${i}"
+		doins "${i}"
+	done
+
+	dodoc ChangeLog* META-FAQ NEWS README config.modules
+
+	if use doc ; then
+		pushd "${WORKDIR}/${PN}-${PV%_*}" >/dev/null
+		dodoc Doc/zsh.{dvi,pdf}
+		docinto html
+		dodoc Doc/*.html
+		popd >/dev/null
+	fi
+
+	docinto StartupFiles
+	dodoc StartupFiles/z*
+}
+
+pkg_postinst() {
+	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+		echo
+		elog "If you want to enable Portage completions and Gentoo prompt,"
+		elog "emerge app-shells/gentoo-zsh-completions and add"
+		elog "	autoload -U compinit promptinit"
+		elog "	compinit"
+		elog "	promptinit; prompt gentoo"
+		elog "to your ~/.zshrc"
+		echo
+		elog "Also, if you want to enable cache for the completions, add"
+		elog "	zstyle ':completion::complete:*' use-cache 1"
+		elog "to your ~/.zshrc"
+		echo
+		elog "Note that a system zprofile startup file is installed. This will override"
+		elog "PATH and possibly other variables that a user may set in ~/.zshenv."
+		elog "Custom PATH settings and similar overridden variables can be moved to ~/.zprofile"
+		elog "or other user startup files that are sourced after the system zprofile."
+		echo
+		elog "If PATH must be set in ~/.zshenv to affect things like non-login ssh shells,"
+		elog "one method is to use a separate path-setting file that is conditionally sourced"
+		elog "in ~/.zshenv and also sourced from ~/.zprofile. For more information, see the"
+		elog "zshenv example in ${EROOT}/usr/share/doc/${PF}/StartupFiles/."
+		echo
+		elog "See https://wiki.gentoo.org/wiki/Zsh/HOWTO for more introduction documentation."
+		echo
+	fi
+}
diff --git a/metadata/md5-cache/app-shells/zsh-5.8 b/metadata/md5-cache/app-shells/zsh-5.8
new file mode 100644
index 0000000..d2ad019
--- /dev/null
+++ b/metadata/md5-cache/app-shells/zsh-5.8
@@ -0,0 +1,15 @@
+BDEPEND=>=app-portage/elt-patches-20170815
+DEFINED_PHASES=compile configure install postinst prepare test
+DEPEND=sys-apps/groff >=sys-libs/ncurses-5.1:0= static? ( >=sys-libs/ncurses-5.7-r4:0=[static-libs] ) caps? ( sys-libs/libcap ) pcre? ( >=dev-libs/libpcre-3.9 static? ( >=dev-libs/libpcre-3.9[static-libs] ) ) gdbm? ( sys-libs/gdbm:= ) !<sys-apps/baselayout-2.4.1 !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4
+DESCRIPTION=UNIX Shell similar to the Korn shell
+EAPI=7
+HOMEPAGE=https://www.zsh.org/
+IUSE=caps debug doc examples gdbm maildir pcre static unicode
+KEYWORDS=*
+LICENSE=ZSH gdbm? ( GPL-2 )
+PDEPEND=examples? ( app-doc/zsh-lovers )
+RDEPEND=>=sys-libs/ncurses-5.1:0= static? ( >=sys-libs/ncurses-5.7-r4:0=[static-libs] ) caps? ( sys-libs/libcap ) pcre? ( >=dev-libs/libpcre-3.9 static? ( >=dev-libs/libpcre-3.9[static-libs] ) ) gdbm? ( sys-libs/gdbm:= ) !<sys-apps/baselayout-2.4.1
+SLOT=0
+SRC_URI=https://www.zsh.org/pub/zsh-5.8.tar.xz https://www.zsh.org/pub/old/zsh-5.8.tar.xz mirror://sourceforge/zsh/zsh-5.8.tar.xz doc? ( https://www.zsh.org/pub/zsh-5.8-doc.tar.xz mirror://sourceforge/zsh/zsh-5.8-doc.tar.xz )
+_eclasses_=autotools	d0e5375d47f4c809f406eb892e531513	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	multilib	2477ebe553d3e4d2c606191fe6c33602	prefix	e51c7882b7b721e54e684f7eb143cbfe	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=f9a57dcba75a3f0f1dc3571a99320bb3