Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/
Date: Mon, 05 Mar 2012 00:01:55
Message-Id: 1330905689.6cd05a95afe799807c90e71d577fb87b1bd01093.zmedico@gentoo
1 commit: 6cd05a95afe799807c90e71d577fb87b1bd01093
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Mon Mar 5 00:01:29 2012 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Mar 5 00:01:29 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6cd05a95
7
8 repoman: support overlays without repo_name
9
10 ---
11 pym/repoman/utilities.py | 33 ++++++++++++++++++++++++++++++++-
12 1 files changed, 32 insertions(+), 1 deletions(-)
13
14 diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py
15 index 449005a..34d6494 100644
16 --- a/pym/repoman/utilities.py
17 +++ b/pym/repoman/utilities.py
18 @@ -1,5 +1,5 @@
19 # repoman: Utilities
20 -# Copyright 2007-2011 Gentoo Foundation
21 +# Copyright 2007-2012 Gentoo Foundation
22 # Distributed under the terms of the GNU General Public License v2
23
24 """This module contains utility functions to help repoman find ebuilds to
25 @@ -17,6 +17,7 @@ __all__ = [
26 "get_commit_message_with_editor",
27 "get_commit_message_with_stdin",
28 "get_committer_name",
29 + "have_ebuild_dir",
30 "have_profile_dir",
31 "parse_metadata_use",
32 "UnknownHerdsError",
33 @@ -30,6 +31,7 @@ from itertools import chain
34 import logging
35 import pwd
36 import re
37 +import stat
38 import sys
39 import time
40 import textwrap
41 @@ -126,6 +128,33 @@ def have_profile_dir(path, maxdepth=3, filename="profiles.desc"):
42 path = normalize_path(path + "/..")
43 maxdepth -= 1
44
45 +def have_ebuild_dir(path, maxdepth=3):
46 + """
47 + Try to figure out if 'path' or a subdirectory contains one or more
48 + ebuild files named appropriately for their parent directory.
49 + """
50 + stack = [(normalize_path(path), 1)]
51 + while stack:
52 + path, depth = stack.pop()
53 + basename = os.path.basename(path)
54 + try:
55 + listdir = os.listdir(path)
56 + except OSError:
57 + continue
58 + for filename in listdir:
59 + abs_filename = os.path.join(path, filename)
60 + try:
61 + st = os.stat(abs_filename)
62 + except OSError:
63 + continue
64 + if stat.S_ISDIR(st.st_mode):
65 + if depth < maxdepth:
66 + stack.append((abs_filename, depth + 1))
67 + elif stat.S_ISREG(st.st_mode):
68 + if filename.endswith(".ebuild") and \
69 + filename.startswith(basename + "-"):
70 + return os.path.dirname(os.path.dirname(path))
71 +
72 def parse_metadata_use(xml_tree):
73 """
74 Records are wrapped in XML as per GLEP 56
75 @@ -447,6 +476,8 @@ def FindPortdir(settings):
76 # file.
77 if not portdir_overlay:
78 portdir_overlay = have_profile_dir(location, filename="repo_name")
79 + if not portdir_overlay:
80 + portdir_overlay = have_ebuild_dir(location)
81 if portdir_overlay:
82 subdir = location[len(portdir_overlay):]
83 if subdir and subdir[-1] != os.sep: