Permalink
Browse files

added double-inclusion QA checker by Zac

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
1 parent a63cea8 commit f17053f29a2b5b77c24bc85ee6d7f5dedf303a1c @trofi committed Mar 22, 2012
Showing with 103 additions and 0 deletions.
  1. +36 −0 profiles/make-profiles-graph.sh
  2. +10 −0 profiles/profile-debug.py
  3. +57 −0 profiles/profile-double-inclusion.py
View
36 profiles/make-profiles-graph.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+profile_root=$(portageq envvar PORTDIR)/profiles
+profile_root=$(realpath "${profile_root}")
+
+profile_tree() {
+ local src_profile=$1
+ local src_profile_name=${src_profile#${profile_root}/}
+ local dst_p
+ local dst_profile
+ local dst_profile_name
+
+ [[ -f "$1/parent" ]] || return
+
+ while read dst_p; do
+ if [[ $dst_p != *"#"* ]]; then
+ dst_profile=$(realpath "${src_profile}/${dst_p}")
+ dst_profile_name=${dst_profile#${profile_root}/}
+
+ echo " \"${src_profile_name}\" -> \"${dst_profile_name}\""
+ profile_tree "${dst_profile}"
+ fi
+ done < "$1/parent"
+}
+
+{
+echo "digraph profiles {"
+
+for p in "$@"
+do
+ profile_tree "${profile_root}/$p"
+done | sort -u
+
+echo "}"
+} > profiles.dot
+dot -Tpng profiles.dot > profiles.png
View
10 profiles/profile-debug.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+# http://archives.gentoo.org/gentoo-dev/msg_75881dcc749478a4fe7659d9b3594c75.xml
+
+import sys
+import portage
+
+c = portage.config(config_profile_path=sys.argv[1])
+for x in c.profiles:
+ sys.stdout.write("%s\n" % (x,))
View
57 profiles/profile-double-inclusion.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+# http://archives.gentoo.org/gentoo-dev/msg_75881dcc749478a4fe7659d9b3594c75.xml
+
+import operator
+import os
+import sys
+import portage
+
+def grab_profiles_desc(repo_path):
+
+ lines = portage.util.grablines(
+ os.path.join(repo_path, "profiles", "profiles.desc"))
+
+ profiles = []
+
+ for line in lines:
+
+ if line.startswith("#"):
+ continue
+
+ line_split = line.split()
+ if line_split:
+ profiles.append(line_split)
+
+ return profiles
+
+def check_double_inclusion(repo_path, profile, out):
+
+ profiles_dir = os.path.join(repo_path, "profiles")
+ profile_path = os.path.join(profiles_dir, profile[1])
+ c = portage.config(config_profile_path=profile_path)
+
+ if len(c.profiles) != len(set(c.profiles)):
+
+ previous = set()
+ duplicates = set()
+
+ for x in c.profiles:
+ if x in previous:
+ duplicates.add(x)
+ previous.add(x)
+
+ out.write("%s\t%s\n" % (profile[1],
+ "\t".join((x[len(profiles_dir)+1:] for x in sorted(duplicates)))))
+
+def main():
+
+ portdir = os.path.realpath(portage.settings["PORTDIR"])
+ profiles_desc = grab_profiles_desc(portdir)
+ profiles_desc.sort(key=operator.itemgetter(1))
+
+ for profile in profiles_desc:
+ check_double_inclusion(portdir, profile, sys.stdout)
+
+if __name__ == "__main__":
+ main()

0 comments on commit f17053f

Please sign in to comment.