Make the ghc-updater script work better.
authorDuncan Coutts <dcoutts@gentoo.org>
Thu, 6 Oct 2005 12:43:58 +0000 (12:43 +0000)
committerDuncan Coutts <dcoutts@gentoo.org>
Thu, 6 Oct 2005 12:43:58 +0000 (12:43 +0000)
Package-Manager: portage-2.0.51.22-r2

dev-lang/ghc/ChangeLog
dev-lang/ghc/Manifest
dev-lang/ghc/files/depsort.py [new file with mode: 0644]
dev-lang/ghc/files/ghc-updater

index 1692deea1025eba2717f3fa00ecaac0d88235bd9..c1649aad102b1e8173a63f73407b81a46878cf48 100644 (file)
@@ -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
index 78964995da772d49db9db21a6be7ac50ddec1889..50cf0f971ecd406b32f4e07915b696e57f59cc50 100644 (file)
@@ -1,24 +1,25 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-MD5 61737029efceb6072316909fd84998ec ChangeLog 12681
+MD5 e49767c6d695845b9a8bf406c519e2c4 ghc-6.4.1.ebuild 6084
 MD5 6b0575f665b30bd942f60a152f52dca8 ghc-6.0.1.ebuild 4709
 MD5 fe0e389aa3150e5fcfc59b4c5ff142cc ghc-6.2.2.ebuild 5581
-MD5 e49767c6d695845b9a8bf406c519e2c4 ghc-6.4.1.ebuild 6084
-MD5 a769ecfcd1cdd2d40986627df7dfb249 metadata.xml 224
 MD5 9620778937a1aff6ef88863c81222cfc ghc-6.4.ebuild 6109
-MD5 d417c9e24a826959ad6d921247e43328 files/digest-ghc-6.0.1 67
-MD5 7c38a5e2d5ecf8446f38ff41fa4d4152 files/digest-ghc-6.4.1 67
-MD5 9e9c22452b545fd9ec1367155c15d8e2 files/digest-ghc-6.2.2 67
-MD5 9c15b50bf0b73b7d70a06fd47510a3ef files/ghc-6.0.1.haddock.patch 380
+MD5 51f33d5881e583634b7ef5d964b9fae9 ChangeLog 12799
+MD5 a769ecfcd1cdd2d40986627df7dfb249 metadata.xml 224
+MD5 af174f2e566a288f0e2276883a866827 files/ghc-updater 9075
+MD5 7e423c353b08a2c05693d13f21e067d0 files/depsort.py 1958
 MD5 1ae8c6b539b6706ba0e8b988a918a944 files/ghc-6.2.hardened.patch 525
-MD5 558c6b9e9b0e15185b69cdfe241dad9a files/ghc-updater 8775
 MD5 ffd472c0685cf2766ce6533265f9a3c9 files/ghc-6.4-powerpc.patch 908
+MD5 d417c9e24a826959ad6d921247e43328 files/digest-ghc-6.0.1 67
+MD5 9e9c22452b545fd9ec1367155c15d8e2 files/digest-ghc-6.2.2 67
+MD5 7c38a5e2d5ecf8446f38ff41fa4d4152 files/digest-ghc-6.4.1 67
 MD5 75417bc4dea34cd08ea105457ccd3032 files/digest-ghc-6.4 65
+MD5 9c15b50bf0b73b7d70a06fd47510a3ef files/ghc-6.0.1.haddock.patch 380
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.2 (GNU/Linux)
+Version: GnuPG v1.4.1 (GNU/Linux)
 
-iD8DBQFDQxg2BQBy/eDH5uERAgx8AJ4pTj8pa+7G04kZ2cQKBqUAVDPtWACfU24c
-7eTsaVfgxqOUX6bSTfoWMJQ=
-=kygF
+iD8DBQFDRRx/kyZuKN4EQ6YRAl0IAJwOb6G/mIn9izIGOyw59cPcQ2S0agCdFTyv
+dXPorTZypYLFxpGrF/7YU8E=
+=7KCW
 -----END PGP SIGNATURE-----
diff --git a/dev-lang/ghc/files/depsort.py b/dev-lang/ghc/files/depsort.py
new file mode 100644 (file)
index 0000000..4c3cb7b
--- /dev/null
@@ -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)
index a1bd116ef8f507ab0431e96e333c377fc0e2342f..e013ee9319363720ead18261f75de03919a1f2b5 100755 (executable)
@@ -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