Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
added double-inclusion QA checker by Zac
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information
Sergei Trofimovich committed Mar 22, 2012
1 parent a63cea8 commit f17053f
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 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
10 changes: 10 additions & 0 deletions 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,))
57 changes: 57 additions & 0 deletions 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.