diff options
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-x | scripts/combo-layer | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index a634dd69d2..4a715914af 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -19,9 +19,8 @@ import tempfile | |||
19 | import configparser | 19 | import configparser |
20 | import re | 20 | import re |
21 | import copy | 21 | import copy |
22 | import pipes | 22 | import shlex |
23 | import shutil | 23 | import shutil |
24 | from collections import OrderedDict | ||
25 | from string import Template | 24 | from string import Template |
26 | from functools import reduce | 25 | from functools import reduce |
27 | 26 | ||
@@ -192,6 +191,23 @@ def runcmd(cmd,destdir=None,printerr=True,out=None,env=None): | |||
192 | logger.debug("output: %s" % output.replace(chr(0), '\\0')) | 191 | logger.debug("output: %s" % output.replace(chr(0), '\\0')) |
193 | return output | 192 | return output |
194 | 193 | ||
194 | def action_sync_revs(conf, args): | ||
195 | """ | ||
196 | Update the last_revision config option for each repo with the latest | ||
197 | revision in the remote's branch. Useful if multiple people are using | ||
198 | combo-layer. | ||
199 | """ | ||
200 | repos = get_repos(conf, args[1:]) | ||
201 | |||
202 | for name in repos: | ||
203 | repo = conf.repos[name] | ||
204 | ldir = repo['local_repo_dir'] | ||
205 | branch = repo.get('branch', "master") | ||
206 | runcmd("git fetch", ldir) | ||
207 | lastrev = runcmd('git rev-parse origin/%s' % branch, ldir).strip() | ||
208 | print("Updating %s to %s" % (name, lastrev)) | ||
209 | conf.update(name, "last_revision", lastrev) | ||
210 | |||
195 | def action_init(conf, args): | 211 | def action_init(conf, args): |
196 | """ | 212 | """ |
197 | Clone component repositories | 213 | Clone component repositories |
@@ -467,7 +483,7 @@ def check_repo_clean(repodir): | |||
467 | exit if repo is dirty | 483 | exit if repo is dirty |
468 | """ | 484 | """ |
469 | output=runcmd("git status --porcelain", repodir) | 485 | output=runcmd("git status --porcelain", repodir) |
470 | r = re.compile('\?\? patch-.*/') | 486 | r = re.compile(r'\?\? patch-.*/') |
471 | dirtyout = [item for item in output.splitlines() if not r.match(item)] | 487 | dirtyout = [item for item in output.splitlines() if not r.match(item)] |
472 | if dirtyout: | 488 | if dirtyout: |
473 | logger.error("git repo %s is dirty, please fix it first", repodir) | 489 | logger.error("git repo %s is dirty, please fix it first", repodir) |
@@ -508,7 +524,7 @@ def check_patch(patchfile): | |||
508 | f.close() | 524 | f.close() |
509 | if of: | 525 | if of: |
510 | of.close() | 526 | of.close() |
511 | os.rename(patchfile + '.tmp', patchfile) | 527 | os.rename(of.name, patchfile) |
512 | 528 | ||
513 | def drop_to_shell(workdir=None): | 529 | def drop_to_shell(workdir=None): |
514 | if not sys.stdin.isatty(): | 530 | if not sys.stdin.isatty(): |
@@ -1259,7 +1275,7 @@ def apply_commit(parent, rev, largs, wargs, dest_dir, file_filter=None): | |||
1259 | target = os.path.join(wargs["destdir"], dest_dir) | 1275 | target = os.path.join(wargs["destdir"], dest_dir) |
1260 | if not os.path.isdir(target): | 1276 | if not os.path.isdir(target): |
1261 | os.makedirs(target) | 1277 | os.makedirs(target) |
1262 | quoted_target = pipes.quote(target) | 1278 | quoted_target = shlex.quote(target) |
1263 | # os.sysconf('SC_ARG_MAX') is lying: running a command with | 1279 | # os.sysconf('SC_ARG_MAX') is lying: running a command with |
1264 | # string length 629343 already failed with "Argument list too | 1280 | # string length 629343 already failed with "Argument list too |
1265 | # long" although SC_ARG_MAX = 2097152. "man execve" explains | 1281 | # long" although SC_ARG_MAX = 2097152. "man execve" explains |
@@ -1271,7 +1287,7 @@ def apply_commit(parent, rev, largs, wargs, dest_dir, file_filter=None): | |||
1271 | unquoted_args = [] | 1287 | unquoted_args = [] |
1272 | cmdsize = 100 + len(quoted_target) | 1288 | cmdsize = 100 + len(quoted_target) |
1273 | while update: | 1289 | while update: |
1274 | quoted_next = pipes.quote(update[0]) | 1290 | quoted_next = shlex.quote(update[0]) |
1275 | size_next = len(quoted_next) + len(dest_dir) + 1 | 1291 | size_next = len(quoted_next) + len(dest_dir) + 1 |
1276 | logger.debug('cmdline length %d + %d < %d?' % (cmdsize, size_next, os.sysconf('SC_ARG_MAX'))) | 1292 | logger.debug('cmdline length %d + %d < %d?' % (cmdsize, size_next, os.sysconf('SC_ARG_MAX'))) |
1277 | if cmdsize + size_next < max_cmdsize: | 1293 | if cmdsize + size_next < max_cmdsize: |
@@ -1302,6 +1318,7 @@ actions = { | |||
1302 | "update": action_update, | 1318 | "update": action_update, |
1303 | "pull": action_pull, | 1319 | "pull": action_pull, |
1304 | "splitpatch": action_splitpatch, | 1320 | "splitpatch": action_splitpatch, |
1321 | "sync-revs": action_sync_revs, | ||
1305 | } | 1322 | } |
1306 | 1323 | ||
1307 | def main(): | 1324 | def main(): |
@@ -1312,10 +1329,11 @@ def main(): | |||
1312 | Create and update a combination layer repository from multiple component repositories. | 1329 | Create and update a combination layer repository from multiple component repositories. |
1313 | 1330 | ||
1314 | Action: | 1331 | Action: |
1315 | init initialise the combo layer repo | 1332 | init initialise the combo layer repo |
1316 | update [components] get patches from component repos and apply them to the combo repo | 1333 | update [components] get patches from component repos and apply them to the combo repo |
1317 | pull [components] just pull component repos only | 1334 | pull [components] just pull component repos only |
1318 | splitpatch [commit] generate commit patch and split per component, default commit is HEAD""") | 1335 | sync-revs [components] update the config file's last_revision for each repository |
1336 | splitpatch [commit] generate commit patch and split per component, default commit is HEAD""") | ||
1319 | 1337 | ||
1320 | parser.add_option("-c", "--conf", help = "specify the config file (conf/combo-layer.conf is the default).", | 1338 | parser.add_option("-c", "--conf", help = "specify the config file (conf/combo-layer.conf is the default).", |
1321 | action = "store", dest = "conffile", default = "conf/combo-layer.conf") | 1339 | action = "store", dest = "conffile", default = "conf/combo-layer.conf") |