|
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, |
@@ -815,41 +817,57 @@ def update_command(to_update): |
815 | 817 | log.warning("Module '%s' not in build. Skipping its update." % update.name) |
816 | 818 | continue |
817 | 819 |
|
818 | | - if "version" not in old_module: |
819 | | - log.warning( |
820 | | - "Module '%s' not updatable. Skipping its update." % old_module["name"] |
| 820 | + if "url" in old_module: |
| 821 | + path, commit = clone_url_repo(old_module["url"]) |
| 822 | + remote_config = CFBSJson( |
| 823 | + path=path, url=old_module["url"], url_commit=commit |
821 | 824 | ) |
822 | | - log.debug("Module '%s' has no version attribute." % old_module["name"]) |
823 | | - continue |
824 | 825 |
|
825 | | - index_info = index.get_module_object(update.name) |
826 | | - if not index_info: |
827 | | - log.warning( |
828 | | - "Module '%s' not present in the index, cannot update it." |
829 | | - % old_module["name"] |
830 | | - ) |
831 | | - continue |
| 826 | + module_name = old_module["name"] |
| 827 | + provides = remote_config.get_provides() |
832 | 828 |
|
833 | | - local_ver = [ |
834 | | - int(version_number) |
835 | | - for version_number in re.split(r"[-\.]", old_module["version"]) |
836 | | - ] |
837 | | - index_ver = [ |
838 | | - int(version_number) |
839 | | - for version_number in re.split(r"[-\.]", index_info["version"]) |
840 | | - ] |
841 | | - if local_ver == index_ver: |
842 | | - print("Module '%s' already up to date" % old_module["name"]) |
843 | | - continue |
844 | | - elif local_ver > index_ver: |
845 | | - log.warning( |
846 | | - "The requested version of module '%s' is older than current version (%s < %s)." |
847 | | - " Skipping its update." |
848 | | - % (old_module["name"], index_info["version"], old_module["version"]) |
849 | | - ) |
850 | | - continue |
| 829 | + if not module_name or module_name not in provides: |
| 830 | + continue |
| 831 | + |
| 832 | + new_module = provides[module_name] |
| 833 | + else: |
| 834 | + |
| 835 | + if "version" not in old_module: |
| 836 | + log.warning( |
| 837 | + "Module '%s' not updatable. Skipping its update." |
| 838 | + % old_module["name"] |
| 839 | + ) |
| 840 | + log.debug("Module '%s' has no version attribute." % old_module["name"]) |
| 841 | + continue |
| 842 | + |
| 843 | + index_info = index.get_module_object(update.name) |
| 844 | + if not index_info: |
| 845 | + log.warning( |
| 846 | + "Module '%s' not present in the index, cannot update it." |
| 847 | + % old_module["name"] |
| 848 | + ) |
| 849 | + continue |
| 850 | + |
| 851 | + local_ver = [ |
| 852 | + int(version_number) |
| 853 | + for version_number in re.split(r"[-\.]", old_module["version"]) |
| 854 | + ] |
| 855 | + index_ver = [ |
| 856 | + int(version_number) |
| 857 | + for version_number in re.split(r"[-\.]", index_info["version"]) |
| 858 | + ] |
| 859 | + if local_ver == index_ver: |
| 860 | + print("Module '%s' already up to date" % old_module["name"]) |
| 861 | + continue |
| 862 | + elif local_ver > index_ver: |
| 863 | + log.warning( |
| 864 | + "The requested version of module '%s' is older than current version (%s < %s)." |
| 865 | + " Skipping its update." |
| 866 | + % (old_module["name"], index_info["version"], old_module["version"]) |
| 867 | + ) |
| 868 | + continue |
851 | 869 |
|
852 | | - new_module = index_info |
| 870 | + new_module = index_info |
853 | 871 |
|
854 | 872 | msg = update_module(old_module, new_module, module_updates, update) |
855 | 873 |
|
|
0 commit comments