diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2016-05-02 15:27:26 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-11 10:33:41 +0100 |
commit | aa4de3c8c5617e8d59cc3085463dc8493edc20df (patch) | |
tree | 4ba5516cd919c471016ba848666fe813a5e16dd6 /scripts/combo-layer | |
parent | eb0ab04149d4d2f3966bce7dd2060d68c6963131 (diff) | |
download | poky-aa4de3c8c5617e8d59cc3085463dc8493edc20df.tar.gz |
combo-layer: dummy "update with history"
When setting "history = True" in combo-layer.conf consistently for the
components involved in an update or using "update" together with the
"--history" command line flag, a new mode for updating will be used
that does not rely on exporting/importing patches.
A config setting is used because it should be used consistently by
everyone using the same config, without having to remember to use an
additional command line parameter.
There are no real global settings, so the setting is checked
separately for each component although the setting has to be set
consistently. This restriction could be removed later.
In practice, putting "history" into the "[DEFAULT]" section is the
easiest approach for configuring it.
The actual code changes split up action_update and the
combo-layer.conf handling in preparation for this new mode, without
implementing the mode itself.
(From OE-Core rev: c9dab31f5f6dc225f5c2c2ca3ec9aeab2ff655d5)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-x | scripts/combo-layer | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 91270415fc..41d69f8ddb 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -73,7 +73,7 @@ class Configuration(object): | |||
73 | else: | 73 | else: |
74 | # Apply special type transformations for some properties. | 74 | # Apply special type transformations for some properties. |
75 | # Type matches the RawConfigParser.get*() methods. | 75 | # Type matches the RawConfigParser.get*() methods. |
76 | types = {'signoff': 'boolean', 'update': 'boolean'} | 76 | types = {'signoff': 'boolean', 'update': 'boolean', 'history': 'boolean'} |
77 | if name in types: | 77 | if name in types: |
78 | value = getattr(parser, 'get' + types[name])(section, name) | 78 | value = getattr(parser, 'get' + types[name])(section, name) |
79 | self.repos[repo][name] = value | 79 | self.repos[repo][name] = value |
@@ -610,8 +610,12 @@ def action_pull(conf, args): | |||
610 | def action_update(conf, args): | 610 | def action_update(conf, args): |
611 | """ | 611 | """ |
612 | update the component repos | 612 | update the component repos |
613 | generate the patch list | 613 | either: |
614 | apply the generated patches | 614 | generate the patch list |
615 | apply the generated patches | ||
616 | or: | ||
617 | re-creates the entire component history and merges them | ||
618 | into the current branch with a merge commit | ||
615 | """ | 619 | """ |
616 | components = [arg.split(':')[0] for arg in args[1:]] | 620 | components = [arg.split(':')[0] for arg in args[1:]] |
617 | revisions = {} | 621 | revisions = {} |
@@ -624,10 +628,23 @@ def action_update(conf, args): | |||
624 | # make sure combo repo is clean | 628 | # make sure combo repo is clean |
625 | check_repo_clean(os.getcwd()) | 629 | check_repo_clean(os.getcwd()) |
626 | 630 | ||
627 | import uuid | 631 | # Check whether we keep the component histories. Must be |
628 | patch_dir = "patch-%s" % uuid.uuid4() | 632 | # set either via --history command line parameter or consistently |
629 | if not os.path.exists(patch_dir): | 633 | # in combo-layer.conf. Mixing modes is (currently, and probably |
630 | os.mkdir(patch_dir) | 634 | # permanently because it would be complicated) not supported. |
635 | if conf.history: | ||
636 | history = True | ||
637 | else: | ||
638 | history = None | ||
639 | for name in repos: | ||
640 | repo = conf.repos[name] | ||
641 | repo_history = repo.get('history', True) | ||
642 | logger.error('%s: %s' % (name, repo_history)) | ||
643 | if history is None: | ||
644 | history = repo_history | ||
645 | elif history != repo_history: | ||
646 | logger.error("'history' property is set inconsistently") | ||
647 | sys.exit(1) | ||
631 | 648 | ||
632 | # Step 1: update the component repos | 649 | # Step 1: update the component repos |
633 | if conf.nopull: | 650 | if conf.nopull: |
@@ -635,6 +652,18 @@ def action_update(conf, args): | |||
635 | else: | 652 | else: |
636 | action_pull(conf, ['arg0'] + components) | 653 | action_pull(conf, ['arg0'] + components) |
637 | 654 | ||
655 | if history: | ||
656 | logger.error("update with history not implemented yet") | ||
657 | sys.exit(1) | ||
658 | else: | ||
659 | update_with_patches(conf, components, revisions, repos) | ||
660 | |||
661 | def update_with_patches(conf, components, revisions, repos): | ||
662 | import uuid | ||
663 | patch_dir = "patch-%s" % uuid.uuid4() | ||
664 | if not os.path.exists(patch_dir): | ||
665 | os.mkdir(patch_dir) | ||
666 | |||
638 | for name in repos: | 667 | for name in repos: |
639 | revision = revisions.get(name, None) | 668 | revision = revisions.get(name, None) |
640 | repo = conf.repos[name] | 669 | repo = conf.repos[name] |
@@ -711,6 +740,21 @@ def action_update(conf, args): | |||
711 | runcmd("rm -rf %s" % patch_dir) | 740 | runcmd("rm -rf %s" % patch_dir) |
712 | 741 | ||
713 | # Step 7: commit the updated config file if it's being tracked | 742 | # Step 7: commit the updated config file if it's being tracked |
743 | commit_conf_file(conf, components) | ||
744 | |||
745 | def conf_commit_msg(conf, components): | ||
746 | # create the "components" string | ||
747 | component_str = "all components" | ||
748 | if len(components) > 0: | ||
749 | # otherwise tell which components were actually changed | ||
750 | component_str = ", ".join(components) | ||
751 | |||
752 | # expand the template with known values | ||
753 | template = Template(conf.commit_msg_template) | ||
754 | msg = template.substitute(components = component_str) | ||
755 | return msg | ||
756 | |||
757 | def commit_conf_file(conf, components, commit=True): | ||
714 | relpath = os.path.relpath(conf.conffile) | 758 | relpath = os.path.relpath(conf.conffile) |
715 | try: | 759 | try: |
716 | output = runcmd("git status --porcelain %s" % relpath, printerr=False) | 760 | output = runcmd("git status --porcelain %s" % relpath, printerr=False) |
@@ -718,23 +762,15 @@ def action_update(conf, args): | |||
718 | # Outside the repository | 762 | # Outside the repository |
719 | output = None | 763 | output = None |
720 | if output: | 764 | if output: |
721 | logger.info("Committing updated configuration file") | ||
722 | if output.lstrip().startswith("M"): | 765 | if output.lstrip().startswith("M"): |
723 | 766 | logger.info("Committing updated configuration file") | |
724 | # create the "components" string | 767 | if commit: |
725 | component_str = "all components" | 768 | msg = conf_commit_msg(conf, components) |
726 | if len(components) > 0: | 769 | runcmd('git commit -m'.split() + [msg, relpath]) |
727 | # otherwise tell which components were actually changed | 770 | else: |
728 | component_str = ", ".join(components) | 771 | runcmd('git add %s' % relpath) |
729 | 772 | return True | |
730 | # expand the template with known values | 773 | return False |
731 | template = Template(conf.commit_msg_template) | ||
732 | raw_msg = template.substitute(components = component_str) | ||
733 | |||
734 | # sanitize the string before using it in command line | ||
735 | msg = raw_msg.replace('"', '\\"') | ||
736 | |||
737 | runcmd('git commit -m "%s" %s' % (msg, relpath)) | ||
738 | 774 | ||
739 | def apply_patchlist(conf, repos): | 775 | def apply_patchlist(conf, repos): |
740 | """ | 776 | """ |