diff options
author | Duncan Coutts <dcoutts@gentoo.org> | 2005-10-06 12:43:58 +0000 |
---|---|---|
committer | Duncan Coutts <dcoutts@gentoo.org> | 2005-10-06 12:43:58 +0000 |
commit | 779432da710a6ea13a51bbffe7d6a6734e832765 (patch) | |
tree | e8df2bf97937d957f6166c67f2eb020f34e4681d /dev-lang | |
parent | Mark 0.35-r1 ~alpha (diff) | |
download | gentoo-2-779432da710a6ea13a51bbffe7d6a6734e832765.tar.gz gentoo-2-779432da710a6ea13a51bbffe7d6a6734e832765.tar.bz2 gentoo-2-779432da710a6ea13a51bbffe7d6a6734e832765.zip |
Make the ghc-updater script work better.
(Portage version: 2.0.51.22-r2)
Diffstat (limited to 'dev-lang')
-rw-r--r-- | dev-lang/ghc/ChangeLog | 5 | ||||
-rw-r--r-- | dev-lang/ghc/files/depsort.py | 65 | ||||
-rwxr-xr-x | dev-lang/ghc/files/ghc-updater | 18 |
3 files changed, 86 insertions, 2 deletions
diff --git a/dev-lang/ghc/ChangeLog b/dev-lang/ghc/ChangeLog index 1692deea1025..c1649aad102b 100644 --- a/dev-lang/ghc/ChangeLog +++ b/dev-lang/ghc/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for dev-lang/ghc # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.70 2005/10/05 00:02:39 araujo Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.71 2005/10/06 12:43:58 dcoutts Exp $ + + 06 Oct 2005; <duncan@gentoo.org> +files/depsort.py, files/ghc-updater: + Make the ghc-updater script work better. 04 Oct 2005; Luis F. Araujo <araujo@gentoo.org> ghc-6.2.2.ebuild: Blocked ghc6.4 in ghc6.2.2 diff --git a/dev-lang/ghc/files/depsort.py b/dev-lang/ghc/files/depsort.py new file mode 100644 index 000000000000..4c3cb7bc84ab --- /dev/null +++ b/dev-lang/ghc/files/depsort.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/ghc/files/ghc-updater b/dev-lang/ghc/files/ghc-updater index a1bd116ef8f5..e013ee931936 100755 --- a/dev-lang/ghc/files/ghc-updater +++ b/dev-lang/ghc/files/ghc-updater @@ -120,6 +120,17 @@ elog() { setup_portdir +find_in_portdir() { + local f + for f in ${PORTDIR} ${PORTDIR_OVERLAYS}; do + if [[ -f "${f}/${1}" ]]; then + echo "${f}/${1}" + return 0 + fi + done + return 1 +} + if [ -z "${PORTDIR}" ]; then eerror "Unable to proceed. Can not find PORTDIR. Make sure the command:" eerror " " @@ -208,7 +219,12 @@ done eloginfo "Re-ordering packages to merge .." -PKGS_OK_SORTED="$(${PORTAGE_PYTHON} ${PORTDIR}/dev-lang/python/files/depreorder.py ${PKGS_OK} | xargs)" +DEPSORT=$(find_in_portdir "dev-lang/ghc/files/depsort.py") +if [[ -z ${DEPSORT} ]]; then + eerror "Fatal error: File dev-lang/ghc/files/depsort.py in portage tree." + exit 1 +fi +PKGS_OK_SORTED="$(${PORTAGE_PYTHON} ${DEPSORT} ${PKGS_OK} | xargs)" eloginfo "Preparing to merge these packages in this order:" for pkg in $PKGS_OK_SORTED; do |