summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-07-31 01:06:26 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-31 08:02:11 +0100
commitde3abcf78ad4cab5c26fa272a5fcccfd17cccdd5 (patch)
tree9884618b0e4e5dcb7b3ad0f7b80fde303cbc37b9
parent6bea86370491ec1b98975eed8e0003c234a2048f (diff)
downloadpoky-de3abcf78ad4cab5c26fa272a5fcccfd17cccdd5.tar.gz
combo-layer: allow splitting out local config
Allow splitting the local parts of the configuration (mostly local_repo_dir and last_revision, although there is no limitation) to a side-by-side -local.conf file, with component sections optionally tagged with the combo layer branch name. This effectively allows you to: * avoid polluting the history by committing the updated last revision to the combo repository for every update * avoid putting local repo paths into the combo repository * manage multiple branches of the combo repository whilst avoiding the possibility of mixing the configuration for one branch with another. An example split configuration (note, values may be artificial): ------------------- combo-layer.conf ------------------- [bitbake] src_uri = git://git.openembedded.org/bitbake dest_dir = bitbake hook = scripts/combo-layer-hook-default.sh [oe-core] src_uri = git://git.openembedded.org/openembedded-core dest_dir = . hook = scripts/combo-layer-hook-default.sh -------------------------------------------------------- ---------------- combo-layer-local.conf ---------------- [bitbake] local_repo_dir = ../repos/bitbake [oe-core] local_repo_dir = ../repos/oe-core [bitbake|master] branch = master last_revision = db689a99beffea1a285cdfc74a58fe73f1666987 [oe-core|master] branch = master last_revision = 121a1499a81706366acc0081272a6bff634d4d62 [bitbake|denzil] branch = 1.12 last_revision = 24b631acdaa143a4de39c6e1328849660c66f219 [oe-core|denzil] branch = denzil last_revision = 741146fa90f28f7ce8d82ee7f7e254872d519724 -------------------------------------------------------- It is assumed that the local config file will be added to .gitignore. (From OE-Core rev: f0065d7a6973628803a17c57f2265512aba3234c) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/combo-layer73
1 files changed, 65 insertions, 8 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 95653b0c21..516fffbec6 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -39,6 +39,15 @@ def logger_create():
39 39
40logger = logger_create() 40logger = logger_create()
41 41
42def get_current_branch(repodir=None):
43 try:
44 branchname = runcmd("git symbolic-ref HEAD 2>/dev/null", repodir).strip()
45 if branchname.startswith("refs/heads/"):
46 branchname = branchname[11:]
47 return branchname
48 except subprocess.CalledProcessError:
49 return ""
50
42class Configuration(object): 51class Configuration(object):
43 """ 52 """
44 Manages the configuration 53 Manages the configuration
@@ -49,30 +58,78 @@ class Configuration(object):
49 def __init__(self, options): 58 def __init__(self, options):
50 for key, val in options.__dict__.items(): 59 for key, val in options.__dict__.items():
51 setattr(self, key, val) 60 setattr(self, key, val)
52 self.parser = ConfigParser.ConfigParser() 61
53 self.parser.readfp(open(self.conffile)) 62 def readsection(parser, section, repo):
54 self.repos = {} 63 for (name, value) in parser.items(section):
55 for repo in self.parser.sections():
56 self.repos[repo] = {}
57 for (name, value) in self.parser.items(repo):
58 if value.startswith("@"): 64 if value.startswith("@"):
59 self.repos[repo][name] = eval(value.strip("@")) 65 self.repos[repo][name] = eval(value.strip("@"))
60 else: 66 else:
61 self.repos[repo][name] = value 67 self.repos[repo][name] = value
62 68
69 logger.debug("Loading config file %s" % self.conffile)
70 self.parser = ConfigParser.ConfigParser()
71 with open(self.conffile) as f:
72 self.parser.readfp(f)
73
74 self.repos = {}
75 for repo in self.parser.sections():
76 self.repos[repo] = {}
77 readsection(self.parser, repo, repo)
78
79 # Load local configuration, if available
80 self.localconffile = None
81 self.localparser = None
82 self.combobranch = None
83 if self.conffile.endswith('.conf'):
84 lcfile = self.conffile.replace('.conf', '-local.conf')
85 if os.path.exists(lcfile):
86 # Read combo layer branch
87 self.combobranch = get_current_branch()
88 logger.debug("Combo layer branch is %s" % self.combobranch)
89
90 self.localconffile = lcfile
91 logger.debug("Loading local config file %s" % self.localconffile)
92 self.localparser = ConfigParser.ConfigParser()
93 with open(self.localconffile) as f:
94 self.localparser.readfp(f)
95
96 for section in self.localparser.sections():
97 if '|' in section:
98 sectionvals = section.split('|')
99 repo = sectionvals[0]
100 if sectionvals[1] != self.combobranch:
101 continue
102 else:
103 repo = section
104 if repo in self.repos:
105 readsection(self.localparser, section, repo)
106
63 def update(self, repo, option, value): 107 def update(self, repo, option, value):
64 self.parser.set(repo, option, value) 108 if self.localparser:
65 self.parser.write(open(self.conffile, "w")) 109 parser = self.localparser
110 section = "%s|%s" % (repo, self.combobranch)
111 conffile = self.localconffile
112 else:
113 parser = self.parser
114 section = repo
115 conffile = self.conffile
116 parser.set(section, option, value)
117 with open(conffile, "w") as f:
118 parser.write(f)
66 119
67 def sanity_check(self): 120 def sanity_check(self):
68 required_options=["src_uri", "local_repo_dir", "dest_dir", "last_revision"] 121 required_options=["src_uri", "local_repo_dir", "dest_dir", "last_revision"]
69 msg = "" 122 msg = ""
123 missing_options = []
70 for name in self.repos: 124 for name in self.repos:
71 for option in required_options: 125 for option in required_options:
72 if option not in self.repos[name]: 126 if option not in self.repos[name]:
73 msg = "%s\nOption %s is not defined for component %s" %(msg, option, name) 127 msg = "%s\nOption %s is not defined for component %s" %(msg, option, name)
128 missing_options.append(option)
74 if msg != "": 129 if msg != "":
75 logger.error("configuration file %s has the following error: %s" % (self.conffile,msg)) 130 logger.error("configuration file %s has the following error: %s" % (self.conffile,msg))
131 if self.localconffile and 'last_revision' in missing_options:
132 logger.error("local configuration file %s may be missing configuration for combo branch %s" % (self.localconffile, self.combobranch))
76 sys.exit(1) 133 sys.exit(1)
77 134
78 # filterdiff is required by action_splitpatch, so check its availability 135 # filterdiff is required by action_splitpatch, so check its availability