summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Østergaard <kloeri@gentoo.org>2006-02-02 21:18:24 +0000
committerBryan Østergaard <kloeri@gentoo.org>2006-02-02 21:18:24 +0000
commitdf3d925c178c505d1d5a31ab5573a84a352c6d41 (patch)
tree92223b96618d09c07a88a466fe122a3e86211d3e /dev-lang/python
parentMark 2.12.4 stable on alpha (diff)
downloadhistorical-df3d925c178c505d1d5a31ab5573a84a352c6d41.tar.gz
historical-df3d925c178c505d1d5a31ab5573a84a352c6d41.tar.bz2
historical-df3d925c178c505d1d5a31ab5573a84a352c6d41.zip
No more libstdc++.so linking, fix python-updater ordering (bug #95538) + mmap (bug #113439) and fd leak (bug #118575) fixes.
Package-Manager: portage-2.0.54
Diffstat (limited to 'dev-lang/python')
-rw-r--r--dev-lang/python/ChangeLog10
-rw-r--r--dev-lang/python/Manifest12
-rw-r--r--dev-lang/python/files/depreorder-topsort.py65
-rw-r--r--dev-lang/python/files/digest-python-2.4.2-r11
-rw-r--r--dev-lang/python/files/python-updater-r1322
-rw-r--r--dev-lang/python/python-2.4.2-r1.ebuild295
6 files changed, 700 insertions, 5 deletions
diff --git a/dev-lang/python/ChangeLog b/dev-lang/python/ChangeLog
index 6af19ffb33c5..fecefc21d430 100644
--- a/dev-lang/python/ChangeLog
+++ b/dev-lang/python/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for dev-lang/python
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.185 2006/01/13 07:56:51 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.186 2006/02/02 21:18:24 kloeri Exp $
+
+*python-2.4.2-r1 (02 Feb 2006)
+
+ 02 Feb 2006; Bryan Østergaard <kloeri@gentoo.org
+ +files/depreorder-topsort.py, +files/python-updater-r1,
+ +python-2.4.2-r1.ebuild:
+ No more libstdc++.so linking, fix python-updater ordering (bug #95538) +
+ mmap (bug #113439) and fd leak (bug #118575) fixes.
13 Jan 2006; Mike Frysinger <vapier@gentoo.org>
+files/python-2.4.2-no-threads.patch, python-2.4.2.ebuild:
diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
index e751161e88a4..3b88ad3e37eb 100644
--- a/dev-lang/python/Manifest
+++ b/dev-lang/python/Manifest
@@ -1,7 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-MD5 3fbcf2fb6955b94129673721a4d39ad7 ChangeLog 29563
+MD5 f489a7002367b7b9d0e9252b11fb90dd ChangeLog 29862
+MD5 7e423c353b08a2c05693d13f21e067d0 files/depreorder-topsort.py 1958
MD5 1c5cd53cb89c821a549968bac31df0f1 files/depreorder.py 2235
MD5 f3f370c8d1382c1a7571cfc1cbb196d9 files/digest-python-2.1.3-r1 62
MD5 f11f5d528c570ef739ea10806cebfa9f files/digest-python-2.2.3-r6 62
@@ -13,6 +14,7 @@ MD5 fccf57b8c47164b676517e516898dc46 files/digest-python-2.4-r3 64
MD5 1e4084c2a8ee240668d02e703e7c171f files/digest-python-2.4.1 66
MD5 1e4084c2a8ee240668d02e703e7c171f files/digest-python-2.4.1-r1 66
MD5 678a7e4660de986e8e22808d18f93686 files/digest-python-2.4.2 66
+MD5 678a7e4660de986e8e22808d18f93686 files/digest-python-2.4.2-r1 66
MD5 5f2361b3e770981b737a9ad3d2863931 files/python-2.2.1-r5-gentoo.diff 4152
MD5 11aa066154fe2e0a4c306124c7e5dd4a files/python-2.2.2-tk-8.4.x.patch 2997
MD5 96d4207fb41391c70d5f02e1785c9527 files/python-2.2.3-db4.patch 1220
@@ -54,6 +56,7 @@ MD5 b530d6f9dbcf30239061be3de80932cc files/python-config-2.2.2 178
MD5 201acd1cfd5124f25c58a8db3f78a502 files/python-config-2.3 178
MD5 d74e7f0fd47f00e8b3fe7ca36b7eb629 files/python-config-2.4 179
MD5 1cf4c21ad3b0aafc571b05b9a9e54594 files/python-updater 8761
+MD5 4b6d43b5e4510d6dc29be97c6aef21ca files/python-updater-r1 8769
MD5 8145ce0144332d6caca98fa5fb648741 metadata.xml 221
MD5 2632d539cd0ab18b40f9510118ed3099 python-2.1.3-r1.ebuild 2299
MD5 5857a314767fd0ae2243590999fe78b2 python-2.2.3-r6.ebuild 4491
@@ -64,11 +67,12 @@ MD5 4928085fdd7860dd8104011c9955a7f2 python-2.3.5.ebuild 7799
MD5 eb681c731b011f69718d04351d341741 python-2.4-r3.ebuild 7355
MD5 ee21268fe5f633029a2575a6e0808d75 python-2.4.1-r1.ebuild 9144
MD5 83d5f6cfce039d87c651dbad4224912a python-2.4.1.ebuild 8344
+MD5 c453c29aa3366ad1e50b2c1f73efedde python-2.4.2-r1.ebuild 9566
MD5 f9de6829c64c8f780d4c3b90ea5105a9 python-2.4.2.ebuild 9234
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
-iD8DBQFDx12o2+ySkm8kpY0RAkCSAJ9YBjPsh+lbYby/J63H81iEYVGy0ACfZpx5
-Pi4bYvevLzX9ugjMVNBCwZ8=
-=AZyc
+iD8DBQFD4ndvugEuf3OQ0akRAmeBAJ9ebJrs59kYCs9Kjjaq0MnQ5M0ghQCfUZ63
+RD7eBPQfSS776DysL62FGpk=
+=mzCE
-----END PGP SIGNATURE-----
diff --git a/dev-lang/python/files/depreorder-topsort.py b/dev-lang/python/files/depreorder-topsort.py
new file mode 100644
index 000000000000..4c3cb7bc84ab
--- /dev/null
+++ b/dev-lang/python/files/depreorder-topsort.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+
+# tries to reorder the deps of a given list of packages so they
+# are merged in order - liquidx@g.o (09 Oct 03)
+
+import portage
+import sys, string
+
+fakedbapi = portage.fakedbapi()
+varapi = portage.db["/"]["vartree"].dbapi
+
+pkgs_to_reorder = sys.argv[1:]
+pkgs_ordered = []
+
+# key = catpkgver
+# value = dependencies
+dep_cache = {}
+
+
+# very simply, we extract the dependencies for each package
+for pkg in pkgs_to_reorder:
+ try:
+ deps, slot = varapi.aux_get(pkg, ["DEPEND", "SLOT"])
+ except ValueError:
+ sys.stderr.write("Error getting dependency information off " + pkg + "\n")
+ continue
+ try:
+ realdeps = portage.dep_check(deps, fakedbapi)
+ except TypeError:
+ # we're probably running >=portage-2.0.50
+ pkgsettings = portage.config(clone=portage.settings)
+ realdeps = portage.dep_check(deps, fakedbapi, pkgsettings)
+
+ vardeps = []
+ # match() finds the versions of all those that are installed
+ for dep in realdeps[1]:
+ vardeps = vardeps + varapi.match(dep)
+ dep_cache[pkg] = vardeps
+
+# topsort takes a graph (given as a dictionary with the nodes
+# as keys and the outgoing edges as values), and returns a
+# list of nodes that is topologically sorted
+def topsort (graph) :
+ visited = dict([(node,False) for node in graph.keys()])
+ result = []
+
+ def dfs_single (node) :
+ visited[node] = True
+ for adj in graph[node]:
+ # we ignore dependencies that are not nodes in the graph
+ if adj in graph.keys() and not visited[adj]:
+ dfs_single (adj)
+ result.append(node)
+
+ for node in graph.keys():
+ if not visited[node]:
+ dfs_single (node)
+
+ return result
+
+pkgs_final_order = topsort(dep_cache)
+
+print string.join(pkgs_final_order, "\n")
+#print portage.dep_expand("=dev-python/sip-3.8", portage.portdb)
+#print portage.dep_check("X? ( >=dev-python/sip-3.8 )", fakedbapi)
diff --git a/dev-lang/python/files/digest-python-2.4.2-r1 b/dev-lang/python/files/digest-python-2.4.2-r1
new file mode 100644
index 000000000000..267e62738cf0
--- /dev/null
+++ b/dev-lang/python/files/digest-python-2.4.2-r1
@@ -0,0 +1 @@
+MD5 98db1465629693fc434d4dc52db93838 Python-2.4.2.tar.bz2 7853169
diff --git a/dev-lang/python/files/python-updater-r1 b/dev-lang/python/files/python-updater-r1
new file mode 100644
index 000000000000..823a355114d0
--- /dev/null
+++ b/dev-lang/python/files/python-updater-r1
@@ -0,0 +1,322 @@
+#!/bin/sh
+#
+# A bit of hackery to update everything that is humanly possible
+# that maybe related to an older version of python. This script can
+# be run as many times as you like. It will log the results in
+# /tmp/python-updater.log
+#
+# OLD_PY_VER = old python version we are upgrading from
+# NEW_PY_VER = new python version we are upgrading to
+# PKGS_EXCEPTIONS = packages that should NOT be re-emerged for any reason
+# PKGS_MANUAL = packages that should be re-emerged even if they don't
+# fit the criteria (eg. ones that have python compiled
+# statically) - FIXME
+#
+# Runtime Variables:
+#
+# PKGS_TO_REMERGE = list of packages we deem to need re-emerging
+# PKGS_OK = list of packages that should be merged without any problems
+# PKGS_MISSING = list of packages that are installed, but cannot be merged
+# because they have been pruned from portage
+# PKGS_MASKED = list of packages that are installed, but masked.
+#
+
+NEW_PY_VER=$(python -V 2>&1 | sed 's:Python ::' | cut -d. -f1-2)
+
+PKGS_EXCEPTIONS="dev-lang/python sys-apps/portage"
+PKGS_MANUAL="app-office/gnumeric app-office/dia x11-libs/vte"
+LOGFILE="/var/log/python-updater.log"
+
+# portage variables
+PKG_DBDIR=/var/db/pkg
+PORTDIR=`portageq portdir`
+PORTDIR_OVERLAYS=`portageq portdir_overlay`
+
+PRETEND=0
+PKGS_TO_REMERGE=""
+PKGS_COUNT_REMERGE=0
+PORTAGE_PYTHON="/usr/bin/python"
+
+# load the gentoo-style info macros, but hack to get around
+# it thinking this is an rc script
+EBUILD="1"
+source /sbin/functions.sh
+
+
+
+for old in 2.4 2.3 2.2 2.1; do
+ if [ "${old}" != "${NEW_PY_VER}" ]; then
+ if [ -e /usr/bin/python${old} ] ; then
+ OLD_PY_VER=${old}
+ break;
+ fi
+ fi
+done
+
+
+if [ -z "${OLD_PY_VER}" ] ; then
+ eerror "Can't determine any previous Python version(s)."
+ exit 1
+fi
+
+
+# misc helper functions
+eloginfo() {
+ einfo $*
+ DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+ echo "${DATESTRING} - ${*}" >> ${LOGFILE}
+}
+
+elogecho() {
+ echo -n " "
+ echo $*
+ DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+ echo "${DATESTRING} - ${*}" >> ${LOGFILE}
+}
+
+elogerr() {
+ eerror $*
+ DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+ echo "${DATESTRING} ! ${*}" >> ${LOGFILE}
+}
+
+elog() {
+ DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+ echo "${DATESTRING} - ${*}" >> ${LOGFILE}
+}
+
+
+usage() {
+ echo "usage: python-updater [-h|-p|-o X.X|-n X.X]"
+ echo " -h help"
+ echo " -p pretend (don't do anything)"
+ echo " -o X.X set old python version to upgrade from [default: ${OLD_PY_VER}]"
+ echo " -n X.X set new python version to upgrade to [default: ${NEW_PY_VER}]"
+}
+
+#
+# Sanity check
+#
+
+if [ -z "${PORTDIR}" ]; then
+ eerror "Unable to proceed. Can not find PORTDIR. Make sure the command:"
+ eerror " "
+ eerror " portageq portdir"
+ eerror " "
+ eerror "returns a value. If it doesn't, make sure you have updated to"
+ eerror "latest portage version."
+ eerror " "
+ eerror "Report bugs to http://bugs.gentoo.org/"
+ exit 1
+fi
+
+if [ ! -f ${LOGFILE} ]; then
+ if ! touch ${LOGFILE} 2>&1 > /dev/null; then
+ ewarn "Logging disabled due to permissions"
+ LOGFILE=/dev/null
+ fi
+elif [ ! -w ${LOGFILE} -o ! -L ${LOGFILE} ]; then
+ ewarn "Logging disabled due to permissions"
+ LOGFILE=/dev/null
+fi
+
+#
+#
+# Command Line Parsing
+#
+#
+while [ -n "$1" ]; do
+ case "$1" in
+ -h)
+ usage
+ exit 0
+ ;;
+ -p)
+ PRETEND=1
+ ;;
+ -o)
+ shift
+ OLD_PY_VER="$1"
+ ;;
+ -n)
+ shift
+ NEW_PY_VER="$1"
+ ;;
+ *)
+ usage
+ echo "unrecognised option: $1"
+ ;;
+ esac
+ shift
+done
+
+#
+# Test where portage is, in python2.2 or somewhere else?
+#
+for py in /usr/bin/python /usr/bin/python${OLD_PY_VER} /usr/bin/python${NEW_PY_VER}; do
+ if ${py} -c "import portage"; then
+ PORTAGE_PYTHON=${py}
+ break;
+ fi
+done
+
+#
+#
+# Find all packages that have installed something in
+# /usr/lib/python${OLD_PY_VER}
+#
+#
+OLD_MODULES_DIRS="/usr/lib/python${OLD_PY_VER} /usr/lib32/python${OLD_PY_VER} /usr/lib64/python${OLD_PY_VER}"
+OLD_INCLUDE_DIR=/usr/include/python${OLD_PY_VER}
+
+eloginfo "Starting Python Updater from ${OLD_PY_VER} to ${NEW_PY_VER} :"
+eloginfo "Searching for packages with files in ${OLD_MODULES_DIRS} .."
+
+# iterate thru all the installed package's contents
+for content in `find ${PKG_DBDIR} -name CONTENTS`; do
+ # extract the category, package name and package version
+ CATPKGVER=$(echo ${content} | sed "s:${PKG_DBDIR}/\(.*\)/CONTENTS:\1:")
+
+ # exclude packages that are an exception, like portage and python itself.
+ exception=0
+ for exp in ${PKGS_EXCEPTIONS}; do
+ if [ -n "$(echo ${CATPKGVER} | grep ${exp})" ]; then
+ exception=1
+ break;
+ fi
+ done
+
+ if [ ${exception} = 1 ]; then
+ continue;
+ fi
+
+ for OLD_MODULES_DIR in ${OLD_MODULES_DIRS}; do
+ if fgrep "${OLD_MODULES_DIR}" ${content} > /dev/null; then
+ PKGS_TO_REMERGE="${PKGS_TO_REMERGE} ${CATPKGVER}"
+ elogecho "Adding to list: ${CATPKGVER}"
+ elif fgrep "${OLD_INCLUDE_DIR}" ${content} > /dev/null; then
+ PKGS_TO_REMERGE="${PKGS_TO_REMERGE} ${CATPKGVER}"
+ fi
+ done
+done
+
+# now we have to do each emerge seperately because if an installed version
+# does not have the corresponding ebuild in portage, then it will bail.
+
+eloginfo "Calculating Upgrade Package List .."
+
+PKGS_OK=""
+PKGS_MASKED=""
+PKGS_MISSING=""
+
+MASKED_STRING="been masked"
+MISSING_STRING="there are no masked or unmasked ebuilds to satisfy"
+
+for pkg in ${PKGS_TO_REMERGE}; do
+ emerge_output="$(emerge -p \=$pkg 2>&1)"
+ if $(echo "${emerge_output}" | grep "${MASKED_STRING}" > /dev/null); then
+ PKGS_MASKED="${PKGS_MASKED} $pkg"
+ elogecho "$pkg is masked"
+ elif $(echo "${emerge_output}" | grep "${MISSING_STRING}" > /dev/null); then
+ PKGS_MISSING="${PKGS_MISSING} $pkg"
+ elogecho "$pkg is missing from portage"
+ else
+ PKGS_OK="${PKGS_OK} $pkg"
+ PKGS_COUNT_REMERGE=$((PKGS_COUNT_REMERGE + 1))
+ fi
+done
+
+#
+# Use my super dumb package reordering algorithm that works most of the time
+#
+
+eloginfo "Re-ordering packages to merge .."
+
+PKGS_OK_SORTED="$(${PORTAGE_PYTHON} ${PORTDIR}/dev-lang/python/files/depreorder-topsort.py ${PKGS_OK} | xargs)"
+
+eloginfo "Preparing to merge these packages in this order:"
+for pkg in $PKGS_OK_SORTED; do
+ elogecho "$pkg"
+done
+
+# we emerge each package seperately to ensure we know exactly which ones might
+# cause an error, and then report it at the end
+
+COUNT=1
+PKGS_FAILED=""
+if [ "${PRETEND}" != "1" ]; then
+ for pkg in ${PKGS_OK_SORTED}; do
+ eloginfo "Starting to merge ($COUNT/$PKGS_COUNT_REMERGE) $pkg .."
+ if ! emerge --oneshot --nodeps =$pkg; then
+ PKGS_FAILED="${PKGS_FAILED} $pkg"
+ elogerr "Failed merging $pkg ($COUNT/$PKGS_COUNT_REMERGE)!"
+ fi
+ COUNT=$((COUNT+1))
+ done
+fi
+
+# final output stuff
+OUTPUT_PKGS_MASKED=""
+for pkg in ${PKGS_MASKED}; do OUTPUT_PKGS_MASKED="${OUTPUT_PKGS_MASKED} \=$pkg"; done
+OUTPUT_PKGS_MISSING=""
+for pkg in ${PKGS_MISSING}; do OUTPUT_PKGS_MISSING="${OUTPUT_PKGS_MISSING} $pkg"; done
+OUTPUT_PKGS_FAILED=""
+for pkg in ${PKGS_FAILED}; do OUTPUT_PKGS_FAILED="${OUTPUT_PKGS_FAILED} \=$pkg"; done
+
+if [ -n "${PKGS_FAILED}" -o -n "${PKGS_MISSING}" -o -n "${PKGS_MASKED}" ]; then
+ echo
+ ewarn "************************************************************"
+ ewarn "* Packages that still need to be manually emerged : *"
+ ewarn "************************************************************"
+ if [ -n "${OUTPUT_PKGS_MASKED}" ]; then
+ echo
+ ewarn " Masked Packages:"
+ ewarn " ----------------"
+ ewarn " Unmask the following packages (at your own risk) and "
+ ewarn " emerge them using this command after removing the '-p'"
+ ewarn " parameter."
+ echo
+ ewarn " emerge -p ${OUTPUT_PKGS_MASKED}"
+ echo
+ fi
+ if [ -n "${OUTPUT_PKGS_MISSING}" ]; then
+ echo
+ ewarn " Missing Packages:"
+ ewarn " -----------------"
+ ewarn " These packages need to be updated because their versions do"
+ ewarn " not exist in portage anymore."
+ echo
+ for x in ${OUTPUT_PKGS_MISSING}; do
+ echo " ${x}"
+ done
+ fi
+ if [ -n "${OUTPUT_PKGS_FAILED}" ]; then
+ echo
+ ewarn " Failed Packaged:"
+ ewarn " ----------------"
+ ewarn " These packages have failed and need to be re-emerged again."
+ ewarn " Alternatively, try re-running this script again to see if it"
+ ewarn " can be fixed."
+ echo
+ ewarn " emerge -p ${OUTPUT_PKGS_FAILED}"
+ echo
+ fi
+
+ elog "Python update completed with errors."
+ elog "Masked Packages:"
+ for x in ${PKGS_MASKED}; do
+ elog $x
+ done
+ elog "Missing Packages:"
+ for x in ${PKGS_MISSING}; do
+ elog $x
+ done
+ elog "Failed Packages:"
+ for x in ${PKGS_FAILED}; do
+ elog $x
+ done
+ elog "Update script completed."
+else
+ eloginfo "Python update completed successfully."
+fi
+
diff --git a/dev-lang/python/python-2.4.2-r1.ebuild b/dev-lang/python/python-2.4.2-r1.ebuild
new file mode 100644
index 000000000000..a52e3987f3d9
--- /dev/null
+++ b/dev-lang/python/python-2.4.2-r1.ebuild
@@ -0,0 +1,295 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.4.2-r1.ebuild,v 1.1 2006/02/02 21:18:24 kloeri Exp $
+
+# NOTE about python-portage interactions :
+# - Do not add a pkg_setup() check for a certain version of portage
+# in dev-lang/python. It _WILL_ stop people installing from
+# Gentoo 1.4 images.
+
+inherit eutils flag-o-matic python multilib versionator toolchain-funcs
+
+# we need this so that we don't depends on python.eclass
+PYVER_MAJOR=$(get_major_version)
+PYVER_MINOR=$(get_version_component_range 2)
+PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
+
+MY_P="Python-${PV}"
+S="${WORKDIR}/${MY_P}"
+DESCRIPTION="Python is an interpreted, interactive, object-orientated programming language."
+HOMEPAGE="http://www.python.org/"
+SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2"
+
+LICENSE="PSF-2.2"
+SLOT="2.4"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+IUSE="ncurses gdbm ssl readline tcltk berkdb bootstrap ipv6 build ucs2 doc X nocxx"
+
+DEPEND=">=sys-libs/zlib-1.1.3
+ !dev-python/cjkcodecs
+ !build? (
+ X? ( tcltk? ( >=dev-lang/tk-8.0 ) )
+ ncurses? ( >=sys-libs/ncurses-5.2 readline? ( >=sys-libs/readline-4.1 ) )
+ berkdb? ( >=sys-libs/db-3.1 )
+ gdbm? ( sys-libs/gdbm )
+ ssl? ( dev-libs/openssl )
+ doc? ( =dev-python/python-docs-${PV}* )
+ dev-libs/expat
+ )"
+
+# NOTE: The dev-python/python-fchksum RDEPEND is needed so that this python
+# provides the functionality expected from previous pythons.
+
+# NOTE: python-fchksum is only a RDEPEND and not a DEPEND since we don't need
+# it to compile python. We just need to ensure that when we install
+# python, we definitely have fchksum support. - liquidx
+
+# NOTE: changed RDEPEND to PDEPEND to resolve bug 88777. - kloeri
+
+PDEPEND="${DEPEND} dev-python/python-fchksum"
+
+PROVIDE="virtual/python"
+
+src_unpack() {
+ unpack ${A}
+ cd ${S}
+
+ # unnecessary termcap dep in readline (#79013)
+ epatch ${FILESDIR}/${PN}-2.4.2-readline.patch
+ # db4.2 support
+ epatch ${FILESDIR}/${PN}-2.4.1-db4.patch
+
+ # Upstream fix when building w/out thread support
+ epatch ${FILESDIR}/${P}-no-threads.patch
+
+ # adds support for PYTHON_DONTCOMPILE shell environment to
+ # supress automatic generation of .pyc and .pyo files - liquidx (08 Oct 03)
+ epatch ${FILESDIR}/${PN}-${PYVER}-gentoo_py_dontcompile.patch
+ epatch ${FILESDIR}/${PN}-${PYVER}-disable_modules_and_ssl.patch
+ epatch ${FILESDIR}/${PN}-${PYVER}-mimetypes_apache.patch
+
+ # prepends /usr/lib/portage/pym to sys.path
+ epatch ${FILESDIR}/${PN}-${PYVER}-add_portage_search_path.patch
+
+ epatch ${FILESDIR}/${PN}-2.4.1-libdir.patch
+ sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
+ Lib/distutils/command/install.py \
+ Lib/distutils/sysconfig.py \
+ Lib/site.py \
+ Makefile.pre.in \
+ Modules/Setup.dist \
+ Modules/getpath.c \
+ setup.py || die
+
+ # add support for struct stat st_flags attribute (bug 94637)
+ epatch ${FILESDIR}/python-2.4.1-st_flags.patch
+
+ # fix os.utime() on hppa. utimes it not supported but unfortunately reported as working - gmsoft (22 May 04)
+ # PLEASE LEAVE THIS FIX FOR NEXT VERSIONS AS IT'S A CRITICAL FIX !!!
+ [ "${ARCH}" = "hppa" ] && sed -e 's/utimes //' -i ${S}/configure
+
+ # fix mmap and fd leak problems (bugs 113439 + 118575)
+ epatch ${FILESDIR}/${P}-mmap+fd.patch
+
+ if tc-is-cross-compiler ; then
+ epatch "${FILESDIR}"/python-2.4.1-bindir-libdir.patch
+ epatch "${FILESDIR}"/python-2.4.1-crosscompile.patch
+ fi
+}
+
+src_configure() {
+ # disable extraneous modules with extra dependencies
+ if use build; then
+ export PYTHON_DISABLE_MODULES="readline pyexpat dbm gdbm bsddb _curses _curses_panel _tkinter"
+ export PYTHON_DISABLE_SSL=1
+ else
+ use gdbm \
+ || PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} gdbm"
+ use berkdb \
+ || PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} dbm bsddb"
+ use readline \
+ || PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} readline"
+ ( use !X || use !tcltk ) \
+ && PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _tkinter"
+ use ncurses \
+ || PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _curses _curses_panel"
+ use ssl \
+ || export PYTHON_DISABLE_SSL=1
+ export PYTHON_DISABLE_MODULES
+ echo $PYTHON_DISABLE_MODULES
+ fi
+}
+
+src_compile() {
+ filter-flags -malign-double
+
+ # Seems to no longer be necessary
+ #[ "${ARCH}" = "amd64" ] && append-flags -fPIC
+ [ "${ARCH}" = "alpha" ] && append-flags -fPIC
+
+ # http://bugs.gentoo.org/show_bug.cgi?id=50309
+ if is-flag -O3; then
+ is-flag -fstack-protector-all && replace-flags -O3 -O2
+ use hardened && replace-flags -O3 -O2
+ fi
+
+ export OPT="${CFLAGS}"
+
+ local myconf
+ #if we are creating a new build image, we remove the dependency on g++
+ if use build && ! use bootstrap || use nocxx ; then
+ myconf="--with-cxx=no"
+ fi
+
+ # super-secret switch. don't use this unless you know what you're
+ # doing. enabling UCS2 support will break your existing python
+ # modules
+ use ucs2 \
+ && myconf="${myconf} --enable-unicode=ucs2" \
+ || myconf="${myconf} --enable-unicode=ucs4"
+
+ src_configure
+
+ if tc-is-cross-compiler ; then
+ OPT="-O1" LDFLAGS="" \
+ ./configure --with-cxx=no || die "cross-configure failed"
+ emake python Parser/pgen || die "cross-make failed"
+ mv python hostpython
+ mv Parser/pgen Parser/hostpgen
+ make distclean
+ sed -i \
+ -e '/^HOSTPYTHON/s:=.*:=./hostpython:' \
+ -e '/^HOSTPGEN/s:=.*:=./Parser/hostpgen:' \
+ Makefile.pre.in || die
+ fi
+
+ # export CXX so it ends up in /usr/lib/python2.x/config/Makefile
+ tc-export CXX
+ # set LINKCC to prevent python from being linked to libstdc++.so
+ export LINKCC="\$(PURIFY) \$(CC)"
+ econf \
+ --with-fpectl \
+ --enable-shared \
+ `use_enable ipv6` \
+ --infodir='${prefix}'/share/info \
+ --mandir='${prefix}'/share/man \
+ --with-threads \
+ --with-libc='' \
+ ${myconf} || die
+ emake || die "Parallel make failed"
+}
+
+src_install() {
+ dodir /usr
+ src_configure
+ make DESTDIR="${D}" altinstall || die
+
+ # install our own custom python-config
+ exeinto /usr/bin
+ newexe ${FILESDIR}/python-config-${PYVER} python-config
+
+ # Use correct libdir in python-config
+ dosed "s:/usr/lib/:/usr/$(get_libdir)/:" /usr/bin/python-config
+
+ # The stuff below this line extends from 2.1, and should be deprecated
+ # in 2.3, or possibly can wait till 2.4
+
+ # seems like the build do not install Makefile.pre.in anymore
+ # it probably shouldn't - use DistUtils, people!
+ insinto /usr/$(get_libdir)/python${PYVER}/config
+ doins ${S}/Makefile.pre.in
+
+ # While we're working on the config stuff... Let's fix the OPT var
+ # so that it doesn't have any opts listed in it. Prevents the problem
+ # with compiling things with conflicting opts later.
+ dosed -e 's:^OPT=.*:OPT=-DNDEBUG:' \
+ /usr/$(get_libdir)/python${PYVER}/config/Makefile
+
+ # install python-updater in /usr/sbin
+ #dosbin ${FILESDIR}/python-updater
+ newsbin ${FILESDIR}/python-updater-r1 python-updater
+
+ if use build ; then
+ rm -rf ${D}/usr/lib/python${PYVER}/{test,encodings,email,lib-tk,bsddb/test}
+ else
+ use elibc_uclibc && rm -rf ${D}/usr/lib/python${PYVER}/{test,bsddb/test}
+ use berkdb || rm -rf ${D}/usr/lib/python${PYVER}/bsddb
+ ( use !X || use !tcltk ) && rm -rf ${D}/usr/lib/python${PYVER}/lib-tk
+ fi
+
+ prep_ml_includes usr/include/python${PYVER}
+}
+
+pkg_postrm() {
+ python_makesym
+ python_mod_cleanup /usr/lib/python${PYVER}
+ [[ "$(get_libdir)" == "lib" ]] || python_mod_cleanup /usr/$(get_libdir)/python${PYVER}
+}
+
+pkg_postinst() {
+ local myroot
+ myroot=$(echo $ROOT | sed 's:/$::')
+
+ python_makesym
+ python_mod_optimize
+ python_mod_optimize -x site-packages -x test ${myroot}/usr/lib/python${PYVER}
+ [[ "$(get_libdir)" == "lib" ]] || python_mod_optimize -x site-packages -x test ${myroot}/usr/$(get_libdir)/python${PYVER}
+
+
+ # workaround possible python-upgrade-breaks-portage situation
+ if [ ! -f ${myroot}/usr/lib/portage/pym/portage.py ]; then
+ if [ -f ${myroot}/usr/lib/python2.3/site-packages/portage.py ]; then
+ einfo "Working around possible python-portage upgrade breakage"
+ mkdir -p ${myroot}/usr/lib/portage/pym
+ cp ${myroot}/usr/lib/python2.4/site-packages/{portage,xpak,output,cvstree,getbinpkg,emergehelp,dispatch_conf}.py ${myroot}/usr/lib/portage/pym
+ python_mod_optimize ${myroot}/usr/lib/portage/pym
+ fi
+ fi
+
+ # try to upgrade to new python automatically - something to think about
+ #if [ "${ROOT}" = "/" ]; then
+ # /usr/sbin/python-updater
+ #fi
+
+ echo
+ ewarn
+ ewarn "If you have just upgraded from an older version of python you will need to run:"
+ ewarn
+ ewarn "/usr/sbin/python-updater"
+ ewarn
+ ewarn "This will automatically rebuild all the python dependent modules"
+ ewarn "to run with python-${PYVER}."
+ ewarn
+ ewarn "Your original Python is still installed and can be accessed via"
+ ewarn "/usr/bin/python2.x."
+ ewarn
+ ebeep 5
+}
+
+src_test() {
+ # PYTHON_DONTCOMPILE=1 breaks test_import
+ unset PYTHON_DONTCOMPILE
+
+ #skip all tests that fail during emerge but pass without emerge:
+ #(See bug# 67970)
+ local skip_tests="distutils global mimetools minidom mmap strptime subprocess tcl time urllib urllib2"
+
+ for test in ${skip_tests} ; do
+ mv ${S}/Lib/test/test_${test}.py ${T}
+ done
+
+ make test || die "make test failed"
+
+ for test in ${skip_tests} ; do
+ mv ${T}/test_${test}.py ${S}/Lib/test/test_${test}.py
+ done
+
+ einfo "Portage skipped the following tests which aren't able to run from emerge:"
+ for test in ${skip_tests} ; do
+ einfo "test_${test}.py"
+ done
+
+ einfo "If you'd like to run them, you may:"
+ einfo "cd /usr/lib/python${PYVER}/test"
+ einfo "and run the tests separately."
+}