mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Unfix installed package when the latest version is uninstalled
This commit is contained in:
@@ -118,10 +118,7 @@ def lib_update(lm, libraries, only_check, json_output):
|
||||
if not libraries:
|
||||
libraries = []
|
||||
for manifest in lm.get_installed():
|
||||
pkg_dir = manifest['__pkg_dir']
|
||||
if "@" in pkg_dir and "@vcs-" not in pkg_dir:
|
||||
continue
|
||||
elif "@vcs-" in pkg_dir:
|
||||
if "@vcs-" in manifest['__pkg_dir']:
|
||||
libraries.append("%s=%s" % (manifest['name'], manifest['url']))
|
||||
else:
|
||||
libraries.append(str(manifest.get("id", manifest['name'])))
|
||||
@@ -131,7 +128,7 @@ def lib_update(lm, libraries, only_check, json_output):
|
||||
for library in libraries:
|
||||
name, requirements, url = lm.parse_pkg_name(library)
|
||||
latest = lm.outdated(name, requirements, url)
|
||||
if latest is False:
|
||||
if not latest:
|
||||
continue
|
||||
manifest = lm.load_manifest(
|
||||
lm.get_package_dir(name, requirements, url))
|
||||
|
@@ -337,11 +337,7 @@ def platform_update(platforms, only_packages, only_check, json_output):
|
||||
if not platforms:
|
||||
platforms = []
|
||||
for manifest in pm.get_installed():
|
||||
pkg_dir = manifest['__pkg_dir']
|
||||
# don't check fixed platforms
|
||||
if "@" in pkg_dir and "@vcs-" not in pkg_dir:
|
||||
continue
|
||||
elif "@vcs-" in pkg_dir:
|
||||
if "@vcs-" in manifest['__pkg_dir']:
|
||||
platforms.append("%s=%s" % (manifest['name'], manifest['url']))
|
||||
else:
|
||||
platforms.append(manifest['name'])
|
||||
@@ -351,7 +347,7 @@ def platform_update(platforms, only_packages, only_check, json_output):
|
||||
for platform in platforms:
|
||||
name, requirements, url = pm.parse_pkg_name(platform)
|
||||
latest = pm.outdated(name, requirements, url)
|
||||
if latest is False:
|
||||
if not latest:
|
||||
continue
|
||||
data = _get_installed_platform_data(
|
||||
name, with_boards=False, expose_packages=False)
|
||||
|
@@ -501,7 +501,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
||||
"""
|
||||
latest = None
|
||||
package_dir = self.get_package_dir(name, requirements, url)
|
||||
if not package_dir:
|
||||
if not package_dir or ("@" in package_dir and
|
||||
"@vcs-" not in package_dir):
|
||||
return None
|
||||
is_vcs_pkg = False
|
||||
manifest_path = self.get_vcs_manifest_path(package_dir)
|
||||
@@ -598,10 +599,16 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
||||
os.unlink(package_dir)
|
||||
else:
|
||||
util.rmtree_(package_dir)
|
||||
self.reset_cache()
|
||||
|
||||
# unfix package with the same name
|
||||
package_dir = self.get_package_dir(manifest['name'])
|
||||
if package_dir and "@" in package_dir:
|
||||
os.rename(package_dir, join(self.package_dir, manifest['name']))
|
||||
self.reset_cache()
|
||||
|
||||
click.echo("[%s]" % click.style("OK", fg="green"))
|
||||
|
||||
self.reset_cache()
|
||||
if trigger_event:
|
||||
telemetry.on_event(
|
||||
category=self.__class__.__name__,
|
||||
@@ -644,7 +651,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
||||
elif latest is False:
|
||||
click.echo("[%s]" % (click.style("Up-to-date", fg="green")))
|
||||
else:
|
||||
click.echo("[%s]" % (click.style("Unknown", fg="yellow")))
|
||||
click.echo("[%s]" % (click.style("Skip", fg="yellow")))
|
||||
|
||||
if only_check or latest is False or (not is_vcs_pkg and not latest):
|
||||
return
|
||||
|
Reference in New Issue
Block a user