summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Robbins <drobbins@gentoo.org>2000-07-31 02:39:02 +0000
committerDaniel Robbins <drobbins@gentoo.org>2000-07-31 02:39:02 +0000
commitd29cf743ef1d5f5dae478f59520b90df78bf33dd (patch)
tree590dce4b6babfd7f739b5f6ede7efdb916cc004f /sys-apps
parentfixed a keyword expansion thing (diff)
downloadhistorical-d29cf743ef1d5f5dae478f59520b90df78bf33dd.tar.gz
historical-d29cf743ef1d5f5dae478f59520b90df78bf33dd.tar.bz2
historical-d29cf743ef1d5f5dae478f59520b90df78bf33dd.zip
added portage (previously ebuild) to the sys-apps category
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/portage/files/ebuild1254
-rw-r--r--sys-apps/portage/files/ebuild-mine1250
-rw-r--r--sys-apps/portage/files/make.conf50
-rw-r--r--sys-apps/portage/files/merge.py81
-rw-r--r--sys-apps/portage/files/pkgdepend.py221
-rw-r--r--sys-apps/portage/files/queryhost.sh27
-rw-r--r--sys-apps/portage/files/unmerge.py127
-rw-r--r--sys-apps/portage/portage-1.0.ebuild32
8 files changed, 3042 insertions, 0 deletions
diff --git a/sys-apps/portage/files/ebuild b/sys-apps/portage/files/ebuild
new file mode 100644
index 000000000000..9195099853d2
--- /dev/null
+++ b/sys-apps/portage/files/ebuild
@@ -0,0 +1,1254 @@
+#!/bin/bash
+# Copyright 1999-2000 Daniel Robbins, Gentoo Technologies, Inc.
+# Distributed under the GPL
+
+# stuff to add:
+# DISTDIR, WORKDIR (WRKDIR) support (relocatable)
+# PATCHDIR support for src_unpack (to get to patches distributed with the
+# port rather than auto-downloaded. Maybe make it another target ??? nah
+# CATEGORIES - place package in /usr/src/packages/All, symlink from
+# /usr/src/sys/packages/${CATEGORY} for cd-rom distribution
+# add BUILD_DEPENDS
+# add RUN_DEPENDS
+# add LIB_DEPENDS ? (make dependency as library-generic as possible)
+# add
+# possibly add PREFIX support
+# add post-install and post-deinstall (for calling ldconfig, install-int)
+
+export PROXY
+export HTTP_PROXY
+export FTP_PROXY
+
+if [ "`whoami`" != "root" ]
+then
+ echo "Since ebuild can modify critical system files, only root is"
+ echo "allowed to use the ebuild system."
+ exit 1
+fi
+
+source /etc/make.conf
+
+initvars() {
+ #fix up ROOT path so that it always has a / after it
+ local rlen
+ rlen=$(( ${#ROOT} -1 ))
+ if [ "${ROOT:${rlen}:1}" != "/" ]
+ then
+ export ROOT=${ROOT}/
+ fi
+
+
+ DESTTREE=/usr
+ INSDESTTREE=""
+ EXEDESTTREE=""
+ DOCDESTTREE=""
+ INSOPTIONS="-m0644"
+ if [ -n "$DEBUG" ]
+ then
+ EXEOPTIONS="-m0755"
+ else
+ EXEOPTIONS="-m0755 -s"
+ fi
+ LIBOPTIONS="-m0644"
+ MOPREFIX=${P%-*}
+ KVERS=`uname -r`
+}
+
+initvars
+
+src_unpack()
+ {
+ unpack ${A}
+ }
+
+src_compile()
+ {
+ return
+ }
+
+src_install()
+ {
+ return
+ }
+
+pkg_preinst()
+ {
+ return
+ }
+
+pkg_postinst()
+ {
+ return
+ }
+
+pkg_prerm()
+ {
+ return
+ }
+
+pkg_postrm()
+ {
+ return
+ }
+
+bz2unpack()
+ {
+ tar -x --use=bzip2 -f $1
+ }
+
+gzunpack()
+ {
+ tar xzf $1
+ }
+
+pmake()
+ {
+ make ${MAKEOPTS} MAKE="make ${MAKEOPTS}" $*
+ }
+
+use()
+{
+ local x
+ for x in "$USE"
+ do
+ if [ "${1}" = "${x}" ]
+ then
+ echo "${x}"
+ return
+ fi
+ return
+ done
+}
+
+dyn_digest() {
+ local x
+ if [ ! -d ${FILESDIR} ]
+ then
+ install -d ${FILESDIR}
+ fi
+ rm -f ${FILESDIR}/digest
+ for x in ${A}
+ do
+ if [ ! -e ${DISTDIR}/${x} ]
+ then
+ echo '!!! Cannot compute message digests: '${x} not found
+ echo "error, aborting."
+ exit 1
+ else
+ mymd5=`md5sum ${DISTDIR}/${x} | cut -f1 -d" "`
+ echo "MD5 $mymd5 $x" >> ${FILESDIR}/digest
+ fi
+ done
+ echo ">>> Computed message digests."
+}
+
+digest_check() {
+ if [ ! -e ${FILESDIR}/digest ]
+ then
+ echo '!!!'" No message digest file found."
+ echo '!!!'" Maintainer: ebuild digest to update message digests."
+ return 1
+ fi
+ if [ ! -e ${DISTDIR}/${1} ]
+ then
+ echo '!!!'" ${1} not found."
+ echo '!!!'" Ebuild fetch to retrieve files."
+ return 1
+ fi
+ local mycdigest=`grep " ${1}" ${FILESDIR}/digest | cut -f2 -d" "`
+ if [ -z "$mycdigest" ]
+ then
+ echo
+ echo '!!!'" No message digest found for ${1}."
+ echo '!!!'" Maintainer: ebuild digest to update message digests."
+ echo
+ return 1
+ fi
+ local mydigest=`md5sum ${DISTDIR}/${1} | cut -f1 -d" "`
+ if [ "$mycdigest" != "$mydigest" ]
+ then
+ echo
+ echo '!!!'" ${1}: message digests do not match!"
+ echo '!!!'" ${1} is corrupt or incomplete"
+ echo ">>> md5 con ${mycdigest}"
+ echo ">>> md5 now ${mydigest}"
+ echo ">>> Please delete/redownload ${DISTDIR}/${1}"
+ echo
+ return 1
+ else
+ echo ">>> md5 ;-) ${1}"
+ fi
+ return 0
+}
+
+
+dyn_fetch() {
+ local y
+ for y in ${A}
+ do
+ if [ ! -e ${DISTDIR}/${y} ]
+ then
+ echo ">>> Fetching ${y}..."
+ echo
+ local x
+ local _SRC_URI
+ _SRC_URI=`/usr/bin/queryhost.sh "${SRC_URI}"`
+ for x in ${_SRC_URI}
+ do
+ if [ ! -e ${DISTDIR}/${y} ]; then
+ if [ $y == ${x##*/} ]
+ then
+ echo ">>> Trying site ${x}..."
+ eval ${FETCHCOMMAND}
+ if [ $? -ne 0 ]
+ then
+ echo '!!!'" Couldn't download ${y}. Aborting."
+ exit 1
+ fi
+ fi
+ fi
+ done
+ echo
+ fi
+ done
+ for y in ${A}
+ do
+ digest_check ${y}
+ if [ $? -ne 0 ]
+ then
+ exit 1
+ fi
+ done
+}
+
+dyn_unpack() {
+ trap "abort_unpack" SIGINT SIGQUIT
+ local unpackwork="yes"
+ if [ -e ${WORKDIR} ]
+ then
+ local x
+ for x in $A $EBUILD
+ do
+ echo ">>> Checking ${x}'s mtime..."
+ if [ ${DISTDIR}/${x} -nt ${WORKDIR} ]
+ then
+ echo ">>> ${x} has been updated; recreating WORKDIR..."
+ rm -rf ${WORKDIR}
+ break
+ fi
+ done
+ echo ">>> WORKDIR is up-to-date, not unpacking. (clean to force unpack)"
+ unpackwork="no"
+ fi
+ if [ "$unpackwork" = "yes" ]
+ then
+ install -m0700 -d ${WORKDIR}
+ cd ${WORKDIR}
+ echo ">>> Unpacking source..."
+ src_unpack
+ echo ">>> Source unpacked."
+ cd ..
+ fi
+ trap SIGINT SIGQUIT
+}
+
+unpack() {
+ local x
+ for x in "$@"
+ do
+ echo ${x}
+ case "${x##*.}" in
+ gz)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ tgz)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ Z)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ bz2)
+ bz2unpack ${DISTDIR}/${x}
+ ;;
+ tbz2)
+ bz2unpack ${DISTDIR}/${x}
+ ;;
+ *)
+ echo "Archive format not recognized."
+ exit
+ ;;
+ esac
+ done
+}
+
+
+dyn_clean() {
+ if [ -d ${WORKDIR} ]
+ then
+ rm -rf ${WORKDIR}
+ fi
+ if [ -d ${BUILDDIR}/image ]
+ then
+ rm -rf ${BUILDDIR}/image
+ fi
+ rm -rf ${BUILDDIR}/.compiled
+}
+
+into() {
+ if [ $1 = "/" ]
+ then
+ DESTTREE=""
+ else
+ DESTTREE=$1
+ if [ ! -d ${D}${DESTTREE} ]
+ then
+ install -d ${D}${DESTTREE}
+ fi
+ fi
+}
+
+insinto() {
+ if [ $1 = "/" ]
+ then
+ INSDESTTREE=""
+ else
+ INSDESTTREE=$1
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ fi
+}
+
+exeinto() {
+ if [ $1 = "/" ]
+ then
+ EXEDESTTREE=""
+ else
+ EXEDESTTREE=$1
+ if [ ! -d ${D}${EXEDESTTREE} ]
+ then
+ install -d ${D}${EXEDESTTREE}
+ fi
+ fi
+}
+docinto() {
+ if [ $1 = "/" ]
+ then
+ DOCDESTTREE=""
+ else
+ DOCDESTTREE=$1
+ if [ ! -d ${D}usr/doc/${P}/${DOCDESTTREE} ]
+ then
+ install -d ${D}usr/doc/${P}/${DOCDESTTREE}
+ fi
+ fi
+}
+dodoc() {
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ if [ ! -d ${D}/usr/doc/${P} ]
+ then
+ install -d ${D}/usr/doc/${P}
+ fi
+ if [ -z ${DOCDESTTREE} ]
+ then
+ install -m0644 ${x} ${D}/usr/doc/${P}
+ gzip -9 ${D}/usr/doc/${P}/${x##*/}
+ else
+ install -m0644 ${x} ${D}usr/doc/${P}/${DOCDESTTREE}
+ gzip -9 ${D}usr/doc/${P}/${DOCDESTTREE}/${x##*/}
+ fi
+ else
+ echo "${0}: ${x} does not exist."
+ fi
+ done
+}
+
+prepstrip() {
+ if [ -n "${DEBUG}" ]
+ then
+ return
+ fi
+ local x
+ for x in $@
+ do
+ strip ${D}${x}/*
+ done
+}
+
+preplib.so() {
+ if [ -n "${DEBUG}" ]
+ then
+ return
+ fi
+ local x
+ for x in $@
+ do
+ strip --strip-unneeded ${D}${x}/*.so*
+ done
+}
+
+prepinfo() {
+ if [ -z "$1" ]
+ then
+ rm -f ${D}/usr/info/dir
+ gzip -9 ${D}/usr/info/*
+ else
+ rm -f ${D}/$1/info/dir
+ gzip -9 ${D}/$1/info/*
+ fi
+}
+
+prepman() {
+ local x
+ local y
+ if [ -z "$1" ] ; then z=${D}/usr/man ; else z=${D}/$1/man ; fi
+ for x in ${z}/*
+ do
+ local y
+ for y in ${x}/*
+ do
+ if [ -h ${y} ]
+ then
+ #symlink
+ local linkto=`ls -l ${y} | sed -e "s:${D}::" | awk '{ printf ("%s.gz",$11) } '`
+ echo "$linkto $y.gz"
+ ln -sf ${linkto} ${y}.gz
+ rm ${y}
+ else
+ gzip -f -9 ${y}
+ fi
+ done
+ done
+}
+
+
+doman() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ local myloc=$DESTTREE
+ if [ "$myloc" = "" ]
+ then
+ myloc=/usr
+ fi
+ local x
+ for x in "$@"
+ do
+ local md=${x##*.}
+ local mandir
+ mandir=man${md:0:1}
+ if [ -e ${x} ]
+ then
+ if [ ! -d ${D}${myloc}/man/${mandir} ]
+ then
+ install -d ${D}${myloc}/man/${mandir}
+ fi
+ install -m0644 ${x} ${D}${myloc}/man/${mandir}
+ gzip -9 ${D}${myloc}/man/${mandir}/${x##*/}
+ else
+ echo "${0}: ${x} does not exist."
+ fi
+ done
+}
+
+doinfo() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}/usr/info ]
+ then
+ install -d ${D}/usr/info
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0644 ${x} ${D}/usr/info
+ gzip -9 ${D}/usr/info/${x##*/}
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+dolib() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install ${LIBOPTIONS} ${x} ${D}${DESTTREE}/lib
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+#To be used for dynamic .so libraries
+dolib.so() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0755 ${x} ${D}${DESTTREE}/lib
+ if [ -z "$DEBUG" ]
+ then
+ strip --strip-unneeded ${D}${DESTTREE}/lib/${x##*/}
+ fi
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+#To be used for static .a libraries
+dolib.a() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0644 ${x} ${D}${DESTTREE}/lib
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+dobin() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/bin ]
+ then
+ install -d ${D}${DESTTREE}/bin
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -x ${x} ]
+ then
+ if [ -z "$DEBUG" ]
+ then
+ local MYVAL
+ MYVAL=`file ${x} | grep "executable"`
+ if [ -n "$MYVAL" ]
+ then
+ strip ${x}
+ fi
+ fi
+ install ${x} ${D}${DESTTREE}/bin
+ else
+ echo "${0}: ${x} is not executable or does not exist"
+ fi
+ done
+}
+
+dosbin() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/sbin ]
+ then
+ install -d ${D}${DESTTREE}/sbin
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -x ${x} ]
+ then
+ if [ -z "$DEBUG" ]
+ then
+ local MYVAL=`file ${x} | grep "executable"`
+ if [ "$MYVAL" ]
+ then
+ strip ${x}
+ fi
+ fi
+ install -m0754 ${x} ${D}${DESTTREE}/sbin
+ else
+ echo "${0}: ${x} is not executable or does not exist"
+ fi
+ done
+}
+
+#symlink
+dosym() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ local target=${1}
+ local linkname=${2}
+ ln -sf ${target} ${D}${linkname}
+}
+
+#hard link
+dohard() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ local mysrc=${1}
+ local mydest=${2}
+ ln -f ${D}${mysrc} ${D}${mydest}
+}
+
+#mkdir
+dodir() {
+ if [ ${#} -ne 1 ]
+ then
+ echo "${0}: one argument needed"
+ return
+ fi
+ install -d ${D}${1}
+}
+
+fperms() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ chmod ${1} ${D}/${2}
+}
+
+fowners() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ chown ${1} ${D}/${2}
+}
+
+
+insopts() {
+ INSOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ INSOPTIONS="$INSOPTIONS $x"
+ fi
+ done
+}
+
+doins() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -L $x ]
+ then
+ cp $x ${WORKDIR}
+ install ${INSOPTIONS} ${WORKDIR}/${x##*/} ${D}${INSDESTTREE}
+ else
+ install ${INSOPTIONS} ${x} ${D}${INSDESTTREE}
+ fi
+ done
+}
+
+newdoc() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dodoc ${T}/${2}
+}
+
+newman() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doman ${T}/${2}
+}
+
+newexe() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doexe ${T}/${2}
+}
+
+newbin() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dobin ${T}/${2}
+}
+
+newlib.so() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dolib.so ${T}/${2}
+}
+
+newlib.a() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dolib.a ${T}/${2}
+}
+
+newsbin() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dosbin ${T}/${2}
+}
+
+newins() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doins ${T}/${2}
+}
+
+donewins() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ install -D ${INSOPTIONS} ${1} ${D}${INSDESTTREE}/${2}
+
+}
+
+exeopts() {
+ EXEOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ EXEOPTIONS="$EXEOPTIONS $x"
+ fi
+ done
+}
+
+libopts() {
+ LIBOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ LIBOPTIONS="$LIBOPTIONS $x"
+ fi
+ done
+}
+
+doexe() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${EXEDESTTREE} ]
+ then
+ install -d ${D}${EXEDESTTREE}
+ fi
+ local x
+ for x in "$@"
+ do
+ install ${EXEOPTIONS} ${x} ${D}${EXEDESTTREE}
+ done
+}
+
+domo() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/share/locale ]
+ then
+ install -d ${D}${DESTTREE}/share/locale/
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ local mytiny=${x##*/}
+ local 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"
+ fi
+ done
+}
+
+abort_compile() {
+ echo
+ echo '*** Compilation Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .compiled
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_unpack() {
+ echo
+ echo '*** Unpack Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .unpacked
+ rm -rf work
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_package() {
+ echo
+ echo '*** Packaging Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .packaged
+ rm -f ${PKGDIR}/All/${P}.t*
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_image() {
+ echo
+ echo '*** Imaging Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -rf image
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+dyn_compile() {
+ trap "abort_compile" SIGINT SIGQUIT
+ export CFLAGS CXXFLAGS LIBCFLAGS LIBCXXFLAGS
+ if [ ${BUILDDIR}/.compiled -nt ${WORKDIR} ]
+ then
+ echo ">>> It appears that ${P} is already compiled. skipping."
+ echo ">>> (clean to force compilation)"
+ trap SIGINT SIGQUIT
+ return
+ fi
+ cd ${S}
+ src_compile
+ cd ${BUILDDIR}
+ touch .compiled
+ trap SIGINT SIGQUIT
+}
+
+dyn_pkginfo() {
+ local PNAME=${P}.${PACKAGE}
+ echo ${P} ${PKGDIR}/All ${PKGDIR}/All/${PNAME}
+}
+
+dyn_package() {
+ trap "abort_package" SIGINT SIGQUIT
+ cd ${BUILDDIR}/image
+ local PNAME=${P}.${PACKAGE}
+ echo ">>> Creating ${PNAME} in ${PKGDIR}/All..."
+ if [ ! -e ${PKGDIR} ]
+ then
+ mkdir ${PKGDIR}
+ fi
+ if [ ! -e ${PKGDIR}/All ]
+ then
+ mkdir ${PKGDIR}/All
+ fi
+ if [ "$PACKAGE" = "tbz2" ]
+ then
+ tar cvf ${PKGDIR}/All/${P}.tar *
+ bzip2 ${PKGDIR}/All/${P}.tar
+ mv ${PKGDIR}/All/${P}.tar.bz2 ${PKGDIR}/All/${PNAME}
+ elif [ "$PACKAGE" = "tgz" ]
+ then
+ tar czvf ${PKGDIR}/All/${PNAME} *
+ else
+ echo '!!! Package format '${PACKAGE}' not recognized. Please correct /etc/make.conf'
+ exit 1
+ fi
+ if [ ! -e ${PKGDIR}/${CATEGORY} ]
+ then
+ mkdir ${PKGDIR}/${CATEGORY}
+ fi
+ ln -sf ${PKGDIR}/All/${PNAME} ${PKGDIR}/${CATEGORY}/${PNAME}
+ echo ">>> Done."
+ cd ${BUILDDIR}
+ touch .packaged
+ trap SIGINT SIGQUIT
+}
+
+dyn_install() {
+ trap "abort_image" SIGINT SIGQUIT
+ rm -rf ${BUILDDIR}/image
+ mkdir ${BUILDDIR}/image
+ cd ${S}
+ echo
+ echo ">>> Install ${P} into ${D}"
+ src_install
+ install -d -m0700 ${D}/var/db/pkg/${P}
+ cp ${STARTDIR}/${EBUILD} ${D}/var/db/pkg/${P}
+ echo ">>> Completed installing into ${D}"
+ echo
+ cd ${BUILDDIR}
+ trap SIGINT SIGQUIT
+}
+
+dyn_merge() {
+ trap "" SIGINT SIGQUIT
+ #not interruptible, so that the db doesn't get garbled
+ if [ -d ${ROOT}/var/db/pkg/${P} ]
+ then
+ echo
+ echo '!!!' "${P} already merged -- unmerge first"
+ echo
+ exit 1
+ fi
+ echo
+ pkg_preinst
+ /usr/sbin/merge.py
+ cd ${BUILDDIR}
+ #zap it so that people don't look at a bad image and get confused
+ rm -rf image
+ pkg_postinst
+ trap SIGINT SIGQUIT
+}
+
+dyn_unmerge() {
+ trap "" SIGINT SIGQUIT
+ #stub unmerge function for now
+ cd ${BUILDDIR}
+ /usr/sbin/unmerge.py ${P}
+ if [ $? -ne 0 ]
+ then
+ exit
+ fi
+ trap SIGINT_SIGQUIT
+}
+
+dyn_spec() {
+
+ tar czf /usr/src/redhat/SOURCES/${P}.tar.gz ${P}.* files
+
+ local V
+
+ V=${P#${O##*/}*}
+ V=${V/[!digit]/}
+ V=${V/-/.}
+
+ cat <<__END1__ > ${P}.spec
+Summary: ${DESCRIPTION}
+Name: ${O##*/}
+Version: ${V}
+Release: 1
+Copyright: GPL
+Group: portage/${CATEGORY}
+Source: ${P}.tar.gz
+Buildroot: ${D}
+%description
+${DESCRIPTION}
+
+%prep
+%setup -c
+
+%build
+
+%install
+
+%clean
+
+%files
+/
+__END1__
+
+}
+dyn_rpm () {
+ dyn_spec
+ rpm -bb ${P}.spec
+ local V
+
+ V=${P#${O##*/}*}
+ V=${V/[!digit]/}
+ V=${V/-/.}
+ local W
+ W="portage/${CATEGORY}"
+
+ install -D /usr/src/redhat/RPMS/i386/${O##*/}-${V}-1.i386.rpm ${RPMDIR}/${W}/${O##*/}-${V}.rpm
+}
+
+dyn_help() {
+ echo
+ echo "Portage v1.1"
+ echo "Copyright 2000 Gentoo Technologies, Inc."
+ echo
+ echo "How to use the ebuild command:"
+ echo
+ echo "The first argument to ebuild should be an existing .ebuild file."
+ echo
+ echo "One or more of the following options can then be specified. If more"
+ echo "than one option is specified, each will be executed in order."
+ echo
+ echo " fetch : download source archive(s) and patches"
+ echo " unpack : unpack/patch sources (auto-fetch if needed)"
+ echo " compile : compile sources (auto-fetch/unpack if needed)"
+ echo " merge : merge image into live filesystem, recording files in db"
+ echo " (auto-fetch/unpack/compile if needed)"
+ echo " unmerge : remove package from live filesystem"
+ echo " clean : clean up all source and temporary files"
+ echo
+ echo "The following settings will be used for the ebuild process:"
+ echo
+ echo " package : ${P}" "( \${P} )"
+ echo " description : ${DESCRIPTION}"
+ echo " system : ${CHOST}" "( \${CHOST} )"
+ echo " c flags : ${CFLAGS}" "( \${CFLAGS} )"
+ echo " c++ flags : ${CXXFLAGS}" "( \${CXXFLAGS} )"
+ echo " make flags : ${MAKEOPTS}" "( \${MAKEOPTS} )"
+ echo -n " build mode : "
+ if [ -n "${DEBUG}" ]
+ then
+ echo "debug (large)"
+ else
+ echo "production (stripped)"
+ fi
+ echo " merge to : ${ROOT}" "( \${ROOT} )"
+ echo " db location : ${ROOT}var/db/pkg/${P}/CONTENTS"
+ echo
+ if [ -n "$USE" ]
+ then
+ echo "Additionally, support for the following toolkits will be enabled if necessary:"
+ echo
+ echo " ${USE}"
+ fi
+ echo
+}
+
+src_menu() {
+ MYDIR=${BUILDDIR}
+ if [ "$1" = "p" ]
+ then
+ echo ${P}
+ exit 0
+ fi
+
+ local MYfoo
+ for MYfoo in "$@"
+ do
+ case "${MYfoo}" in
+ noop)
+ ;;
+ unpack)
+ dyn_fetch
+ dyn_unpack
+ ;;
+ compile)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ ;;
+ prerm|postrm|preinst|postinst)
+ pkg_${MYfoo}
+ ;;
+ help|clean|fetch|digest|pkginfo|pkgloc|unmerge)
+ dyn_${MYfoo}
+ ;;
+ package)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ dyn_install
+ dyn_package
+ ;;
+ merge)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ dyn_install
+ dyn_merge
+ ;;
+ rpm)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ dyn_install
+ dyn_rpm
+ ;;
+ *)
+ echo "Please specify a valid command."
+ echo
+ dyn_help
+ esac
+ done
+ cd $MYDIR
+}
+
+#dummy value for help printouts
+P=packagename
+
+if [ $# -lt 2 ]
+then
+ echo
+ echo '!!!' "At least two arguments expected."
+ dyn_help
+ exit 1
+fi
+
+if [ ! -e ${1} ]
+then
+ echo
+ echo '!!!' "${1} not found."
+ dyn_help
+ exit 1
+fi
+
+export STARTDIR=`pwd`
+export O=`dirname ${STARTDIR}/${1}`
+export EBUILD=${1}
+export PEBUILD=${O}/files/${PLATFORM}.ebuild
+export FILESDIR=${O}/files
+
+source ${1}
+if [ -e ${PEBUILD} ]
+then
+ source ${PEBUILD}
+fi
+
+if [ -z "$FETCHCOMMAND" ]
+then
+ FETCHCOMMAND="/usr/bin/wget --passive-ftp \${x} -P \${DISTDIR}"
+fi
+
+if [ ! -z ${BUILD_PREFIX} ]
+then
+ export BUILDDIR=${BUILD_PREFIX}/${CATEGORY}/${P}
+else
+ export BUILDDIR=${O}
+fi
+if [ ! -d ${BUILDDIR} ]
+then
+ install -d ${BUILDDIR}
+fi
+
+export T=${BUILDDIR}/temp
+if [ ! -d ${T} ]
+then
+ install -d ${T}
+fi
+export WORKDIR=${BUILDDIR}/work
+export D=${BUILDDIR}/image
+dlen=$(( ${#D} -1 ))
+if [ "${D:${dlen}:1}" != "/" ]
+then
+ export D=${D}/
+fi
+
+if [ -z ${DISTDIR} ]
+then
+ export DISTDIR=/usr/portage/distfiles
+fi
+if [ -z ${PKGDIR} ]
+then
+ export PKGDIR=/usr/portage/packages
+fi
+
+source ${1}
+if [ -e ${PEBUILD} ]
+then
+ source ${PEBUILD}
+fi
+
+export P
+
+# Set Perl-Installation Enviroment
+
+for i in ARCHLIB PRIVLIB BIN MAN1DIR MAN3DIR SCRIPT SITEARCH SITELIB
+do
+ install=`echo $i | awk '{ printf "%s%s","install",tolower($1) }'`
+ install=`perl "-V:$install" | sed -e "s:.*/image/\(.*\)'\;:\1:"`
+ PERLINSTALL=`echo INSTALL$i=$D$install $PERLINSTALL`
+done
+export PERLINSTALL
+
+foo=2
+while [ $foo -le $# ]
+do
+eval "src_menu \${${foo}}"
+if [ $? -ne 0 ]
+then
+ echo "***error***"
+ exit 1
+fi
+foo=$(( $foo + 1))
+done
diff --git a/sys-apps/portage/files/ebuild-mine b/sys-apps/portage/files/ebuild-mine
new file mode 100644
index 000000000000..162f0c6a4d3b
--- /dev/null
+++ b/sys-apps/portage/files/ebuild-mine
@@ -0,0 +1,1250 @@
+#!/bin/bash
+# Copyright 1999-2000 Daniel Robbins, Gentoo Technologies, Inc.
+# Distributed under the GPL
+
+# stuff to add:
+# DISTDIR, WORKDIR (WRKDIR) support (relocatable)
+# PATCHDIR support for src_unpack (to get to patches distributed with the
+# port rather than auto-downloaded. Maybe make it another target ??? nah
+# CATEGORIES - place package in /usr/src/packages/All, symlink from
+# /usr/src/sys/packages/${CATEGORY} for cd-rom distribution
+# add BUILD_DEPENDS
+# add RUN_DEPENDS
+# add LIB_DEPENDS ? (make dependency as library-generic as possible)
+# add
+# possibly add PREFIX support
+# add post-install and post-deinstall (for calling ldconfig, install-int)
+
+export PROXY
+export HTTP_PROXY
+export FTP_PROXY
+
+if [ "`whoami`" != "root" ]
+then
+ echo "Since ebuild can modify critical system files, only root is"
+ echo "allowed to use the ebuild system."
+ exit 1
+fi
+
+source /etc/make.conf
+
+initvars() {
+ #fix up ROOT path so that it always has a / after it
+ local rlen
+ rlen=$(( ${#ROOT} -1 ))
+ if [ "${ROOT:${rlen}:1}" != "/" ]
+ then
+ export ROOT=${ROOT}/
+ fi
+
+
+ DESTTREE=/usr
+ INSDESTTREE=""
+ EXEDESTTREE=""
+ DOCDESTTREE=""
+ INSOPTIONS="-m0644"
+ if [ -n "$DEBUG" ]
+ then
+ EXEOPTIONS="-m0755"
+ else
+ EXEOPTIONS="-m0755 -s"
+ fi
+ LIBOPTIONS="-m0644"
+ MOPREFIX=${P%-*}
+ KVERS=`uname -r`
+}
+
+initvars
+
+src_unpack()
+ {
+ unpack ${A}
+ }
+
+src_compile()
+ {
+ return
+ }
+
+src_install()
+ {
+ return
+ }
+
+pkg_preinst()
+ {
+ return
+ }
+
+pkg_postinst()
+ {
+ return
+ }
+
+pkg_prerm()
+ {
+ return
+ }
+
+pkg_postrm()
+ {
+ return
+ }
+
+bz2unpack()
+ {
+ tar -x --use=bzip2 -f $1
+ }
+
+gzunpack()
+ {
+ tar xzf $1
+ }
+
+pmake()
+ {
+ make ${MAKEOPTS} MAKE="make ${MAKEOPTS}" $*
+ }
+
+use()
+{
+ local x
+ for x in "$USE"
+ do
+ if [ "${1}" = "${x}" ]
+ then
+ echo "${x}"
+ return
+ fi
+ return
+ done
+}
+
+dyn_digest() {
+ local x
+ if [ ! -d ${FILESDIR} ]
+ then
+ install -d ${FILESDIR}
+ fi
+ rm -f ${FILESDIR}/digest
+ for x in ${A}
+ do
+ if [ ! -e ${DISTDIR}/${x} ]
+ then
+ echo '!!! Cannot compute message digests: '${x} not found
+ echo "error, aborting."
+ exit 1
+ else
+ mymd5=`md5sum ${DISTDIR}/${x} | cut -f1 -d" "`
+ echo "MD5 $mymd5 $x" >> ${FILESDIR}/digest
+ fi
+ done
+ echo ">>> Computed message digests."
+}
+
+digest_check() {
+ if [ ! -e ${FILESDIR}/digest ]
+ then
+ echo '!!!'" No message digest file found."
+ echo '!!!'" Maintainer: ebuild digest to update message digests."
+ return 1
+ fi
+ if [ ! -e ${DISTDIR}/${1} ]
+ then
+ echo '!!!'" ${1} not found."
+ echo '!!!'" Ebuild fetch to retrieve files."
+ return 1
+ fi
+ local mycdigest=`grep " ${1}" ${FILESDIR}/digest | cut -f2 -d" "`
+ if [ -z "$mycdigest" ]
+ then
+ echo
+ echo '!!!'" No message digest found for ${1}."
+ echo '!!!'" Maintainer: ebuild digest to update message digests."
+ echo
+ return 1
+ fi
+ local mydigest=`md5sum ${DISTDIR}/${1} | cut -f1 -d" "`
+ if [ "$mycdigest" != "$mydigest" ]
+ then
+ echo
+ echo '!!!'" ${1}: message digests do not match!"
+ echo '!!!'" ${1} is corrupt or incomplete"
+ echo ">>> md5 con ${mycdigest}"
+ echo ">>> md5 now ${mydigest}"
+ echo ">>> Please delete/redownload ${DISTDIR}/${1}"
+ echo
+ return 1
+ else
+ echo ">>> md5 ;-) ${1}"
+ fi
+ return 0
+}
+
+
+dyn_fetch() {
+ local y
+ for y in ${A}
+ do
+ if [ ! -e ${DISTDIR}/${y} ]
+ then
+ echo ">>> Fetching ${y}..."
+ echo
+ local x
+ local _SRC_URI
+ _SRC_URI=`/usr/bin/queryhost.sh "${SRC_URI}"`
+ for x in ${_SRC_URI}
+ do
+ if [ $y == ${x##*/} ]
+ then
+ echo ">>> Trying site ${x}..."
+ eval ${FETCHCOMMAND}
+ if [ $? -ne 0 ]
+ then
+ echo '!!!'" Couldn't download ${y}. Aborting."
+ exit 1
+ fi
+ fi
+ done
+ echo
+ fi
+ done
+ for y in ${A}
+ do
+ digest_check ${y}
+ if [ $? -ne 0 ]
+ then
+ exit 1
+ fi
+ done
+}
+
+dyn_unpack() {
+ trap "abort_unpack" SIGINT SIGQUIT
+ local unpackwork="yes"
+ if [ -e ${WORKDIR} ]
+ then
+ local x
+ for x in $A $EBUILD
+ do
+ echo ">>> Checking ${x}'s mtime..."
+ if [ ${DISTDIR}/${x} -nt ${WORKDIR} ]
+ then
+ echo ">>> ${x} has been updated; recreating WORKDIR..."
+ rm -rf ${WORKDIR}
+ break
+ fi
+ done
+ echo ">>> WORKDIR is up-to-date, not unpacking. (clean to force unpack)"
+ unpackwork="no"
+ fi
+ if [ "$unpackwork" = "yes" ]
+ then
+ install -m0700 -d ${WORKDIR}
+ cd ${WORKDIR}
+ echo ">>> Unpacking source..."
+ src_unpack
+ echo ">>> Source unpacked."
+ cd ..
+ fi
+ trap SIGINT SIGQUIT
+}
+
+unpack() {
+ local x
+ for x in "$@"
+ do
+ echo ${x}
+ case "${x##*.}" in
+ gz)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ tgz)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ Z)
+ gzunpack ${DISTDIR}/${x}
+ ;;
+ bz2)
+ bz2unpack ${DISTDIR}/${x}
+ ;;
+ tbz2)
+ bz2unpack ${DISTDIR}/${x}
+ ;;
+ *)
+ echo "Archive format not recognized."
+ exit
+ ;;
+ esac
+ done
+}
+
+
+dyn_clean() {
+ if [ -d ${WORKDIR} ]
+ then
+ rm -rf ${WORKDIR}
+ fi
+ if [ -d ${BUILDDIR}/image ]
+ then
+ rm -rf ${BUILDDIR}/image
+ fi
+ rm -rf ${BUILDDIR}/.compiled
+}
+
+into() {
+ if [ $1 = "/" ]
+ then
+ DESTTREE=""
+ else
+ DESTTREE=$1
+ if [ ! -d ${D}${DESTTREE} ]
+ then
+ install -d ${D}${DESTTREE}
+ fi
+ fi
+}
+
+insinto() {
+ if [ $1 = "/" ]
+ then
+ INSDESTTREE=""
+ else
+ INSDESTTREE=$1
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ fi
+}
+
+exeinto() {
+ if [ $1 = "/" ]
+ then
+ EXEDESTTREE=""
+ else
+ EXEDESTTREE=$1
+ if [ ! -d ${D}${EXEDESTTREE} ]
+ then
+ install -d ${D}${EXEDESTTREE}
+ fi
+ fi
+}
+docinto() {
+ if [ $1 = "/" ]
+ then
+ DOCDESTTREE=""
+ else
+ DOCDESTTREE=$1
+ if [ ! -d ${D}usr/doc/${P}/${DOCDESTTREE} ]
+ then
+ install -d ${D}usr/doc/${P}/${DOCDESTTREE}
+ fi
+ fi
+}
+dodoc() {
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ if [ ! -d ${D}/usr/doc/${P} ]
+ then
+ install -d ${D}/usr/doc/${P}
+ fi
+ if [ -z ${DOCDESTTREE} ]
+ then
+ install -m0644 ${x} ${D}/usr/doc/${P}
+ gzip -9 ${D}/usr/doc/${P}/${x##*/}
+ else
+ install -m0644 ${x} ${D}usr/doc/${P}/${DOCDESTTREE}
+ gzip -9 ${D}usr/doc/${P}/${DOCDESTTREE}/${x##*/}
+ fi
+ else
+ echo "${0}: ${x} does not exist."
+ fi
+ done
+}
+
+prepstrip() {
+ if [ -n "${DEBUG}" ]
+ then
+ return
+ fi
+ local x
+ for x in $@
+ do
+ strip ${D}${x}/*
+ done
+}
+
+preplib.so() {
+ if [ -n "${DEBUG}" ]
+ then
+ return
+ fi
+ local x
+ for x in $@
+ do
+ strip --strip-unneeded ${D}${x}/*.so*
+ done
+}
+
+prepinfo() {
+ if [ -z "$1" ]
+ then
+ rm -f ${D}/usr/info/dir
+ gzip -9 ${D}/usr/info/*
+ else
+ rm -f ${D}/$1/info/dir
+ gzip -9 ${D}/$1/info/*
+ fi
+}
+
+prepman() {
+ local x
+ local y
+ if [ -z "$1" ] ; then z=${D}/usr/man ; else z=${D}/$1/man ; fi
+ for x in ${z}/*
+ do
+ local y
+ for y in ${x}/*
+ do
+ if [ -h ${y} ]
+ then
+ #symlink
+ local linkto=`ls -l ${y} | sed -e "s:${D}::" | awk '{ printf ("%s.gz",$11) } '`
+ echo "$linkto $y.gz"
+ ln -sf ${linkto} ${y}.gz
+ rm ${y}
+ else
+ gzip -f -9 ${y}
+ fi
+ done
+ done
+}
+
+
+doman() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ local myloc=$DESTTREE
+ if [ "$myloc" = "" ]
+ then
+ myloc=/usr
+ fi
+ local x
+ for x in "$@"
+ do
+ local md=${x##*.}
+ local mandir
+ mandir=man${md:0:1}
+ if [ -e ${x} ]
+ then
+ if [ ! -d ${D}${myloc}/man/${mandir} ]
+ then
+ install -d ${D}${myloc}/man/${mandir}
+ fi
+ install -m0644 ${x} ${D}${myloc}/man/${mandir}
+ gzip -9 ${D}${myloc}/man/${mandir}/${x##*/}
+ else
+ echo "${0}: ${x} does not exist."
+ fi
+ done
+}
+
+doinfo() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}/usr/info ]
+ then
+ install -d ${D}/usr/info
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0644 ${x} ${D}/usr/info
+ gzip -9 ${D}/usr/info/${x##*/}
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+dolib() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install ${LIBOPTIONS} ${x} ${D}${DESTTREE}/lib
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+#To be used for dynamic .so libraries
+dolib.so() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0755 ${x} ${D}${DESTTREE}/lib
+ if [ -z "$DEBUG" ]
+ then
+ strip --strip-unneeded ${D}${DESTTREE}/lib/${x##*/}
+ fi
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+#To be used for static .a libraries
+dolib.a() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/lib ]
+ then
+ install -d ${D}${DESTTREE}/lib
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ install -m0644 ${x} ${D}${DESTTREE}/lib
+ else
+ echo "${0}: ${x} does not exist"
+ fi
+ done
+}
+
+dobin() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/bin ]
+ then
+ install -d ${D}${DESTTREE}/bin
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -x ${x} ]
+ then
+ if [ -z "$DEBUG" ]
+ then
+ local MYVAL
+ MYVAL=`file ${x} | grep "executable"`
+ if [ -n "$MYVAL" ]
+ then
+ strip ${x}
+ fi
+ fi
+ install ${x} ${D}${DESTTREE}/bin
+ else
+ echo "${0}: ${x} is not executable or does not exist"
+ fi
+ done
+}
+
+dosbin() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/sbin ]
+ then
+ install -d ${D}${DESTTREE}/sbin
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -x ${x} ]
+ then
+ if [ -z "$DEBUG" ]
+ then
+ local MYVAL=`file ${x} | grep "executable"`
+ if [ "$MYVAL" ]
+ then
+ strip ${x}
+ fi
+ fi
+ install -m0754 ${x} ${D}${DESTTREE}/sbin
+ else
+ echo "${0}: ${x} is not executable or does not exist"
+ fi
+ done
+}
+
+#symlink
+dosym() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ local target=${1}
+ local linkname=${2}
+ ln -sf ${target} ${D}${linkname}
+}
+
+#hard link
+dohard() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ local mysrc=${1}
+ local mydest=${2}
+ ln -f ${D}${mysrc} ${D}${mydest}
+}
+
+#mkdir
+dodir() {
+ if [ ${#} -ne 1 ]
+ then
+ echo "${0}: one argument needed"
+ return
+ fi
+ install -d ${D}${1}
+}
+
+fperms() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ chmod ${1} ${D}/${2}
+}
+
+fowners() {
+ if [ ${#} -ne 2 ]
+ then
+ echo "${0}: two arguments needed"
+ return
+ fi
+ chown ${1} ${D}/${2}
+}
+
+
+insopts() {
+ INSOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ INSOPTIONS="$INSOPTIONS $x"
+ fi
+ done
+}
+
+doins() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -L $x ]
+ then
+ cp $x ${WORKDIR}
+ install ${INSOPTIONS} ${WORKDIR}/${x##*/} ${D}${INSDESTTREE}
+ else
+ install ${INSOPTIONS} ${x} ${D}${INSDESTTREE}
+ fi
+ done
+}
+
+newdoc() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dodoc ${T}/${2}
+}
+
+newman() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doman ${T}/${2}
+}
+
+newexe() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doexe ${T}/${2}
+}
+
+newbin() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dobin ${T}/${2}
+}
+
+newlib.so() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dolib.so ${T}/${2}
+}
+
+newlib.a() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dolib.a ${T}/${2}
+}
+
+newsbin() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ dosbin ${T}/${2}
+}
+
+newins() {
+ rm -rf ${T}/${2}
+ cp ${1} ${T}/${2}
+ doins ${T}/${2}
+}
+
+donewins() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${INSDESTTREE} ]
+ then
+ install -d ${D}${INSDESTTREE}
+ fi
+ install -D ${INSOPTIONS} ${1} ${D}${INSDESTTREE}/${2}
+
+}
+
+exeopts() {
+ EXEOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ EXEOPTIONS="$EXEOPTIONS $x"
+ fi
+ done
+}
+
+libopts() {
+ LIBOPTIONS=""
+ for x in $*
+ do
+ #if we have a debug build, let's not strip anything
+ if [ -n "$DEBUG" ] && [ "$x" = "-s" ]
+ then
+ continue
+ else
+ LIBOPTIONS="$LIBOPTIONS $x"
+ fi
+ done
+}
+
+doexe() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${EXEDESTTREE} ]
+ then
+ install -d ${D}${EXEDESTTREE}
+ fi
+ local x
+ for x in "$@"
+ do
+ install ${EXEOPTIONS} ${x} ${D}${EXEDESTTREE}
+ done
+}
+
+domo() {
+ local mynum=${#}
+ if [ ${mynum} -lt 1 ]
+ then
+ echo "${0}: at least one argument needed"
+ return
+ fi
+ if [ ! -d ${D}${DESTTREE}/share/locale ]
+ then
+ install -d ${D}${DESTTREE}/share/locale/
+ fi
+ local x
+ for x in "$@"
+ do
+ if [ -e ${x} ]
+ then
+ local mytiny=${x##*/}
+ local 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"
+ fi
+ done
+}
+
+abort_compile() {
+ echo
+ echo '*** Compilation Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .compiled
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_unpack() {
+ echo
+ echo '*** Unpack Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .unpacked
+ rm -rf work
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_package() {
+ echo
+ echo '*** Packaging Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -f .packaged
+ rm -f ${PKGDIR}/All/${P}.t*
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+abort_image() {
+ echo
+ echo '*** Imaging Aborted ***'
+ echo
+ cd ${BUILDDIR} #original dir
+ rm -rf image
+ trap SIGINT SIGQUIT
+ exit 1
+}
+
+dyn_compile() {
+ trap "abort_compile" SIGINT SIGQUIT
+ export CFLAGS CXXFLAGS LIBCFLAGS LIBCXXFLAGS
+ if [ ${BUILDDIR}/.compiled -nt ${WORKDIR} ]
+ then
+ echo ">>> It appears that ${P} is already compiled. skipping."
+ echo ">>> (clean to force compilation)"
+ trap SIGINT SIGQUIT
+ return
+ fi
+ cd ${S}
+ src_compile
+ cd ${BUILDDIR}
+ touch .compiled
+ trap SIGINT SIGQUIT
+}
+
+dyn_pkginfo() {
+ local PNAME=${P}.${PACKAGE}
+ echo ${P} ${PKGDIR}/All ${PKGDIR}/All/${PNAME}
+}
+
+dyn_package() {
+ trap "abort_package" SIGINT SIGQUIT
+ cd ${BUILDDIR}/image
+ local PNAME=${P}.${PACKAGE}
+ echo ">>> Creating ${PNAME} in ${PKGDIR}/All..."
+ if [ ! -e ${PKGDIR} ]
+ then
+ mkdir ${PKGDIR}
+ fi
+ if [ ! -e ${PKGDIR}/All ]
+ then
+ mkdir ${PKGDIR}/All
+ fi
+ if [ "$PACKAGE" = "tbz2" ]
+ then
+ tar cvf ${PKGDIR}/All/${P}.tar *
+ bzip2 ${PKGDIR}/All/${P}.tar
+ mv ${PKGDIR}/All/${P}.tar.bz2 ${PKGDIR}/All/${PNAME}
+ elif [ "$PACKAGE" = "tgz" ]
+ then
+ tar czvf ${PKGDIR}/All/${PNAME} *
+ else
+ echo '!!! Package format '${PACKAGE}' not recognized. Please correct /etc/make.conf'
+ exit 1
+ fi
+ if [ ! -e ${PKGDIR}/${CATEGORY} ]
+ then
+ mkdir ${PKGDIR}/${CATEGORY}
+ fi
+ ln -sf ${PKGDIR}/All/${PNAME} ${PKGDIR}/${CATEGORY}/${PNAME}
+ echo ">>> Done."
+ cd ${BUILDDIR}
+ touch .packaged
+ trap SIGINT SIGQUIT
+}
+
+dyn_install() {
+ trap "abort_image" SIGINT SIGQUIT
+ rm -rf ${BUILDDIR}/image
+ mkdir ${BUILDDIR}/image
+ cd ${S}
+ echo
+ echo ">>> Install ${P} into ${D}"
+ src_install
+ install -d -m0700 ${D}/var/db/pkg/${P}
+ cp ${STARTDIR}/${EBUILD} ${D}/var/db/pkg/${P}
+ echo ">>> Completed installing into ${D}"
+ echo
+ cd ${BUILDDIR}
+ trap SIGINT SIGQUIT
+}
+
+dyn_merge() {
+ trap "" SIGINT SIGQUIT
+ #not interruptible, so that the db doesn't get garbled
+ if [ -d ${ROOT}/var/db/pkg/${P} ]
+ then
+ echo
+ echo '!!!' "${P} already merged -- unmerge first"
+ echo
+ exit 1
+ fi
+ echo
+ pkg_preinst
+ /usr/sbin/merge.py
+ cd ${BUILDDIR}
+ #zap it so that people don't look at a bad image and get confused
+ rm -rf image
+ pkg_postinst
+ trap SIGINT SIGQUIT
+}
+
+dyn_unmerge() {
+ trap "" SIGINT SIGQUIT
+ #stub unmerge function for now
+ cd ${BUILDDIR}
+ /usr/sbin/unmerge.py ${P}
+ if [ $? -ne 0 ]
+ then
+ exit
+ fi
+ trap SIGINT_SIGQUIT
+}
+
+dyn_spec() {
+
+ tar czf /usr/src/redhat/SOURCES/${P}.tar.gz ${P}.* files
+
+ local V
+
+ V=${P#${O##*/}*}
+ V=${V/[!digit]/}
+ V=${V/-/.}
+
+ cat <<__END1__ > ${P}.spec
+Summary: ${DESCRIPTION}
+Name: ${O##*/}
+Version: ${V}
+Release: 1
+Copyright: GPL
+Group: portage/${CATEGORY}
+Source: ${P}.tar.gz
+Buildroot: ${D}
+%description
+${DESCRIPTION}
+
+%prep
+%setup -c
+ebuild ${P}.ebuild unpack
+
+%build
+ebuild ${P}.ebuild compile
+
+%install
+ebuild ${P}.ebuild install
+
+%clean
+ebuild ${P}.ebuild clean
+
+%files
+/
+__END1__
+
+}
+dyn_rpm () {
+ dyn_spec
+ rpm -bb ${P}.spec
+ local V
+
+ V=${P#${O##*/}*}
+ V=${V/[!digit]/}
+ V=${V/-/.}
+ local W
+ W="portage/${CATEGORY}"
+
+ install -D /usr/src/redhat/RPMS/i386/${O##*/}-${V}-1.i386.rpm ${RPMDIR}/${W}/${O##*/}-${V}.rpm
+}
+
+dyn_help() {
+ echo
+ echo "Portage v1.1"
+ echo "Copyright 2000 Gentoo Technologies, Inc."
+ echo
+ echo "How to use the ebuild command:"
+ echo
+ echo "The first argument to ebuild should be an existing .ebuild file."
+ echo
+ echo "One or more of the following options can then be specified. If more"
+ echo "than one option is specified, each will be executed in order."
+ echo
+ echo " fetch : download source archive(s) and patches"
+ echo " unpack : unpack/patch sources (auto-fetch if needed)"
+ echo " compile : compile sources (auto-fetch/unpack if needed)"
+ echo " merge : merge image into live filesystem, recording files in db"
+ echo " (auto-fetch/unpack/compile if needed)"
+ echo " unmerge : remove package from live filesystem"
+ echo " clean : clean up all source and temporary files"
+ echo " clean-image : clean image directory only"
+ echo
+ echo "The following settings will be used for the ebuild process:"
+ echo
+ echo " package : ${P}" "( \${P} )"
+ echo " description : ${DESCRIPTION}"
+ echo " system : ${CHOST}" "( \${CHOST} )"
+ echo " c flags : ${CFLAGS}" "( \${CFLAGS} )"
+ echo " c++ flags : ${CXXFLAGS}" "( \${CXXFLAGS} )"
+ echo " make flags : ${MAKEOPTS}" "( \${MAKEOPTS} )"
+ echo -n " build mode : "
+ if [ -n "${DEBUG}" ]
+ then
+ echo "debug (large)"
+ else
+ echo "production (stripped)"
+ fi
+ echo " merge to : ${ROOT}" "( \${ROOT} )"
+ echo " db location : ${ROOT}var/db/pkg/${P}/CONTENTS"
+ echo
+ if [ -n "$USE" ]
+ then
+ echo "Additionally, support for the following toolkits will be enabled if necessary:"
+ echo
+ echo " ${USE}"
+ fi
+ echo
+}
+
+src_menu() {
+ MYDIR=${BUILDDIR}
+ if [ "$1" = "p" ]
+ then
+ echo ${P}
+ exit 0
+ fi
+
+ local MYfoo
+ for MYfoo in "$@"
+ do
+ case "${MYfoo}" in
+ noop)
+ ;;
+ unpack)
+ dyn_fetch
+ dyn_unpack
+ ;;
+ compile)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ ;;
+ prerm|postrm|preinst|postinst)
+ pkg_${MYfoo}
+ ;;
+ help|install|clean|fetch|digest|pkginfo|pkgloc|spec|rpm)
+ dyn_${MYfoo}
+ ;;
+ package)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ dyn_install
+ dyn_package
+ ;;
+ merge)
+ dyn_fetch
+ dyn_unpack
+ dyn_compile
+ dyn_install
+ dyn_merge
+ ;;
+ *)
+ echo "Please specify a valid command."
+ echo
+ dyn_help
+ esac
+ done
+ cd $MYDIR
+}
+
+#dummy value for help printouts
+P=packagename
+
+if [ $# -lt 2 ]
+then
+ echo
+ echo '!!!' "At least two arguments expected."
+ dyn_help
+ exit 1
+fi
+
+if [ ! -e ${1} ]
+then
+ echo
+ echo '!!!' "${1} not found."
+ dyn_help
+ exit 1
+fi
+
+export STARTDIR=`pwd`
+export O=`dirname ${STARTDIR}/${1}`
+export EBUILD=${1}
+export PEBUILD=${O}/files/${PLATFORM}.ebuild
+export FILESDIR=${O}/files
+
+source ${1}
+if [ -e ${PEBUILD} ]
+then
+ source ${PEBUILD}
+fi
+
+if [ -z "$FETCHCOMMAND" ]
+then
+ FETCHCOMMAND="/usr/bin/wget --passive-ftp \${x} -P \${DISTDIR}"
+fi
+
+if [ ! -z ${BUILD_PREFIX} ]
+then
+ export BUILDDIR=${BUILD_PREFIX}/${CATEGORY}/${P}
+else
+ export BUILDDIR=${O}
+fi
+if [ ! -d ${BUILDDIR} ]
+then
+ install -d ${BUILDDIR}
+fi
+
+export T=${BUILDDIR}/temp
+if [ ! -d ${T} ]
+then
+ install -d ${T}
+fi
+export WORKDIR=${BUILDDIR}/work
+export D=${BUILDDIR}/image
+dlen=$(( ${#D} -1 ))
+if [ "${D:${dlen}:1}" != "/" ]
+then
+ export D=${D}/
+fi
+
+if [ -z ${DISTDIR} ]
+then
+ export DISTDIR=/usr/portage/distfiles
+fi
+if [ -z ${PKGDIR} ]
+then
+ export PKGDIR=/usr/portage/packages
+fi
+
+source ${1}
+if [ -e ${PEBUILD} ]
+then
+ source ${PEBUILD}
+fi
+
+export P
+
+# Set Perl-Installation Enviroment
+
+for i in ARCHLIB PRIVLIB BIN MAN1DIR MAN3DIR SCRIPT SITEARCH SITELIB
+do
+ install=`echo $i | awk '{ printf "%s%s","install",tolower($1) }'`
+ install=`perl "-V:$install" | sed -e "s:.*/image/\(.*\)'\;:\1:"`
+ PERLINSTALL=`echo INSTALL$i=$D$install $PERLINSTALL`
+done
+export PERLINSTALL
+
+foo=2
+while [ $foo -le $# ]
+do
+eval "src_menu \${${foo}}"
+if [ $? -ne 0 ]
+then
+ echo "***error***"
+ exit 1
+fi
+foo=$(( $foo + 1))
+done
diff --git a/sys-apps/portage/files/make.conf b/sys-apps/portage/files/make.conf
new file mode 100644
index 000000000000..aa21a1b84d3a
--- /dev/null
+++ b/sys-apps/portage/files/make.conf
@@ -0,0 +1,50 @@
+# Copyright 2000 Daniel Robbins, Gentoo Technologies, Inc.
+#
+# /etc/make.conf -- set system-wide compile options in this file
+# Use bash-style semantics, since this will be sourced from bash,
+# rather than by make as under FreeBSD.
+# stuff to add: how to compress manpages
+
+#proxy settings PROXY(both), or HTTP_PROXY/FTP_PROXY
+PROXY=freebox.gentoo.org:3128
+#HTTP_PROXY=
+#FTP_PROXY=
+
+# Host-type
+CHOST=i686-pc-linux-gnu
+
+# Directory used for the build process
+BUILD_PREFIX=/tmp/portage/
+DISTDIR=/usr/portage/distfiles
+PKGDIR=/usr/portage/packages
+RPMDIR=/usr/portage/rpm
+PLATFORM=$CHOST
+
+# Options passed to make during the build process
+MAKEOPTS="-j2"
+
+# Fetching command
+FETCHCOMMAND="/usr/bin/wget --passive-ftp \${x} -P \${DISTDIR}"
+
+# Compile programs with GNOME/SLANG extensions
+USE="gnome slang"
+
+# C Compiler flags
+CFLAGS="-O2 -mpentium"
+
+# C++ Compiler flags
+CXXFLAGS="-O2 -mpentium"
+
+#Debug build -- if defined, binaries won't be stripped
+#DEBUG=true
+
+#Package Mode - tbz2 or tgz (what binary package mode)
+PACKAGE=tbz2
+
+einfo() {
+ echo info:"$*"
+}
+
+eerror() {
+ echo error:"$*"
+}
diff --git a/sys-apps/portage/files/merge.py b/sys-apps/portage/files/merge.py
new file mode 100644
index 000000000000..ff32a5ae7453
--- /dev/null
+++ b/sys-apps/portage/files/merge.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+import os
+from commands import *
+import string
+
+mystart=os.path.normpath(os.environ["D"])
+mypackage=os.path.normpath(os.environ["P"])
+myroot=os.environ["ROOT"]
+
+os.chdir(mystart)
+print
+print ">>> Merging contents of",mystart,"into live filesystem at "+myroot
+print ">>> Recording merged files to "+myroot+"var/db/pkg/"+mypackage+"/CONTENTS"
+def prepare_db():
+ if not os.path.isdir(myroot+"var/db"):
+ os.mkdir(myroot+"var/db",0755)
+ if not os.path.isdir(myroot+"var/db/pkg"):
+ os.mkdir(myroot+"/var/db/pkg",0755)
+ if not os.path.isdir(myroot+"var/db/pkg/"+mypackage):
+ os.mkdir(myroot+"var/db/pkg/"+mypackage,0755)
+
+def md5(x):
+ myresult=getstatusoutput("/usr/bin/md5sum "+x)
+ return string.split(myresult[1]," ")[0]
+
+def getmtime(x):
+ return `os.lstat(x)[-2]`
+
+def pathstrip(x):
+ cpref=os.path.commonprefix([x,mystart])
+ return [myroot+x[len(cpref)+1:],x[len(cpref):]]
+
+def mergefiles():
+ mycurpath=os.getcwd()
+ myfiles=os.listdir(mycurpath)
+ for x in myfiles:
+ floc=pathstrip(os.path.normpath(mycurpath+"/"+x))
+ if os.path.islink(x):
+ myto=os.readlink(x)
+ mycom=getstatusoutput("/bin/ln -sf "+myto+" "+floc[0])
+ if mycom[0]==0:
+ print "<<<",floc[0],"->",myto
+ outfile.write("sym "+floc[1]+" -> "+myto+" "+getmtime(floc[0])+"\n")
+ else:
+ print "!!!",floc[0],"->",myto
+ elif os.path.isfile(x):
+ mymd5=md5(mycurpath+"/"+x)
+ mystatus=getstatusoutput("/bin/mv "+x+" "+pathstrip(mycurpath)[0])
+ if mystatus[0]==0:
+ zing="<<<"
+ else:
+ zing="!!!"
+
+ print zing+" "+floc[0]
+ print "md5",mymd5
+ outfile.write("obj "+floc[1]+" "+mymd5+" "+getmtime(floc[0])+"\n")
+ elif os.path.isdir(x):
+ mystat=os.stat(x)
+ if not os.path.exists(floc[0]):
+ os.mkdir(floc[0])
+ os.chmod(floc[0],mystat[0])
+ os.chown(floc[0],mystat[4],mystat[5])
+ print "<<<",floc[0]+"/"
+ else:
+ print "---",floc[0]+"/"
+ #mtime doesn't mean much for directories -- we don't store it
+ outfile.write("dir "+floc[1]+"\n")
+ mywd=os.getcwd()
+ os.chdir(x)
+ mergefiles()
+ os.chdir(mywd)
+
+
+prepare_db()
+outfile=open(myroot+"var/db/pkg/"+mypackage+"/CONTENTS","w")
+mergefiles()
+print
+print ">>>",mypackage,"installed."
+print
+outfile.close()
diff --git a/sys-apps/portage/files/pkgdepend.py b/sys-apps/portage/files/pkgdepend.py
new file mode 100644
index 000000000000..81d4f20b31a9
--- /dev/null
+++ b/sys-apps/portage/files/pkgdepend.py
@@ -0,0 +1,221 @@
+#!/usr/bin/env python
+#
+# StampedeLinux Dependency Checking Code
+# Copyright 1998 Daniel Robbins
+# Distributed under the GNU Public License
+# Version 0.5 12/22/98
+#
+# Version comparison: Functionality
+#
+# Exactly what version numbers and letters does this versioning code
+# recognize, and which tags are considered later versions than others?
+# Take a look at these version number examples:
+#
+# 4.5 > 4.0 (you knew this one!)
+# 4.0 == 4 (probably knew this one too)
+# 4.0.1 < 4.0.2
+# 4.0.0.1 < 4.0.2
+#
+# Build (revision) Numbers:
+#
+# Build (or revision) numbers can be specified along with the last digit
+# in a version string, for example:
+#
+# 4.5b (Revision b of version 4.5, *not* 4.5 beta)
+# 4.5c > 4.5b
+# 1.2.3a > 1.2.3
+# 9.8.0z > 9.8
+# 9a.5b *ILLEGAL* --- Build numbers can only immediately follow the *last*
+# digit in a version, so the "9a" is illegal
+#
+# Alpha, Beta, and Pre
+#
+# Functionality has been added to support alpha, beta and pre prefixes.
+# They are specified by placing an underscore "_" immediately after the last
+# digit, and then specifying "alpha","beta",or "pre". They are always branched
+# off the last digit in a version. In addition, an optional build (revision) number
+# can immediately follow an "alpha", "beta" or "pre"
+#
+# More examples:
+#
+# 4.5_pre6 > 4.5_beta6 > 4.5_alpha6 ( pre is closer to release than a beta )
+# 4.5_pre < 4.5pre1 < 4.5pre2 ( without a build number, a "0 build" is assumed )
+# 2.9_alpha > 2.8
+# 3.4beta *ILLEGAL* (no "_" betweeen last digit and "beta")
+# 3.4.beta *ILLEGAL* ("beta" must immediately follow a digit and a "_")
+# 3.4_beta (Correct)
+#
+# The versioning functionality will provide adequate support for a variety of
+# numbering schemes, and will allow them to interoperate together. Of course,
+# we cannot support every wacky versioning scheme. Our versioning supports
+# the vast majority of packages, however.
+
+import string
+
+# parsever:
+# This function accepts an 'inter-period chunk' such as
+# "3","4","3_beta5", or "2b" and returns an array of three
+# integers. "3_beta5" returns [ 3, -2, 5 ]
+# These values are used to determine which package is
+# newer.
+
+def relparse(myver):
+ number=0
+ p1=0
+ p2=0
+ mynewver=string.split(myver,"_")
+ if len(mynewver)==2:
+ #alpha,beta or pre
+ number=string.atoi(mynewver[0])
+ if "beta" == mynewver[1][:4]:
+ p1=-2
+ try:
+ p2=string.atoi(mynewver[1][4:])
+ except:
+ p2=0
+ elif "alpha" == mynewver[1][:5]:
+ p1=-3
+ try:
+ p2=string.atoi(mynewver[1][5:])
+ except:
+ p2=0
+ elif "pre" ==mynewver[1][:3]:
+ p1=-1
+ try:
+ p2=string.atoi(mynewver[1][3:])
+ except:
+ p2=0
+ else:
+ #normal number or number with letter at end
+ divider=len(myver)-1
+ if myver[divider:] not in "1234567890":
+ #letter at end
+ p1=ord(myver[divider:])
+ number=string.atoi(myver[0:divider])
+ else:
+ number=string.atoi(myver)
+ return [number,p1,p2]
+
+
+#returns 1 if valid version string, else 0
+# valid string in format: <v1>.<v2>...<vx>[a-z,_{alpha,beta,pre}[vy]]-vz
+
+def ververify(myval):
+ mybuildval=string.split(myval,'-')
+ if len(mybuildval)==2:
+ try:
+ string.atoi(mybuildval[1])
+ myval=mybuildval[0]
+ except:
+ return 0
+ myval=string.split(myval,'.')
+ for x in range(0,len(myval)-1):
+ try:
+ foo=string.atoi(myval[x])
+ except:
+ return 0
+ endval=myval[-1:][0]
+ try:
+ string.atoi(endval)
+ return 1
+ except:
+ pass
+ pos=0
+ keepgoing=1
+ while keepgoing:
+ if (pos<len(endval)) and (endval[pos] in "0123456789"):
+ pos=pos+1
+ else:
+ keepgoing=0
+ if pos==0:
+ return 0
+ endval=endval[pos:]
+ if len(endval)==0:
+ return 1
+ if endval[0] in string.lowercase:
+ if len(endval)>1:
+ return 0
+ else:
+ return 1
+ elif endval[0] == "_":
+ endval=endval[1:]
+ mylen=len(endval)
+ if (mylen>=3) and (endval[0:3]=="pre"):
+ if mylen==3:
+ return 1
+ else:
+ try:
+ string.atoi(endval[3:])
+ return 1
+ except:
+ return 0
+ elif (mylen>=4) and (endval[0:4]=="beta"):
+ if mylen==4:
+ return 1
+ else:
+ try:
+ string.atoi(endval[4:])
+ return 1
+ except:
+ return 0
+
+ elif (mylen>=5) and (endval[0:5]=="alpha"):
+ if mylen==5:
+ return 1
+ else:
+ try:
+ string.atoi(endval[5:])
+ return 1
+ except:
+ return 0
+
+ else:
+ return 0
+ else:
+ return 0
+
+
+# vercmp:
+# This takes two version strings and returns an integer to tell you whether
+# the versions are the same, val1>val2 or val2>val1.
+
+def vercmp(val1,val2):
+ val1=string.split(val1,'-')
+ if len(val1)==2:
+ val1[0]=val1[0]+"."+val1[1]
+ val1=string.split(val1[0],'.')
+ val2=string.split(val2,'-')
+ if len(val2)==2:
+ val2[0]=val2[0]+"."+val2[1]
+ val2=string.split(val2[0],'.')
+ if len(val2)<len(val1):
+ for x in range(0,len(val1)-len(val2)):
+ val2.append("0")
+ elif len(val1)<len(val2):
+ for x in range(0,len(val2)-len(val1)):
+ val1.append("0")
+ #The above code will extend version numbers out so they
+ #have the same number of digits.
+ myval1=[]
+ for x in range(0,len(val1)):
+ cmp1=relparse(val1[x])
+ cmp2=relparse(val2[x])
+ for y in range(0,3):
+ myret=cmp1[y]-cmp2[y]
+ if myret != 0:
+ return myret
+ return 0
+
+def pkgsame(pkg1,pkg2):
+ if (string.split(pkg1,'-')[0])==(string.split(pkg2,'-')[0]):
+ return 1
+ else:
+ return 0
+
+def pkg(myname):
+ return string.split(myname,'-')[0]
+
+def ver(myname):
+ a=string.split(myname,'-')
+ return myname[len(a[0])+1:]
+
diff --git a/sys-apps/portage/files/queryhost.sh b/sys-apps/portage/files/queryhost.sh
new file mode 100644
index 000000000000..61213f379f07
--- /dev/null
+++ b/sys-apps/portage/files/queryhost.sh
@@ -0,0 +1,27 @@
+
+#!/bin/sh
+
+hping() {
+ host=`echo $1 | sed -e 's:.*\://::' -e 's:/.*::'`
+ result=`ping -c3 -q ${host} 2>/dev/null`
+ if [ -n "$result" ]
+ then
+ if [ -z "`echo $result | sed 's:.*0 packets received.*:N:'`" ]
+ then
+ result=`echo $result | sed -e "s:.*= [0-9|\.]*/::" -e "s:/[0-9|\.]* ms::" | awk '{ printf ("%04i\n",(atof $1)) }'`
+ echo $result $1
+ else
+ echo 9999 $1
+ fi
+ fi
+}
+pingall() {
+
+ for i in $1
+ do
+ hping $i
+ done
+}
+pingall "$1" | sort | sed -e "s:[0-9]* ::"
+#pingall "$1"
+
diff --git a/sys-apps/portage/files/unmerge.py b/sys-apps/portage/files/unmerge.py
new file mode 100644
index 000000000000..846ce4f03d68
--- /dev/null
+++ b/sys-apps/portage/files/unmerge.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+
+import sys
+import os
+norm=os.path.normpath
+import string
+from commands import *
+
+def pkgscript(x):
+ myresult=getstatusoutput("/usr/bin/ebuild "+myebuildfile+" "+x)
+ if myresult[0] or myresult[1]:
+ print
+ if myresult[0]:
+ print "Error code from",pkgname,x,"script --",myresult[0]
+ if myresult[1]:
+ print "Output from",pkgname,x,"script:"
+ print
+ print myresult[1]
+
+def md5(x):
+ myresult=getstatusoutput("/usr/bin/md5sum "+x)
+ return string.split(myresult[1]," ")[0]
+
+def getmtime(x):
+ return `os.lstat(x)[-2]`
+
+try:
+ myroot=os.environ["ROOT"]
+except KeyError:
+ myroot="/"
+
+for pkgname in sys.argv[1:]:
+ if os.path.isdir(os.path.normpath(myroot+"var/db/pkg/"+pkgname)):
+ if myroot=="/":
+ print "Unmerging",pkgname+"..."
+ else:
+ print "Unmerging",pkgname,"from",myroot+"..."
+ print
+ else:
+ print pkgname,"not installed"
+ continue
+ try:
+ contents=open(os.path.normpath(myroot+"var/db/pkg/"+pkgname+"/CONTENTS"))
+ except:
+ print "Error -- could not open CONTENTS file for", pkgname+". Aborting."
+ sys.exit(1)
+ pkgfiles={}
+ for line in contents.readlines():
+ mydat=string.split(line)
+ # we do this so we can remove from non-root filesystems
+ # (use the ROOT var to allow maintenance on other partitions)
+ mydat[1]=os.path.normpath(myroot+mydat[1][1:])
+ if mydat[0]=="obj":
+ #format: type, mtime, md5sum
+ pkgfiles[mydat[1]]=[mydat[0], mydat[3], mydat[2]]
+ elif mydat[0]=="dir":
+ #format: type
+ pkgfiles[mydat[1]]=[mydat[0] ]
+ elif mydat[0]=="sym":
+ #format: type, mtime, dest
+ pkgfiles[mydat[1]]=[mydat[0], mydat[4], mydat[3]]
+ else:
+ print "Error -- CONTENTS file for", pkgname, "is corrupt."
+ print ">>> "+line
+ sys.exit(1)
+ # we don't want to automatically remove the ebuild file listed
+ # in the CONTENTS file. We'll do after everything else has
+ # completed successfully.
+ myebuildfile=os.path.normpath(myroot+"var/db/pkg/"+pkgname+"/"+pkgname+".ebuild")
+ if pkgfiles.has_key(myebuildfile):
+ del pkgfiles[myebuildfile]
+
+ mykeys=pkgfiles.keys()
+ mykeys.sort()
+ mykeys.reverse()
+
+ #prerm script
+ pkgscript("prerm")
+
+ for obj in mykeys:
+ obj=norm(obj)
+ if not os.path.exists(obj):
+ print "--- !found", pkgfiles[obj][0], obj
+ continue
+ if (pkgfiles[obj][0]!="dir") and (getmtime(obj) != pkgfiles[obj][1]):
+ print "--- !mtime", pkgfiles[obj][0], obj
+ continue
+ if pkgfiles[obj][0]=="dir":
+ if not os.path.isdir(obj):
+ print "--- !dir ","dir", obj
+ continue
+ if os.listdir(obj):
+ print "--- !empty","dir", obj
+ continue
+ os.rmdir(obj)
+ print "<<< ","dir",obj
+ elif pkgfiles[obj][0]=="sym":
+ if not os.path.islink(obj):
+ print "--- !sym ","sym", obj
+ continue
+ mydest=os.readlink(obj)
+ if mydest != pkgfiles[obj][2]:
+ print "--- !destn","sym", obj
+ continue
+ os.unlink(obj)
+ print "<<< ","sym",obj
+ elif pkgfiles[obj][0]=="obj":
+ if not os.path.isfile(obj):
+ print "--- !obj ","obj", obj
+ continue
+ mymd5=md5(obj)
+ if mymd5 != pkgfiles[obj][2]:
+ print "--- !md5 ","obj", obj
+ continue
+ os.unlink(obj)
+ print "<<< ","obj",obj
+ #postrm script
+ pkgscript("postrm")
+ #recursive cleanup
+ for thing in os.listdir(myroot+"var/db/pkg/"+pkgname):
+ os.unlink(myroot+"var/db/pkg/"+pkgname+"/"+thing)
+ os.rmdir(myroot+"var/db/pkg/"+pkgname)
+ print
+ if myroot=="/":
+ print pkgname,"unmerged."
+ else:
+ print pkgname,"unmerged from",myroot+"."
diff --git a/sys-apps/portage/portage-1.0.ebuild b/sys-apps/portage/portage-1.0.ebuild
new file mode 100644
index 000000000000..595afdd35fbd
--- /dev/null
+++ b/sys-apps/portage/portage-1.0.ebuild
@@ -0,0 +1,32 @@
+#Copyright 2000 Achim Gottinger
+
+P=portage-1.0
+A=""
+S=${WORKDIR}/${P}
+CATEGORY="sys"
+DESCRIPTION="Portage autobuild system"
+
+src_unpack() {
+ mkdir ${S}
+}
+
+src_compile() {
+ cd ${S}
+}
+
+src_install() {
+ cd ${FILESDIR}
+ insinto /etc
+ doins make.conf
+ dodir /usr/bin
+ dodir /usr/sbin
+ insinto /usr/bin
+ insopts -m755
+ doins ebuild *.sh
+ insinto /usr/sbin
+ doins merge.py unmerge.py
+}
+
+
+
+