Exemplo n.º 1
0
    def retro_compatibility_test(self):
        f = os.path.join(temp_folder(), "aux_file")
        save(f, """conan.io https://server.conan.io
""")  # Without SSL parameter
        new_path = os.path.join(temp_folder(), "aux_file.json")
        migrate_registry_file(f, new_path)
        registry = RemoteRegistry(new_path, TestBufferConanOutput())
        self.assertEqual(registry.remotes.list,
                         [("conan.io", "https://server.conan.io", True)])
Exemplo n.º 2
0
 def retro_compatibility_test(self):
     folder = temp_folder()
     f = os.path.join(folder, ".conan", "registry.txt")
     save(f, "conan.io https://server.conan.io")  # Without SSL parameter
     cache = ClientCache(folder, TestBufferConanOutput())
     migrate_registry_file(cache, TestBufferConanOutput())
     registry = RemoteRegistry(cache)
     self.assertEqual(list(registry.load_remotes().values()),
                      [("conan.io", "https://server.conan.io", True)])
Exemplo n.º 3
0
 def registry_path(self):
     reg_json_path = join(self.conan_folder, REGISTRY_JSON)
     if not os.path.exists(reg_json_path):
         # Load the txt if exists and convert to json
         reg_txt = join(self.conan_folder, REGISTRY)
         if os.path.exists(reg_txt):
             migrate_registry_file(reg_txt, reg_json_path)
         else:
             self._output.warn("Remotes registry file missing, "
                               "creating default one in %s" % reg_json_path)
             save(reg_json_path, dump_registry(default_remotes, {}, {}))
     return reg_json_path
Exemplo n.º 4
0
    def retro_compatibility_test(self):
        folder = temp_folder()
        f = os.path.join(folder, "registry.txt")
        save(f, textwrap.dedent("""conan.io https://server.conan.io

            pkg/0.1@user/testing some_remote
            """))
        output = TestBufferConanOutput()
        cache = ClientCache(folder, output)
        migrate_registry_file(cache, output)
        registry = RemoteRegistry(cache, output)
        self.assertEqual(list(registry.load_remotes().values()),
                         [("conan.io", "https://server.conan.io", True, False)])
Exemplo n.º 5
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return

        # Migrate the settings if they were the default for that version
        self._update_settings_yml(old_version)

        if old_version < Version("0.25"):
            from conans.paths import DEFAULT_PROFILE_NAME
            default_profile_path = os.path.join(self.cache.cache_folder,
                                                PROFILES_FOLDER,
                                                DEFAULT_PROFILE_NAME)
            if not os.path.exists(default_profile_path):
                self.out.warn(
                    "Migration: Moving default settings from %s file to %s" %
                    (CONAN_CONF, DEFAULT_PROFILE_NAME))
                conf_path = os.path.join(self.cache.cache_folder, CONAN_CONF)

                migrate_to_default_profile(conf_path, default_profile_path)

                self.out.warn("Migration: export_source cache new layout")
                migrate_c_src_export_source(self.cache, self.out)

        if old_version < Version("1.0"):
            _migrate_lock_files(self.cache, self.out)

        if old_version < Version("1.12.0"):
            migrate_plugins_to_hooks(self.cache)

        if old_version < Version("1.13.0"):
            # MIGRATE LOCAL CACHE TO GENERATE MISSING METADATA.json
            _migrate_create_metadata(self.cache, self.out)

        if old_version < Version("1.14.0"):
            migrate_config_install(self.cache)

        if old_version < Version("1.14.2"):
            _migrate_full_metadata(self.cache, self.out)

        if old_version < Version("1.15.0"):
            migrate_registry_file(self.cache, self.out)

        if old_version < Version("1.19.0"):
            migrate_localdb_refresh_token(self.cache, self.out)

        if old_version < Version("1.26.0"):
            migrate_editables_use_conanfile_name(self.cache, self.out)
Exemplo n.º 6
0
def _process_folder(config, folder, cache, output):
    if not os.path.isdir(folder):
        raise ConanException("No such directory: '%s'" % str(folder))
    if config.source_folder:
        folder = os.path.join(folder, config.source_folder)
    for root, dirs, files in walk(folder):
        dirs[:] = [d for d in dirs if d != ".git"]
        if ".git" in root:
            continue
        for f in files:
            if f == "settings.yml":
                output.info("Installing settings.yml")
                _filecopy(root, f, cache.cache_folder)
            elif f == "conan.conf":
                output.info("Processing conan.conf")
                _handle_conan_conf(cache.config, os.path.join(root, f))
            elif f == "remotes.txt":
                output.info("Defining remotes from remotes.txt")
                _handle_remotes(cache, os.path.join(root, f))
            elif f in ("registry.txt", "registry.json"):
                try:
                    os.remove(cache.remotes_path)
                except OSError:
                    pass
                finally:
                    _filecopy(root, f, cache.cache_folder)
                    migrate_registry_file(cache, output)
            elif f == "remotes.json":
                # Fix for Conan 2.0
                raise ConanException(
                    "remotes.json install is not supported yet. Use 'remotes.txt'"
                )
            else:
                # This is ugly, should be removed in Conan 2.0
                if root == folder and f in ("README.md", "LICENSE.txt"):
                    output.info("Skip %s" % f)
                    continue
                relpath = os.path.relpath(root, folder)
                if config.target_folder:
                    target_folder = os.path.join(cache.cache_folder,
                                                 config.target_folder, relpath)
                else:
                    target_folder = os.path.join(cache.cache_folder, relpath)
                mkdir(target_folder)
                output.info("Copying file %s to %s" % (f, target_folder))
                _filecopy(root, f, target_folder)
Exemplo n.º 7
0
def _process_file(directory, filename, config, cache, output, folder):
    if filename == "settings.yml":
        output.info("Installing settings.yml")
        _filecopy(directory, filename, cache.cache_folder)
    elif filename == "conan.conf":
        output.info("Processing conan.conf")
        _handle_conan_conf(cache.config, os.path.join(directory, filename))
    elif filename == "remotes.txt":
        output.info("Defining remotes from remotes.txt")
        _handle_remotes(cache, os.path.join(directory, filename))
    elif filename in ("registry.txt", "registry.json"):
        try:
            os.remove(cache.remotes_path)
        except OSError:
            pass
        finally:
            _filecopy(directory, filename, cache.cache_folder)
            migrate_registry_file(cache, output)
    elif filename == "remotes.json":
        # Fix for Conan 2.0
        raise ConanException(
            "remotes.json install is not supported yet. Use 'remotes.txt'")
    else:
        # This is ugly, should be removed in Conan 2.0
        if filename in ("README.md", "LICENSE.txt"):
            output.info("Skip %s" % filename)
        else:
            relpath = os.path.relpath(directory, folder)
            if config.target_folder:
                target_folder = os.path.join(cache.cache_folder,
                                             config.target_folder, relpath)
            else:
                target_folder = os.path.join(cache.cache_folder, relpath)

            if os.path.exists(target_folder):
                if os.path.isfile(
                        target_folder
                ):  # Existed as a file and now should be a folder
                    remove(target_folder)

            mkdir(target_folder)
            output.info("Copying file %s to %s" % (filename, target_folder))
            _filecopy(directory, filename, target_folder)
Exemplo n.º 8
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return

        # Migrate the settings if they were the default for that version
        cache = ClientCache(self.cache_folder, self.out)
        self._update_settings_yml(cache, old_version)

        if old_version < Version("1.0"):
            _migrate_lock_files(cache, self.out)

        if old_version < Version("1.12.0"):
            migrate_plugins_to_hooks(cache)

        if old_version < Version("1.13.0"):
            # MIGRATE LOCAL CACHE TO GENERATE MISSING METADATA.json
            _migrate_create_metadata(cache, self.out)

        if old_version < Version("1.14.0"):
            migrate_config_install(cache)

        if old_version < Version("1.14.2"):
            _migrate_full_metadata(cache, self.out)

        if old_version < Version("1.15.0"):
            migrate_registry_file(cache, self.out)

        if old_version < Version("1.19.0"):
            migrate_localdb_refresh_token(cache, self.out)

        if old_version < Version("1.26.0"):
            migrate_editables_use_conanfile_name(cache)

        if old_version < Version("1.31.0"):
            migrate_tgz_location(cache, self.out)

        if old_version < Version("1.40.3"):
            remove_buggy_cacert(cache, self.out)