This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added double-inclusion QA checker by Zac
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
- Loading branch information
Sergei Trofimovich
committed
Mar 22, 2012
1 parent
a63cea8
commit f17053f
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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,)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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() |