Created
November 2, 2012 03:21
-
-
Save ormaaj/3998534 to your computer and use it in GitHub Desktop.
ksh93 ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 1999-2012 Gentoo Foundation | |
# Distributed under the terms of the GNU General Public License v2 | |
# $Header: $ | |
EAPI=4 | |
# Specify an alternate AST distribution if needed. | |
myPkgName= | |
# This section allows for the possibility to build from git sources, | |
# and otherwise specifies source tarball names. | |
if [[ $PV == 9999 ]]; then | |
myPkgName=ast-open | |
EGIT_REPO_URI=http://I.accept.www.opensource.org.licenses.eclipse:.@www2.research.att.com/sw/git/ast-open | |
SRC_URI= | |
else | |
printf -v SRC_URI "%s.$(LC_TIME=C date -d "${PV##*.}" +%F).tgz\n" \ | |
{mirror://gentoo,'http://dev.gentoo.org/~flopppym/distfiles'}/{INIT,"${myPkgName:=ast-base}"} | |
fi | |
inherit toolchain-funcs prefix eutils ${EGIT_REPO_URI+git-2} | |
# various metadata | |
DESCRIPTION='The AT&T Korn Shell' | |
HOMEPAGE='http://www.kornshell.com/ http://www2.research.att.com/~gsf/download/ksh/ksh.html' | |
LICENSE='CPL-1.0 EPL-1.0' | |
SLOT=0 | |
KEYWORDS='~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86' | |
IUSE=+plugins | |
RDEPEND= | |
S=$WORKDIR | |
src_prepare() { | |
# Bug 238906 | |
typeset f | |
for f in bin/package src/cmd/INIT/package.sh; do | |
ed -s "$f" </dev/fd/0 || die | |
done <<\EOF | |
g|cd /tmp|s,,cd "${TMPDIR:-/tmp}",g | |
w | |
EOF | |
# Bug 230241 | |
epatch "${FILESDIR}/${PN}-prefix.patch" | |
eprefixify src/cmd/ksh93/data/msg.c | |
# Apply a backport of the one-liner "command" builtin fix. | |
# http://article.gmane.org/gmane.comp.programming.tools.ast.devel/651 | |
if (( $(LC_TIME=C date -d "${PV##*.}" +%Y%m%d) < 20121024 )); then | |
epatch "${FILESDIR}/${PN}-fix-command-builtin.patch" | |
fi | |
} | |
src_compile() { | |
# This recursion works around Portage being unable to do anything useful with | |
# the return status. FUNCNAME is like .sh.fun, but an array of the entire stack. | |
if [[ $FUNCNAME != "${FUNCNAME[1]}" ]]; then | |
# export some toolchain-specific vars. e.g. CC=cc | |
tc-export AR CC LD NM | |
export CCFLAGS=$CFLAGS | |
typeset -a packageOpts=("SHELL=${EPREFIX}/bin/sh" SHOPT_SYSRC=1) | |
# I'm just setting SHOPT_CMDLIB_DIR=1 to optionally add all the builtins, but | |
# am not sure whether this is the best method. | |
use plugins && packageOpts+=(SHOPT_CMDLIB_DIR=1) | |
typeset -f +t "$FUNCNAME" | |
"$FUNCNAME" "$@" || die | |
else | |
# Print the results when we return. RETURN is somewhat similar to the Ksh EXIT trap. | |
trap 'einfo "make results:"; sh bin/package results; trap - RETURN' RETURN | |
# Do the build. Flat should be fine I think. | |
sh bin/package flat only make ast-ksh "${packageOpts[@]}" | |
fi | |
} | |
# This only runs if the user opts in to running the tests. | |
src_test() { | |
sh bin/package test | |
einfo 'test results:' | |
sh bin/package results test | |
} | |
# I suspect this is not ideal. | |
src_install() { | |
# Install the docs | |
dodoc "lib/package/${myPkgName}.README" | |
dohtml "lib/package/${myPkgName}.html" | |
# Install the binary and rksh symlink. | |
into / | |
dobin bin/ksh | |
dosym ksh /bin/rksh | |
# manpage... | |
newman man/man1/sh.1 ksh.1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment