summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-12 05:55:37 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-12 05:55:37 +0000
commitaacb5d3be42eb354596ca19db836bd3085bc2da9 (patch)
tree9be638d9a9d226b59e031bddffedfcc2f87eba4e /bin/ebuild-helpers
parentUse absolute imports instead of relative. (trunk r13062) (diff)
downloadportage-multirepo-aacb5d3be42eb354596ca19db836bd3085bc2da9.tar.gz
portage-multirepo-aacb5d3be42eb354596ca19db836bd3085bc2da9.tar.bz2
portage-multirepo-aacb5d3be42eb354596ca19db836bd3085bc2da9.zip
Move ebuild helpers into an ebuild-helpers subdirectory. (trunk r13063)
svn path=/main/branches/2.1.6/; revision=13077
Diffstat (limited to 'bin/ebuild-helpers')
-rwxr-xr-xbin/ebuild-helpers/dobin29
-rwxr-xr-xbin/ebuild-helpers/doconfd14
-rwxr-xr-xbin/ebuild-helpers/dodir6
-rwxr-xr-xbin/ebuild-helpers/dodoc28
-rwxr-xr-xbin/ebuild-helpers/doenvd14
-rwxr-xr-xbin/ebuild-helpers/doexe29
-rwxr-xr-xbin/ebuild-helpers/dohard14
-rwxr-xr-xbin/ebuild-helpers/dohtml186
-rwxr-xr-xbin/ebuild-helpers/doinfo22
-rwxr-xr-xbin/ebuild-helpers/doinitd14
-rwxr-xr-xbin/ebuild-helpers/doins98
-rwxr-xr-xbin/ebuild-helpers/dolib41
-rwxr-xr-xbin/ebuild-helpers/dolib.a7
-rwxr-xr-xbin/ebuild-helpers/dolib.so7
-rwxr-xr-xbin/ebuild-helpers/doman62
-rwxr-xr-xbin/ebuild-helpers/domo26
-rwxr-xr-xbin/ebuild-helpers/dosbin27
-rwxr-xr-xbin/ebuild-helpers/dosed36
-rwxr-xr-xbin/ebuild-helpers/dosym14
-rwxr-xr-xbin/ebuild-helpers/ecompress92
-rwxr-xr-xbin/ebuild-helpers/ecompressdir136
-rwxr-xr-xbin/ebuild-helpers/emake25
-rwxr-xr-xbin/ebuild-helpers/fowners9
-rwxr-xr-xbin/ebuild-helpers/fperms9
-rwxr-xr-xbin/ebuild-helpers/newbin18
-rwxr-xr-xbin/ebuild-helpers/newconfd18
-rwxr-xr-xbin/ebuild-helpers/newdoc18
-rwxr-xr-xbin/ebuild-helpers/newenvd18
-rwxr-xr-xbin/ebuild-helpers/newexe18
-rwxr-xr-xbin/ebuild-helpers/newinitd18
-rwxr-xr-xbin/ebuild-helpers/newins21
-rwxr-xr-xbin/ebuild-helpers/newlib.a18
-rwxr-xr-xbin/ebuild-helpers/newlib.so18
-rwxr-xr-xbin/ebuild-helpers/newman18
-rwxr-xr-xbin/ebuild-helpers/newsbin18
l---------bin/ebuild-helpers/portageq1
-rwxr-xr-xbin/ebuild-helpers/prepall24
-rwxr-xr-xbin/ebuild-helpers/prepalldocs16
-rwxr-xr-xbin/ebuild-helpers/prepallinfo10
-rwxr-xr-xbin/ebuild-helpers/prepallman17
-rwxr-xr-xbin/ebuild-helpers/prepallstrip6
-rwxr-xr-xbin/ebuild-helpers/prepinfo31
-rwxr-xr-xbin/ebuild-helpers/preplib29
-rwxr-xr-xbin/ebuild-helpers/prepman30
-rwxr-xr-xbin/ebuild-helpers/prepstrip178
-rwxr-xr-xbin/ebuild-helpers/sed28
46 files changed, 1516 insertions, 0 deletions
diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
new file mode 100755
index 00000000..958a37fe
--- /dev/null
+++ b/bin/ebuild-helpers/dobin
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ $# -lt 1 ]] ; then
+ vecho "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+if [[ ! -d ${D}${DESTTREE}/bin ]] ; then
+ install -d "${D}${DESTTREE}/bin" || exit 2
+fi
+
+ret=0
+
+for x in "$@" ; do
+ if [[ -e ${x} ]] ; then
+ install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/bin"
+ else
+ echo "!!! ${0##*/}: $x does not exist" 1>&2
+ false
+ fi
+ ((ret+=$?))
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/doconfd b/bin/ebuild-helpers/doconfd
new file mode 100755
index 00000000..9952ec0f
--- /dev/null
+++ b/bin/ebuild-helpers/doconfd
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+exec \
+env \
+INSDESTTREE="/etc/conf.d/" \
+doins "$@"
diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir
new file mode 100755
index 00000000..1902c6f3
--- /dev/null
+++ b/bin/ebuild-helpers/dodir
@@ -0,0 +1,6 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+exec install -d ${DIROPTIONS} "${@/#/${D}/}"
diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
new file mode 100755
index 00000000..adf49d04
--- /dev/null
+++ b/bin/ebuild-helpers/dodoc
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [ $# -lt 1 ] ; then
+ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+ vecho "${0##*/}: at least one argument needed" 1>&2
+ exit 1
+fi
+
+dir="${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
+if [ ! -d "${dir}" ] ; then
+ install -d "${dir}"
+fi
+
+ret=0
+for x in "$@" ; do
+ if [ -s "${x}" ] ; then
+ install -m0644 "${x}" "${dir}"
+ ecompress --queue "${dir}/${x##*/}"
+ elif [ ! -e "${x}" ] ; then
+ echo "!!! ${0##*/}: $x does not exist" 1>&2
+ ((++ret))
+ fi
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/doenvd b/bin/ebuild-helpers/doenvd
new file mode 100755
index 00000000..eb7dcd72
--- /dev/null
+++ b/bin/ebuild-helpers/doenvd
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+exec \
+env \
+INSDESTTREE="/etc/env.d/" \
+doins "$@"
diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe
new file mode 100755
index 00000000..6e72c1c7
--- /dev/null
+++ b/bin/ebuild-helpers/doexe
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+if [[ ! -d ${D}${_E_EXEDESTTREE_} ]] ; then
+ install -d "${D}${_E_EXEDESTTREE_}"
+fi
+
+for x in "$@" ; do
+ if [ -L "${x}" ] ; then
+ cp "${x}" "${T}"
+ mysrc="${T}"/$(/usr/bin/basename "${x}")
+ elif [ -d "${x}" ] ; then
+ vecho "doexe: warning, skipping directory ${x}"
+ continue
+ else
+ mysrc="${x}"
+ fi
+ install $EXEOPTIONS "$mysrc" "$D$_E_EXEDESTTREE_" || \
+ echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
+done
diff --git a/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard
new file mode 100755
index 00000000..dfd7bd34
--- /dev/null
+++ b/bin/ebuild-helpers/dohard
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -ne 2 ]] ; then
+ echo "$0: two arguments needed" 1>&2
+ exit 1
+fi
+
+destdir=${2%/*}
+[[ ! -d ${D}${destdir} ]] && dodir "${destdir}"
+
+exec ln -f "${D}$1" "${D}$2"
diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml
new file mode 100755
index 00000000..1c707bdf
--- /dev/null
+++ b/bin/ebuild-helpers/dohtml
@@ -0,0 +1,186 @@
+#!/usr/bin/python
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+#
+# Typical usage:
+# dohtml -r docs/*
+# - put all files and directories in docs into /usr/share/doc/${PF}/html
+# dohtml foo.html
+# - put foo.html into /usr/share/doc/${PF}/html
+#
+#
+# Detailed usage:
+# dohtml <list-of-files>
+# - will install the files in the list of files (space-separated list) into
+# /usr/share/doc/${PF}/html, provided the file ends in .htm, .html, .css,
+# .js, ,gif, .jpeg, .jpg, or .png.
+# dohtml -r <list-of-files-and-directories>
+# - will do as 'dohtml', but recurse into all directories, as long as the
+# directory name is not CVS
+# dohtml -A jpe,java [-r] <list-of-files[-and-directories]>
+# - will do as 'dohtml' but add .jpe,.java (default filter list is
+# added to your list)
+# dohtml -a png,gif,html,htm [-r] <list-of-files[-and-directories]>
+# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter
+# list is ignored)
+# dohtml -x CVS,SCCS,RCS -r <list-of-files-and-directories>
+# - will do as 'dohtml -r', but ignore directories named CVS, SCCS, RCS
+#
+
+import os
+import sys
+
+def dodir(path):
+ os.spawnlp(os.P_WAIT, "install", "install", "-d", path)
+
+def dofile(src,dst):
+ os.spawnlp(os.P_WAIT, "install", "install", "-m0644", src, dst)
+
+def eqawarn(lines):
+ cmd = "source '%s/isolated-functions.sh' ; " % \
+ os.environ["PORTAGE_BIN_PATH"]
+ for line in lines:
+ cmd += "eqawarn \"%s\" ; " % line
+ os.spawnlp(os.P_WAIT, "bash", "bash", "-c", cmd)
+
+skipped_directories = []
+
+def install(basename, dirname, options, prefix=""):
+ fullpath = basename
+ if prefix:
+ fullpath = prefix + "/" + fullpath
+ if dirname:
+ fullpath = dirname + "/" + fullpath
+
+ if options.DOCDESTTREE:
+ destdir = options.D + "usr/share/doc/" + options.PF + "/" + options.DOCDESTTREE + "/" + options.doc_prefix + "/" + prefix
+ else:
+ destdir = options.D + "usr/share/doc/" + options.PF + "/html/" + options.doc_prefix + "/" + prefix
+
+ if os.path.isfile(fullpath):
+ ext = os.path.splitext(basename)[1]
+ if (len(ext) and ext[1:] in options.allowed_exts) or basename in options.allowed_files:
+ dodir(destdir)
+ dofile(fullpath, destdir + "/" + basename)
+ elif options.recurse and os.path.isdir(fullpath) and \
+ basename not in options.disallowed_dirs:
+ for i in os.listdir(fullpath):
+ pfx = basename
+ if prefix: pfx = prefix + "/" + pfx
+ install(i, dirname, options, pfx)
+ elif not options.recurse and os.path.isdir(fullpath):
+ global skipped_directories
+ skipped_directories.append(fullpath)
+ return False
+ else:
+ return False
+ return True
+
+
+class OptionsClass:
+ def __init__(self):
+ self.PF = ""
+ self.D = ""
+ self.DOCDESTTREE = ""
+
+ if "PF" in os.environ:
+ self.PF = os.environ["PF"]
+ if "D" in os.environ:
+ self.D = os.environ["D"]
+ if "_E_DOCDESTTREE_" in os.environ:
+ self.DOCDESTTREE = os.environ["_E_DOCDESTTREE_"]
+
+ self.allowed_exts = [ 'htm', 'html', 'css', 'js',
+ 'gif', 'jpeg', 'jpg', 'png' ]
+ self.allowed_files = []
+ self.disallowed_dirs = [ 'CVS' ]
+ self.recurse = False
+ self.verbose = False
+ self.doc_prefix = ""
+
+def print_help():
+ opts = OptionsClass()
+
+ print "dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]"
+ print " [-r] [-V] <file> [file ...]"
+ print
+ print " -a Set the list of allowed to those that are specified."
+ print " Default:", ",".join(opts.allowed_exts)
+ print " -A Extend the list of allowed file types."
+ print " -f Set list of allowed extensionless file names."
+ print " -x Set directories to be excluded from recursion."
+ print " Default:", ",".join(opts.disallowed_dirs)
+ print " -p Set a document prefix for installed files (empty by default)."
+ print " -r Install files and directories recursively."
+ print " -V Be verbose."
+ print
+
+def parse_args():
+ options = OptionsClass()
+ args = []
+
+ x = 1
+ while x < len(sys.argv):
+ arg = sys.argv[x]
+ if arg in ["-h","-r","-V"]:
+ if arg == "-h":
+ print_help()
+ sys.exit(0)
+ elif arg == "-r":
+ options.recurse = True
+ elif arg == "-V":
+ options.verbose = True
+ elif sys.argv[x] in ["-A","-a","-f","-x","-p"]:
+ x += 1
+ if x == len(sys.argv):
+ print_help()
+ sys.exit(0)
+ elif arg == "-p":
+ options.doc_prefix = sys.argv[x]
+ else:
+ values = sys.argv[x].split(",")
+ if arg == "-A":
+ options.allowed_exts.extend(values)
+ elif arg == "-a":
+ options.allowed_exts = values
+ elif arg == "-f":
+ options.allowed_files = values
+ elif arg == "-x":
+ options.disallowed_dirs = values
+ else:
+ args.append(sys.argv[x])
+ x += 1
+
+ return (options, args)
+
+def main():
+
+ (options, args) = parse_args()
+
+ if options.verbose:
+ print "Allowed extensions:", options.allowed_exts
+ print "Document prefix : '" + options.doc_prefix + "'"
+ print "Allowed files :", options.allowed_files
+
+ success = False
+
+ for x in args:
+ basename = os.path.basename(x)
+ dirname = os.path.dirname(x)
+ success |= install(basename, dirname, options)
+
+ if success:
+ retcode = 0
+ else:
+ retcode = 1
+ global skipped_directories
+ for x in skipped_directories:
+ eqawarn(["QA Notice: dohtml on directory " + \
+ "'%s' without recursion option" % x])
+
+ sys.exit(retcode)
+
+if __name__ == "__main__":
+ main()
diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo
new file mode 100755
index 00000000..1c9e7cc0
--- /dev/null
+++ b/bin/ebuild-helpers/doinfo
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z $1 ]] ; then
+ vecho "${0##*/}: at least one argument needed"
+ exit 1
+fi
+
+if [[ ! -d ${D}usr/share/info ]] ; then
+ install -d "${D}usr/share/info" || exit 1
+fi
+
+install -m0644 "$@" "${D}usr/share/info"
+rval=$?
+if [ $rval -ne 0 ] ; then
+ for x in "$@" ; do
+ [ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2
+ done
+fi
+exit $rval
diff --git a/bin/ebuild-helpers/doinitd b/bin/ebuild-helpers/doinitd
new file mode 100755
index 00000000..0f1af940
--- /dev/null
+++ b/bin/ebuild-helpers/doinitd
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+exec \
+env \
+_E_EXEDESTTREE_="/etc/init.d/" \
+doexe "$@"
diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
new file mode 100755
index 00000000..8c06bfd9
--- /dev/null
+++ b/bin/ebuild-helpers/doins
@@ -0,0 +1,98 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [ $# -lt 1 ] ; then
+ echo "${0##*/}: at least one argument needed" 1>&2
+ exit 1
+fi
+
+if [[ "$1" == "-r" ]] ; then
+ DOINSRECUR=y
+ shift
+else
+ DOINSRECUR=n
+fi
+
+if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then
+ vecho "-------------------------------------------------------" 1>&2
+ vecho "You should not use \${D} with helpers." 1>&2
+ vecho " --> ${INSDESTTREE}" 1>&2
+ vecho "-------------------------------------------------------" 1>&2
+ exit 1
+fi
+
+export TMP=$T/.doins_tmp
+# Use separate directories to avoid potential name collisions.
+mkdir -p "$TMP"/{1,2}
+
+[[ ! -d ${D}${INSDESTTREE} ]] && dodir "${INSDESTTREE}"
+
+_doins() {
+ local mysrc="$1" mydir="$2" cleanup="" rval
+
+ if [ -L "$mysrc" ] ; then
+ cp "$mysrc" "$TMP/2"
+ mysrc="$TMP/2/${mysrc##*/}"
+ cleanup=${mysrc}
+ fi
+
+ install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}/${mydir}"
+ rval=$?
+ [[ -n ${cleanup} ]] && rm -f "${cleanup}"
+ [ $rval -ne 0 ] && echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
+ return $rval
+}
+
+_xdoins() {
+ while read -d $'\0' x ; do
+ _doins "$x" "${x%/*}"
+ done
+}
+
+success=0
+
+for x in "$@" ; do
+ if [ -d "$x" ] ; then
+ if [ "${DOINSRECUR}" == "n" ] ; then
+ continue
+ fi
+
+ while [ "$x" != "${x%/}" ] ; do
+ x=${x%/}
+ done
+ if [ "$x" = "${x%/*}" ] ; then
+ pushd "$PWD" >/dev/null
+ else
+ pushd "${x%/*}" >/dev/null
+ fi
+ x=${x##*/}
+ x_orig=$x
+ # Follow any symlinks recursively until we've got
+ # a normal directory for 'find' to traverse.
+ while [ -L "$x" ] ; do
+ pushd "$(readlink "$x")" >/dev/null
+ x=${PWD##*/}
+ pushd "${PWD%/*}" >/dev/null
+ done
+ if [[ $x != $x_orig ]] ; then
+ mv "$x" "$TMP/1/$x_orig"
+ pushd "$TMP/1" >/dev/null
+ fi
+ find "$x_orig" -type d -exec dodir "${INSDESTTREE}/{}" \;
+ find "$x_orig" \( -type f -or -type l \) -print0 | _xdoins
+ if [[ $x != $x_orig ]] ; then
+ popd >/dev/null
+ mv "$TMP/1/$x_orig" "$x"
+ fi
+ while popd >/dev/null 2>&1 ; do true ; done
+ ((++success))
+ else
+ _doins "${x}" && ((++success))
+ fi
+done
+rm -rf "$TMP"
+[ $success -gt 0 ] && exit 0 || exit 1
diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
new file mode 100755
index 00000000..6c6628bd
--- /dev/null
+++ b/bin/ebuild-helpers/dolib
@@ -0,0 +1,41 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Setup ABI cruft
+LIBDIR_VAR="LIBDIR_${ABI}"
+if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
+ CONF_LIBDIR=${!LIBDIR_VAR}
+fi
+unset LIBDIR_VAR
+# we need this to default to lib so that things dont break
+CONF_LIBDIR=${CONF_LIBDIR:-lib}
+libdir="${D}${DESTTREE}/${CONF_LIBDIR}"
+
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+if [[ ! -d ${libdir} ]] ; then
+ install -d "${libdir}" || exit 1
+fi
+
+ret=0
+
+for x in "$@" ; do
+ if [[ -e ${x} ]] ; then
+ if [[ ! -L ${x} ]] ; then
+ install ${LIBOPTIONS} "${x}" "${libdir}"
+ else
+ ln -s "$(readlink "${x}")" "${libdir}/${x##*/}"
+ fi
+ else
+ echo "!!! ${0##*/}: ${x} does not exist" 1>&2
+ false
+ fi
+ ((ret+=$?))
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/dolib.a b/bin/ebuild-helpers/dolib.a
new file mode 100755
index 00000000..3ef57d2f
--- /dev/null
+++ b/bin/ebuild-helpers/dolib.a
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+exec env LIBOPTIONS="-m0644" \
+ dolib "$@"
diff --git a/bin/ebuild-helpers/dolib.so b/bin/ebuild-helpers/dolib.so
new file mode 100755
index 00000000..e4d477f6
--- /dev/null
+++ b/bin/ebuild-helpers/dolib.so
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+exec env LIBOPTIONS="-m0755" \
+ dolib "$@"
diff --git a/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman
new file mode 100755
index 00000000..48abc39f
--- /dev/null
+++ b/bin/ebuild-helpers/doman
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+i18n=""
+
+ret=0
+
+for x in "$@" ; do
+ if [[ ${x:0:6} == "-i18n=" ]] ; then
+ i18n=${x:6}/
+ continue
+ fi
+ if [[ ${x:0:6} == ".keep_" ]] ; then
+ continue
+ fi
+
+ suffix=${x##*.}
+
+ # These will be automatically decompressed by ecompressdir.
+ if hasq ${suffix} Z gz bz2 ; then
+ realname=${x%.*}
+ suffix=${realname##*.}
+ fi
+
+ if ! hasq "${EAPI:-0}" 0 1 && \
+ [[ $x =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]] ; then
+ name=${BASH_REMATCH[1]##*/}.${BASH_REMATCH[4]}
+ mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
+ else
+ name=${x##*/}
+ mandir=${i18n}man${suffix:0:1}
+ fi
+
+
+ if [[ ${mandir} =~ man[0-9n](f|p|pm)?$ ]] ; then
+ if [[ -s ${x} ]] ; then
+ if [[ ! -d ${D}/usr/share/man/${mandir} ]] ; then
+ install -d "${D}/usr/share/man/${mandir}"
+ fi
+
+ install -m0644 "${x}" "${D}/usr/share/man/${mandir}/${name}"
+ ((ret+=$?))
+ elif [[ ! -e ${x} ]] ; then
+ echo "!!! ${0##*/}: $x does not exist" 1>&2
+ ((++ret))
+ fi
+ else
+ vecho "doman: '${x}' is probably not a man page; skipping" 1>&2
+ ((++ret))
+ fi
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
new file mode 100755
index 00000000..a7ba5775
--- /dev/null
+++ b/bin/ebuild-helpers/domo
@@ -0,0 +1,26 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+mynum=${#}
+if [ ${mynum} -lt 1 ] ; then
+ echo "${0}: at least one argument needed"
+ exit 1
+fi
+if [ ! -d "${D}${DESTTREE}/share/locale" ] ; then
+ install -d "${D}${DESTTREE}/share/locale/"
+fi
+
+for x in "$@" ; do
+ if [ -e "${x}" ] ; then
+ mytiny="${x##*/}"
+ mydir="${D}${DESTTREE}/share/locale/${mytiny%.*}/LC_MESSAGES"
+ if [ ! -d "${mydir}" ] ; then
+ install -d "${mydir}"
+ fi
+ install -m0644 "${x}" "${mydir}/${MOPREFIX}.mo"
+ else
+ echo "!!! ${0##*/}: $x does not exist" 1>&2
+ fi
+done
diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
new file mode 100755
index 00000000..c9e85c0b
--- /dev/null
+++ b/bin/ebuild-helpers/dosbin
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -lt 1 ]] ; then
+ echo "$0: at least one argument needed" 1>&2
+ exit 1
+fi
+
+if [[ ! -d ${D}${DESTTREE}/sbin ]] ; then
+ install -d "${D}${DESTTREE}/sbin" || exit 2
+fi
+
+ret=0
+
+for x in "$@" ; do
+ if [[ -e ${x} ]] ; then
+ install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/sbin"
+ else
+ echo "!!! ${0##*/}: ${x} does not exist" 1>&2
+ false
+ fi
+ ((ret+=$?))
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed
new file mode 100755
index 00000000..abcb15a7
--- /dev/null
+++ b/bin/ebuild-helpers/dosed
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -lt 1 ]] ; then
+ echo "!!! ${0##*/}: at least one argument needed" >&2
+ exit 1
+fi
+
+ret=0
+file_found=0
+mysed="s:${D}::g"
+
+for x in "$@" ; do
+ y=$D${x#/}
+ if [ -e "${y}" ] ; then
+ if [ -f "${y}" ] ; then
+ file_found=1
+ sed -i -e "${mysed}" "${y}"
+ else
+ echo "${y} is not a regular file!" >&2
+ false
+ fi
+ ((ret+=$?))
+ else
+ mysed="${x}"
+ fi
+done
+
+if [ $file_found = 0 ] ; then
+ echo "!!! ${0##*/}: $y does not exist" 1>&2
+ ((ret+=1))
+fi
+
+exit $ret
diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
new file mode 100755
index 00000000..da31246c
--- /dev/null
+++ b/bin/ebuild-helpers/dosym
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ $# -ne 2 ]] ; then
+ echo "$0: two arguments needed" 1>&2
+ exit 1
+fi
+
+destdir=${2%/*}
+[[ ! -d ${D}${destdir} ]] && dodir "${destdir}"
+
+exec ln -snf "$1" "${D}$2"
diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress
new file mode 100755
index 00000000..6fdde571
--- /dev/null
+++ b/bin/ebuild-helpers/ecompress
@@ -0,0 +1,92 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ -z $1 ]] ; then
+ vecho "${0##*/}: at least one argument needed" 1>&2
+ exit 1
+fi
+
+# setup compression stuff
+PORTAGE_COMPRESS=${PORTAGE_COMPRESS-bzip2}
+[[ -z ${PORTAGE_COMPRESS} ]] && exit 0
+
+if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then
+ case ${PORTAGE_COMPRESS} in
+ bzip2|gzip) PORTAGE_COMPRESS_FLAGS="-9";;
+ esac
+fi
+
+case $1 in
+ --suffix)
+ [[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
+
+ if [[ ! -e ${T}/.ecompress.suffix ]] ; then
+ set -e
+ tmpdir="${T}"/.ecompress$$.${RANDOM}
+ mkdir "${tmpdir}"
+ cd "${tmpdir}"
+ # we have to fill the file enough so that there is something
+ # to compress as some programs will refuse to do compression
+ # if it cannot actually compress the file
+ echo {0..1000} > compressme
+ ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
+ suffix=$(ls compressme*)
+ suffix=${suffix#compressme}
+ cd /
+ rm -rf "${tmpdir}"
+ echo "${suffix}" > "${T}/.ecompress.suffix"
+ fi
+ cat "${T}/.ecompress.suffix"
+ ;;
+ --bin)
+ [[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2
+
+ echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
+ ;;
+ --queue)
+ shift
+ exec touch "${@/%/.ecompress.file}"
+ ;;
+ --dequeue)
+ [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
+ find "${D}" -name '*.ecompress.file' -print0 \
+ | sed -e 's:\.ecompress\.file::g' \
+ | ${XARGS} -0 ecompress
+ find "${D}" -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
+ ;;
+ --*)
+ vecho "${0##*/}: unknown arguments '$*'" 1>&2
+ exit 1
+ ;;
+ *)
+ mask_ext_re=""
+ set -f
+ for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do
+ mask_ext_re+="|$x"
+ done
+ set +f
+ mask_ext_re="^(${mask_ext_re:1})\$"
+ declare -a filtered_args=()
+ i=0
+ for x in "$@" ; do
+ [[ ${x##*.} =~ $mask_ext_re ]] && continue
+ filtered_args[$i]=$x
+ (( i++ ))
+ done
+ [ $i -eq 0 ] && exit 0
+ set -- "${filtered_args[@]}"
+
+ # If a compressed version of the file already exists, simply
+ # delete it so that the compressor doesn't whine (bzip2 will
+ # complain and skip, gzip will prompt for input)
+ suffix=$(ecompress --suffix)
+ [[ -n ${suffix} ]] && echo -n "${@/%/${suffix}$'\001'}" | \
+ tr '\001' '\000' | ${XARGS} -0 rm -f
+ # Finally, let's actually do some real work
+ exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
+ ;;
+esac
diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir
new file mode 100755
index 00000000..4dd35e54
--- /dev/null
+++ b/bin/ebuild-helpers/ecompressdir
@@ -0,0 +1,136 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ -z $1 ]] ; then
+ vecho "${0##*/}: at least one argument needed" 1>&2
+ exit 1
+fi
+
+case $1 in
+ --ignore)
+ shift
+ for skip in "$@" ; do
+ [[ -d ${D}${skip} ]] && touch "${D}${skip}.ecompress.skip"
+ done
+ exit 0
+ ;;
+ --queue)
+ shift
+ set -- "${@/%/.ecompress.dir}"
+ set -- "${@/#/${D}}"
+ exec touch "$@"
+ ;;
+ --dequeue)
+ [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
+ find "${D}" -name '*.ecompress.dir' -print0 \
+ | sed -e 's:\.ecompress\.dir::g' -e "s:${D}:/:g" \
+ | ${XARGS} -0 ecompressdir
+ find "${D}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f
+ exit 0
+ ;;
+ --*)
+ vecho "${0##*/}: unknown arguments '$*'"
+ exit 1
+ ;;
+esac
+
+# figure out the new suffix
+suffix=$(ecompress --suffix)
+
+# funk_up_dir(action, suffix, binary)
+# - action: compress or decompress
+# - suffix: the compression suffix to work with
+# - binary: the program to execute that'll compress/decompress
+# The directory we act on is implied in the ${dir} variable
+funk_up_dir() {
+ local act=$1 suffix=$2 binary=$3
+
+ local negate=""
+ [[ ${act} == "compress" ]] && negate="!"
+
+ # first we act on all the files
+ find "${dir}" -type f ${negate} -iname '*'${suffix} -print0 | ${XARGS} -0 ${binary}
+ ((ret+=$?))
+
+ find "${dir}" -type l -print0 | \
+ while read -d $'\0' brokenlink ; do
+ [[ -e ${brokenlink} ]] && continue
+ olddest=$(readlink "${brokenlink}")
+ [[ ${act} == "compress" ]] \
+ && newdest="${olddest}${suffix}" \
+ || newdest="${olddest%${suffix}}"
+ rm -f "${brokenlink}"
+ [[ ${act} == "compress" ]] \
+ && ln -snf "${newdest}" "${brokenlink}${suffix}" \
+ || ln -snf "${newdest}" "${brokenlink%${suffix}}"
+ ((ret+=$?))
+ done
+}
+
+# _relocate_skip_dirs(srctree, dsttree)
+# Move all the directories we want to skip running compression
+# on from srctree to dsttree.
+_relocate_skip_dirs() {
+ local srctree="$1" dsttree="$2"
+
+ [[ -d ${srctree} ]] || return 0
+
+ find "${srctree}" -name '*.ecompress.skip' -print0 | \
+ while read -d $'\0' src ; do
+ src=${src%.ecompress.skip}
+ dst="${dsttree}${src#${srctree}}"
+ parent=${dst%/*}
+ mkdir -p "${parent}"
+ mv "${src}" "${dst}"
+ mv "${src}.ecompress.skip" "${dst}.ecompress.skip"
+ done
+}
+hide_skip_dirs() { _relocate_skip_dirs "${D}" "${T}"/ecompress-skip/ ; }
+restore_skip_dirs() { _relocate_skip_dirs "${T}"/ecompress-skip/ "${D}" ; }
+
+ret=0
+
+rm -rf "${T}"/ecompress-skip
+
+for dir in "$@" ; do
+ dir=${dir#/}
+ dir="${D}${dir}"
+ if [[ ! -d ${dir} ]] ; then
+ vecho "${0##*/}: /${dir#${D}} does not exist!"
+ continue
+ fi
+ cd "${dir}"
+ actual_dir=${dir}
+ dir=. # use relative path to avoid 'Argument list too long' errors
+
+ # hide all the stuff we want to skip
+ hide_skip_dirs "${dir}"
+
+ # since we've been requested to compress the whole dir,
+ # delete any individual queued requests
+ rm -f "${actual_dir}.ecompress.dir"
+ find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
+
+ # not uncommon for packages to compress doc files themselves
+ funk_up_dir "decompress" ".Z" "gunzip -f"
+ funk_up_dir "decompress" ".gz" "gunzip -f"
+ funk_up_dir "decompress" ".bz2" "bunzip2 -f"
+
+ # forcibly break all hard links as some compressors whine about it
+ find "${dir}" -type f -links +1 -exec env file="{}" sh -c \
+ 'cp -p "${file}" "${file}.ecompress.break" ; mv -f "${file}.ecompress.break" "${file}"' \;
+
+ # now lets do our work
+ [[ -z ${suffix} ]] && continue
+ vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${D}}"
+ funk_up_dir "compress" "${suffix}" "ecompress"
+
+ # finally, restore the skipped stuff
+ restore_skip_dirs
+done
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/emake b/bin/ebuild-helpers/emake
new file mode 100755
index 00000000..18d8f089
--- /dev/null
+++ b/bin/ebuild-helpers/emake
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+#
+# emake: Supplies some default parameters to GNU make. At the moment the
+# only parameter supplied is -jN, where N is a number of
+# parallel processes that should be ideal for the running host
+# (e.g. on a single-CPU machine, N=2). The MAKEOPTS variable
+# is set in /etc/make.globals. We don't source
+# /etc/make.globals here because emake is only called from an
+# ebuild.
+
+if [[ $PORTAGE_QUIET != 1 ]] ; then
+ (
+ for arg in ${MAKE:-make} $MAKEOPTS $EXTRA_EMAKE "$@" ; do
+ [[ ${arg} == *" "* ]] \
+ && printf "'%s' " "${arg}" \
+ || printf "%s " "${arg}"
+ done
+ printf "\n"
+ ) >&2
+fi
+
+exec ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
new file mode 100755
index 00000000..766266a1
--- /dev/null
+++ b/bin/ebuild-helpers/fowners
@@ -0,0 +1,9 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# we can't prefix all arguments because
+# chown takes random options
+slash="/"
+exec chown "${@/#${slash}/${D}${slash}}"
diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
new file mode 100755
index 00000000..1d5326ec
--- /dev/null
+++ b/bin/ebuild-helpers/fperms
@@ -0,0 +1,9 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# we can't prefix all arguments because
+# chmod takes random options
+slash="/"
+exec chmod "${@/#${slash}/${D}${slash}}"
diff --git a/bin/ebuild-helpers/newbin b/bin/ebuild-helpers/newbin
new file mode 100755
index 00000000..905b2802
--- /dev/null
+++ b/bin/ebuild-helpers/newbin
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec dobin "${T}/${2}"
diff --git a/bin/ebuild-helpers/newconfd b/bin/ebuild-helpers/newconfd
new file mode 100755
index 00000000..6d57a343
--- /dev/null
+++ b/bin/ebuild-helpers/newconfd
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec doconfd "${T}/${2}"
diff --git a/bin/ebuild-helpers/newdoc b/bin/ebuild-helpers/newdoc
new file mode 100755
index 00000000..331bf0d0
--- /dev/null
+++ b/bin/ebuild-helpers/newdoc
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec dodoc "${T}/${2}"
diff --git a/bin/ebuild-helpers/newenvd b/bin/ebuild-helpers/newenvd
new file mode 100755
index 00000000..2c03e373
--- /dev/null
+++ b/bin/ebuild-helpers/newenvd
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec doenvd "${T}/${2}"
diff --git a/bin/ebuild-helpers/newexe b/bin/ebuild-helpers/newexe
new file mode 100755
index 00000000..32d7d929
--- /dev/null
+++ b/bin/ebuild-helpers/newexe
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec doexe "${T}/${2}"
diff --git a/bin/ebuild-helpers/newinitd b/bin/ebuild-helpers/newinitd
new file mode 100755
index 00000000..7ab89ae0
--- /dev/null
+++ b/bin/ebuild-helpers/newinitd
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec doinitd "${T}/${2}"
diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
new file mode 100755
index 00000000..f235835a
--- /dev/null
+++ b/bin/ebuild-helpers/newins
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" || exit $?
+cp -f "${1}" "${T}/${2}" || exit $?
+doins "${T}/${2}"
+ret=$?
+rm -rf "${T}/${2}"
+exit $ret
diff --git a/bin/ebuild-helpers/newlib.a b/bin/ebuild-helpers/newlib.a
new file mode 100755
index 00000000..ddcb1af2
--- /dev/null
+++ b/bin/ebuild-helpers/newlib.a
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec dolib.a "${T}/${2}"
diff --git a/bin/ebuild-helpers/newlib.so b/bin/ebuild-helpers/newlib.so
new file mode 100755
index 00000000..eb23d267
--- /dev/null
+++ b/bin/ebuild-helpers/newlib.so
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec dolib.so "${T}/${2}"
diff --git a/bin/ebuild-helpers/newman b/bin/ebuild-helpers/newman
new file mode 100755
index 00000000..2d278aed
--- /dev/null
+++ b/bin/ebuild-helpers/newman
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec doman "${T}/${2}"
diff --git a/bin/ebuild-helpers/newsbin b/bin/ebuild-helpers/newsbin
new file mode 100755
index 00000000..cfe75450
--- /dev/null
+++ b/bin/ebuild-helpers/newsbin
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
+ echo "$0: Need two arguments, old file and new file" 1>&2
+ exit 1
+fi
+
+if [ ! -e "$1" ] ; then
+ echo "!!! ${0##*/}: $1 does not exist" 1>&2
+ exit 1
+fi
+
+rm -rf "${T}/${2}" && \
+cp -f "${1}" "${T}/${2}" && \
+exec dosbin "${T}/${2}"
diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq
new file mode 120000
index 00000000..4d1273c4
--- /dev/null
+++ b/bin/ebuild-helpers/portageq
@@ -0,0 +1 @@
+../portageq \ No newline at end of file
diff --git a/bin/ebuild-helpers/prepall b/bin/ebuild-helpers/prepall
new file mode 100755
index 00000000..eec5c814
--- /dev/null
+++ b/bin/ebuild-helpers/prepall
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if type -P chflags > /dev/null && type -P mtree > /dev/null ; then
+ # Save all the file flags for restoration at the end of prepall.
+ mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree"
+ # Remove all the file flags so that prepall can do anything necessary.
+ chflags -R noschg,nouchg,nosappnd,nouappnd "${D}"
+ chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null
+fi
+
+prepallman
+prepallinfo
+
+prepallstrip
+
+if type -P chflags > /dev/null && type -P mtree > /dev/null; then
+ # Restore all the file flags that were saved at the beginning of prepall.
+ mtree -U -e -p "${D}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
+fi
diff --git a/bin/ebuild-helpers/prepalldocs b/bin/ebuild-helpers/prepalldocs
new file mode 100755
index 00000000..c9509d1f
--- /dev/null
+++ b/bin/ebuild-helpers/prepalldocs
@@ -0,0 +1,16 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ -n $1 ]] ; then
+ vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
+fi
+
+cd "${D}"
+[[ -d usr/share/doc ]] || exit 0
+
+ecompressdir --ignore /usr/share/doc/${PF}/html
+ecompressdir --queue /usr/share/doc
diff --git a/bin/ebuild-helpers/prepallinfo b/bin/ebuild-helpers/prepallinfo
new file mode 100755
index 00000000..af95bbfc
--- /dev/null
+++ b/bin/ebuild-helpers/prepallinfo
@@ -0,0 +1,10 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+[[ ! -d ${D}usr/share/info ]] && exit 0
+
+exec prepinfo
diff --git a/bin/ebuild-helpers/prepallman b/bin/ebuild-helpers/prepallman
new file mode 100755
index 00000000..747ed1fa
--- /dev/null
+++ b/bin/ebuild-helpers/prepallman
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+ret=0
+
+find "${D}" -type d -name man > "${T}"/prepallman.filelist
+while read mandir ; do
+ mandir=${mandir#${D}}
+ prepman "${mandir%/man}"
+ ((ret+=$?))
+done < "${T}"/prepallman.filelist
+
+exit ${ret}
diff --git a/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip
new file mode 100755
index 00000000..178ded79
--- /dev/null
+++ b/bin/ebuild-helpers/prepallstrip
@@ -0,0 +1,6 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+exec prepstrip "${D}"
diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
new file mode 100755
index 00000000..582f41fe
--- /dev/null
+++ b/bin/ebuild-helpers/prepinfo
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ -z $1 ]] ; then
+ infodir="/usr/share/info"
+else
+ if [[ -d ${D}$1/share/info ]] ; then
+ infodir="$1/share/info"
+ else
+ infodir="$1/info"
+ fi
+fi
+
+if [[ ! -d ${D}${infodir} ]] ; then
+ if [[ -n $1 ]] ; then
+ vecho "${0##*/}: '${infodir}' does not exist!"
+ exit 1
+ else
+ exit 0
+ fi
+fi
+
+find "${D}${infodir}" -type d -print0 | while read -d $'\0' x ; do
+ rm -f "${x}"/dir{,.info}{,.gz,.bz2}
+done
+
+exec ecompressdir --queue "${infodir}"
diff --git a/bin/ebuild-helpers/preplib b/bin/ebuild-helpers/preplib
new file mode 100755
index 00000000..71446316
--- /dev/null
+++ b/bin/ebuild-helpers/preplib
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+eqawarn "QA Notice: Deprecated call to 'preplib'"
+
+LIBDIR_VAR="LIBDIR_${ABI}"
+if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
+ CONF_LIBDIR="${!LIBDIR_VAR}"
+fi
+unset LIBDIR_VAR
+
+if [ -z "${CONF_LIBDIR}" ]; then
+ # we need this to default to lib so that things dont break
+ CONF_LIBDIR="lib"
+fi
+
+if [ -z "$1" ] ; then
+ z="${D}usr/${CONF_LIBDIR}"
+else
+ z="${D}$1/${CONF_LIBDIR}"
+fi
+
+if [ -d "${z}" ] ; then
+ ldconfig -n -N "${z}"
+fi
diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman
new file mode 100755
index 00000000..af6ad1f8
--- /dev/null
+++ b/bin/ebuild-helpers/prepman
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if [[ -z $1 ]] ; then
+ mandir="${D}usr/share/man"
+else
+ mandir="${D}$1/man"
+fi
+
+if [[ ! -d ${mandir} ]] ; then
+ eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${D}}'"
+ exit 0
+fi
+
+shopt -s nullglob
+
+really_is_mandir=0
+
+# use some heuristics to test if this is a real mandir
+for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
+ [[ -d ${subdir} ]] && really_is_mandir=1 && break
+done
+
+[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --queue "${mandir#${D}}"
+
+exit 0
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
new file mode 100755
index 00000000..977ccec7
--- /dev/null
+++ b/bin/ebuild-helpers/prepstrip
@@ -0,0 +1,178 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+banner=false
+SKIP_STRIP=false
+if hasq nostrip ${FEATURES} || \
+ hasq strip ${RESTRICT}
+then
+ SKIP_STRIP=true
+ banner=true
+ hasq installsources ${FEATURES} || exit 0
+fi
+
+STRIP=${STRIP:-${CHOST}-strip}
+type -P -- ${STRIP} > /dev/null || STRIP=strip
+OBJCOPY=${OBJCOPY:-${CHOST}-objcopy}
+type -P -- ${OBJCOPY} > /dev/null || OBJCOPY=objcopy
+
+# We'll leave out -R .note for now until we can check out the relevance
+# of the section when it has the ALLOC flag set on it ...
+export SAFE_STRIP_FLAGS="--strip-unneeded"
+export PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS} -R .comment}
+
+if hasq installsources ${FEATURES} && ! type -P debugedit >/dev/null ; then
+ ewarn "FEATURES=installsources is enabled but the debugedit binary could not"
+ ewarn "be found. This feature will not work unless debugedit is installed!"
+fi
+
+unset ${!INODE_*}
+
+inode_var_name() {
+ if [[ $USERLAND = BSD ]] ; then
+ stat -f 'INODE_%d_%i' "$1"
+ else
+ stat -c 'INODE_%d_%i' "$1"
+ fi
+}
+
+save_elf_sources() {
+ hasq installsources ${FEATURES} || return 0
+ hasq installsources ${RESTRICT} && return 0
+ type -P debugedit >/dev/null || return 0
+
+ local x=$1
+ local inode=$(inode_var_name "$x")
+ [[ -n ${!inode} ]] && return 0
+ local sources_dir=/usr/src/debug/${CATEGORY}/${PF}
+ debugedit -b "${WORKDIR}" -d "${sources_dir}" \
+ -l "${T}"/debug.sources "${x}"
+ if [[ -s ${T}/debug.sources ]] ; then
+ [[ -d ${D}${sources_dir} ]] || mkdir -p "${D}${sources_dir}"
+ grep -zv '/<built-in>$' "${T}"/debug.sources | \
+ (cd "${WORKDIR}"; LANG=C sort -z -u | \
+ rsync -rtL0 --files-from=- "${WORKDIR}/" "${D}${sources_dir}/" )
+ fi
+}
+
+save_elf_debug() {
+ hasq splitdebug ${FEATURES} || return 0
+
+ local x=$1
+ local y="${D}usr/lib/debug/${x:${#D}}.debug"
+
+ # dont save debug info twice
+ [[ ${x} == *".debug" ]] && return 0
+
+ # this will recompute the build-id, but for now that's ok
+ local buildid="$( type -P debugedit >/dev/null && debugedit -i "${x}" )"
+
+ mkdir -p $(dirname "${y}")
+
+ local inode=$(inode_var_name "$x")
+ if [[ -n ${!inode} ]] ; then
+ ln "${D}usr/lib/debug/${!inode:${#D}}.debug" "$y"
+ else
+ eval $inode=\$x
+ ${OBJCOPY} --only-keep-debug "${x}" "${y}"
+ ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}"
+ [[ -g ${x} ]] && chmod go-r "${y}"
+ [[ -u ${x} ]] && chmod go-r "${y}"
+ chmod a-x,o-w "${y}"
+ fi
+
+ if [[ -n ${buildid} ]] ; then
+ local buildid_dir="${D}usr/lib/debug/.build-id/${buildid:0:2}"
+ local buildid_file="${buildid_dir}/${buildid:2}"
+ mkdir -p "${buildid_dir}"
+ ln -s "../../${x:${#D}}.debug" "${buildid_file}.debug"
+ ln -s "/${x:${#D}}" "${buildid_file}"
+ fi
+}
+
+# The existance of the section .symtab tells us that a binary is stripped.
+# We want to log already stripped binaries, as this may be a QA violation.
+# They prevent us from getting the splitdebug data.
+if ! hasq binchecks ${RESTRICT} && \
+ ! hasq strip ${RESTRICT} ; then
+ log=$T/scanelf-already-stripped.log
+ scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^$D##" > "$log"
+ if [[ -n $QA_PRESTRIPPED && -s $log && \
+ ${QA_STRICT_PRESTRIPPED-unset} = unset ]] ; then
+ shopts=$-
+ set -o noglob
+ for x in $QA_PRESTRIPPED ; do
+ sed -e "s#^${x#/}\$##" -i "$log"
+ done
+ set +o noglob
+ set -$shopts
+ fi
+ sed -e "/^\$/d" -e "s#^#/#" -i "$log"
+ if [[ -s $log ]] ; then
+ vecho -e "\a\n"
+ eqawarn "QA Notice: Pre-stripped files found:"
+ eqawarn "$(<"$log")"
+ else
+ rm -f "$log"
+ fi
+fi
+
+# Now we look for unstripped binaries.
+for x in \
+ $(scanelf -yqRBF '#k%F' -k '.symtab' "$@") \
+ $(find "$@" -type f -name '*.a')
+do
+ if ! ${banner} ; then
+ vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}"
+ banner=true
+ fi
+
+ f=$(file "${x}") || continue
+ [[ -z ${f} ]] && continue
+
+ if ! ${SKIP_STRIP} ; then
+ # The noglob funk is to support STRIP_MASK="/*/booga" and to keep
+ # the for loop from expanding the globs.
+ # The eval echo is to support STRIP_MASK="/*/{booga,bar}" sex.
+ set -o noglob
+ strip_this=true
+ for m in $(eval echo ${STRIP_MASK}) ; do
+ [[ /${x#${D}} == ${m} ]] && strip_this=false && break
+ done
+ set +o noglob
+ else
+ strip_this=false
+ fi
+
+ # only split debug info for final linked objects
+ # or kernel modules as debuginfo for intermediatary
+ # files (think crt*.o from gcc/glibc) is useless and
+ # actually causes problems. install sources for all
+ # elf types though cause that stuff is good.
+
+ if [[ ${f} == *"current ar archive"* ]] ; then
+ vecho " ${x:${#D}}"
+ if ${strip_this} ; then
+ # hmm, can we split debug/sources for .a ?
+ ${STRIP} -g "${x}"
+ fi
+ elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then
+ vecho " ${x:${#D}}"
+ save_elf_sources "${x}"
+ if ${strip_this} ; then
+ save_elf_debug "${x}"
+ ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
+ fi
+ elif [[ ${f} == *"SB relocatable"* ]] ; then
+ vecho " ${x:${#D}}"
+ save_elf_sources "${x}"
+ if ${strip_this} ; then
+ [[ ${x} == *.ko ]] && save_elf_debug "${x}"
+ ${STRIP} ${SAFE_STRIP_FLAGS} "${x}"
+ fi
+ fi
+done
diff --git a/bin/ebuild-helpers/sed b/bin/ebuild-helpers/sed
new file mode 100755
index 00000000..6fc54500
--- /dev/null
+++ b/bin/ebuild-helpers/sed
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Copyright 2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+scriptpath=${BASH_SOURCE[0]}
+scriptname=${scriptpath##*/}
+
+if [[ sed == ${scriptname} ]] && [[ -n ${ESED} ]]; then
+ exec ${ESED} "$@"
+elif type -P g${scriptname} > /dev/null ; then
+ exec g${scriptname} "$@"
+else
+ old_IFS="${IFS}"
+ IFS=":"
+
+ for path in $PATH; do
+ [[ ${path}/${scriptname} == ${scriptpath} ]] && continue
+ if [[ -x ${path}/${scriptname} ]]; then
+ exec ${path}/${scriptname} "$@"
+ exit 0
+ fi
+ done
+
+ IFS="${old_IFS}"
+fi
+
+exit 1