summaryrefslogtreecommitdiffstats
path: root/scripts/combo-layer
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-07-31 10:22:05 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-31 10:59:06 (GMT)
commit74aac73d69985ebc41a18fd30111e3c9c82f434f (patch)
tree7861c8a199087b68401a23c61f2d1c0599063397 /scripts/combo-layer
parentf8d40ab395ffb8ed12731e318354fb3d30447e84 (diff)
downloadpoky-74aac73d69985ebc41a18fd30111e3c9c82f434f.tar.gz
combo-layer: ensure init works with split local config
If the local configuration is already split out, ensure the init action works properly and does not error in the case that last_revision is not set. Additionally, if the local configuration is within the repository, prevent it from being committed and add it to .gitignore. (From OE-Core rev: de339b0cb201035e27df1128ccf526937b8325ec) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-xscripts/combo-layer27
1 files changed, 23 insertions, 4 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 516fffb..448fe71 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -41,6 +41,9 @@ logger = logger_create()
41 41
42def get_current_branch(repodir=None): 42def get_current_branch(repodir=None):
43 try: 43 try:
44 if not os.path.exists(os.path.join(repodir if repodir else '', ".git")):
45 # Repo not created yet (i.e. during init) so just assume master
46 return "master"
44 branchname = runcmd("git symbolic-ref HEAD 2>/dev/null", repodir).strip() 47 branchname = runcmd("git symbolic-ref HEAD 2>/dev/null", repodir).strip()
45 if branchname.startswith("refs/heads/"): 48 if branchname.startswith("refs/heads/"):
46 branchname = branchname[11:] 49 branchname = branchname[11:]
@@ -104,11 +107,13 @@ class Configuration(object):
104 if repo in self.repos: 107 if repo in self.repos:
105 readsection(self.localparser, section, repo) 108 readsection(self.localparser, section, repo)
106 109
107 def update(self, repo, option, value): 110 def update(self, repo, option, value, initmode=False):
108 if self.localparser: 111 if self.localparser:
109 parser = self.localparser 112 parser = self.localparser
110 section = "%s|%s" % (repo, self.combobranch) 113 section = "%s|%s" % (repo, self.combobranch)
111 conffile = self.localconffile 114 conffile = self.localconffile
115 if initmode and not parser.has_section(section):
116 parser.add_section(section)
112 else: 117 else:
113 parser = self.parser 118 parser = self.parser
114 section = repo 119 section = repo
@@ -117,8 +122,10 @@ class Configuration(object):
117 with open(conffile, "w") as f: 122 with open(conffile, "w") as f:
118 parser.write(f) 123 parser.write(f)
119 124
120 def sanity_check(self): 125 def sanity_check(self, initmode=False):
121 required_options=["src_uri", "local_repo_dir", "dest_dir", "last_revision"] 126 required_options=["src_uri", "local_repo_dir", "dest_dir", "last_revision"]
127 if initmode:
128 required_options.remove("last_revision")
122 msg = "" 129 msg = ""
123 missing_options = [] 130 missing_options = []
124 for name in self.repos: 131 for name in self.repos:
@@ -185,8 +192,19 @@ def action_init(conf, args):
185 file_filter = repo.get('file_filter', "") 192 file_filter = repo.get('file_filter', "")
186 runcmd("git archive %s | tar -x -C %s %s" % (branch, extract_dir, file_filter), ldir) 193 runcmd("git archive %s | tar -x -C %s %s" % (branch, extract_dir, file_filter), ldir)
187 lastrev = runcmd("git rev-parse HEAD", ldir).strip() 194 lastrev = runcmd("git rev-parse HEAD", ldir).strip()
188 conf.update(name, "last_revision", lastrev) 195 conf.update(name, "last_revision", lastrev, initmode=True)
189 runcmd("git add .") 196 runcmd("git add .")
197 if conf.localconffile:
198 localadded = True
199 try:
200 runcmd("git rm --cached %s" % conf.localconffile, printerr=False)
201 except subprocess.CalledProcessError:
202 localadded = False
203 if localadded:
204 localrelpath = os.path.relpath(conf.localconffile)
205 runcmd("grep -q %s .gitignore || echo %s >> .gitignore" % (localrelpath, localrelpath))
206 runcmd("git add .gitignore")
207 logger.info("Added local configuration file %s to .gitignore", localrelpath)
190 logger.info("Initial combo layer repository data has been created; please make any changes if desired and then use 'git commit' to make the initial commit.") 208 logger.info("Initial combo layer repository data has been created; please make any changes if desired and then use 'git commit' to make the initial commit.")
191 else: 209 else:
192 logger.info("Repository already initialised, nothing to do.") 210 logger.info("Repository already initialised, nothing to do.")
@@ -552,7 +570,8 @@ Action:
552 if options.debug: 570 if options.debug:
553 logger.setLevel(logging.DEBUG) 571 logger.setLevel(logging.DEBUG)
554 confdata = Configuration(options) 572 confdata = Configuration(options)
555 confdata.sanity_check() 573 initmode = (args[1] == 'init')
574 confdata.sanity_check(initmode)
556 actions.get(args[1], action_error)(confdata, args[1:]) 575 actions.get(args[1], action_error)(confdata, args[1:])
557 576
558if __name__ == "__main__": 577if __name__ == "__main__":