|
13 | 13 | from cfbs.analyze import analyze_policyset |
14 | 14 | from cfbs.args import get_args |
15 | 15 |
|
| 16 | +from cfbs.cfbs_json import CFBSJson |
16 | 17 | from cfbs.utils import ( |
17 | 18 | cfbs_dir, |
18 | 19 | cfbs_filename, |
|
43 | 44 | from cfbs.cfbs_config import CFBSConfig, CFBSReturnWithoutCommit |
44 | 45 | from cfbs.validate import validate_config |
45 | 46 | from cfbs.internal_file_management import ( |
| 47 | + clone_url_repo, |
46 | 48 | fetch_archive, |
47 | 49 | get_download_path, |
48 | 50 | local_module_copy, |
@@ -757,13 +759,19 @@ def update_module(old_module, new_module, module_updates, update): |
757 | 759 | {item: old_module["name"] for item in extra} |
758 | 760 | ) |
759 | 761 |
|
760 | | - if not update.version: |
761 | | - update.version = new_module["version"] |
762 | | - module_updates.msg += "\n - Updated module '%s' from version %s to version %s" % ( |
763 | | - update.name, |
764 | | - old_module["version"], |
765 | | - update.version, |
766 | | - ) |
| 762 | + if new_module.get("version"): |
| 763 | + if not update.version: |
| 764 | + update.version = new_module["version"] |
| 765 | + module_updates.msg += ( |
| 766 | + "\n - Updated module '%s' from version %s to version %s" |
| 767 | + % ( |
| 768 | + update.name, |
| 769 | + old_module["version"], |
| 770 | + update.version, |
| 771 | + ) |
| 772 | + ) |
| 773 | + else: |
| 774 | + module_updates.msg += "\n - Updated module '%s' from url" % (update.name) |
767 | 775 |
|
768 | 776 |
|
769 | 777 | @cfbs_command("update") |
@@ -810,41 +818,57 @@ def update_command(to_update): |
810 | 818 | log.warning("Module '%s' not in build. Skipping its update." % update.name) |
811 | 819 | continue |
812 | 820 |
|
813 | | - if "version" not in old_module: |
814 | | - log.warning( |
815 | | - "Module '%s' not updatable. Skipping its update." % old_module["name"] |
| 821 | + if "url" in old_module: |
| 822 | + path, commit = clone_url_repo(old_module["url"]) |
| 823 | + remote_config = CFBSJson( |
| 824 | + path=path, url=old_module["url"], url_commit=commit |
816 | 825 | ) |
817 | | - log.debug("Module '%s' has no version attribute." % old_module["name"]) |
818 | | - continue |
819 | 826 |
|
820 | | - index_info = index.get_module_object(update.name) |
821 | | - if not index_info: |
822 | | - log.warning( |
823 | | - "Module '%s' not present in the index, cannot update it." |
824 | | - % old_module["name"] |
825 | | - ) |
826 | | - continue |
| 827 | + module_name = old_module["name"] |
| 828 | + provides = remote_config.get_provides() |
827 | 829 |
|
828 | | - local_ver = [ |
829 | | - int(version_number) |
830 | | - for version_number in re.split(r"[-\.]", old_module["version"]) |
831 | | - ] |
832 | | - index_ver = [ |
833 | | - int(version_number) |
834 | | - for version_number in re.split(r"[-\.]", index_info["version"]) |
835 | | - ] |
836 | | - if local_ver == index_ver: |
837 | | - print("Module '%s' already up to date" % old_module["name"]) |
838 | | - continue |
839 | | - elif local_ver > index_ver: |
840 | | - log.warning( |
841 | | - "The requested version of module '%s' is older than current version (%s < %s)." |
842 | | - " Skipping its update." |
843 | | - % (old_module["name"], index_info["version"], old_module["version"]) |
844 | | - ) |
845 | | - continue |
| 830 | + if not module_name or module_name not in provides: |
| 831 | + continue |
| 832 | + |
| 833 | + new_module = provides[module_name] |
| 834 | + else: |
| 835 | + |
| 836 | + if "version" not in old_module: |
| 837 | + log.warning( |
| 838 | + "Module '%s' not updatable. Skipping its update." |
| 839 | + % old_module["name"] |
| 840 | + ) |
| 841 | + log.debug("Module '%s' has no version attribute." % old_module["name"]) |
| 842 | + continue |
| 843 | + |
| 844 | + index_info = index.get_module_object(update.name) |
| 845 | + if not index_info: |
| 846 | + log.warning( |
| 847 | + "Module '%s' not present in the index, cannot update it." |
| 848 | + % old_module["name"] |
| 849 | + ) |
| 850 | + continue |
| 851 | + |
| 852 | + local_ver = [ |
| 853 | + int(version_number) |
| 854 | + for version_number in re.split(r"[-\.]", old_module["version"]) |
| 855 | + ] |
| 856 | + index_ver = [ |
| 857 | + int(version_number) |
| 858 | + for version_number in re.split(r"[-\.]", index_info["version"]) |
| 859 | + ] |
| 860 | + if local_ver == index_ver: |
| 861 | + print("Module '%s' already up to date" % old_module["name"]) |
| 862 | + continue |
| 863 | + elif local_ver > index_ver: |
| 864 | + log.warning( |
| 865 | + "The requested version of module '%s' is older than current version (%s < %s)." |
| 866 | + " Skipping its update." |
| 867 | + % (old_module["name"], index_info["version"], old_module["version"]) |
| 868 | + ) |
| 869 | + continue |
846 | 870 |
|
847 | | - new_module = index_info |
| 871 | + new_module = index_info |
848 | 872 |
|
849 | 873 | update_module(old_module, new_module, module_updates, update) |
850 | 874 |
|
|
0 commit comments