Reinstall/redownload package with a new `-f, --force` option // Resolve #778

This commit is contained in:
Ivan Kravets
2017-12-19 00:51:35 +02:00
parent 31814b5122
commit 5dd97a35cc
7 changed files with 75 additions and 33 deletions

View File

@ -9,19 +9,16 @@ PlatformIO 3.0
* PIO Home
* Integration with `Jenkins CI <http://docs.platformio.org/en/latest/ci/jenkins.html>`_
* Added `include <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#include-dir>`__
* New `include <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#include-dir>`__
folder for project's header files
(`issue #1107 <https://github.com/platformio/platformio-core/issues/1107>`_)
* Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion)
in `Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__
Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead.
* New options for `platformio device list <http://docs.platformio.org/en/latest/userguide/cmd_device.html#platformio-device-list>`__
command:
- ``--serial`` list available serial ports (default)
- ``--logical`` list logical devices
- ``--mdns`` discover multicast DNS services
(`issue #463 <https://github.com/platformio/platformio-core/issues/463>`_)
* Depend on development platform using VSC URL (Git, Mercurial and Subversion) instead of a name
in `Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__.
Drop support for ``*_stage`` dev/platform names (use VCS URL instead).
* Reinstall/redownload package with a new ``-f, --force`` option for `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__
and `platformio platform install <http://docs.platformio.org/page/userguide/platforms/cmd_install.html>`__
commands
(`issue #778 <https://github.com/platformio/platformio-core/issues/778>`_)
* `Library Dependency Finder (LDF) <http://docs.platformio.org/page/librarymanager/ldf.html>`__:
@ -35,6 +32,14 @@ PlatformIO 3.0
- Added option to configure library `Compatible Mode <http://docs.platformio.org/page/librarymanager/ldf.html#compatibility-mode>`__
using `library.json <http://docs.platformio.org/page/librarymanager/config.html>`__
* New options for `platformio device list <http://docs.platformio.org/en/latest/userguide/cmd_device.html#platformio-device-list>`__
command:
- ``--serial`` list available serial ports (default)
- ``--logical`` list logical devices
- ``--mdns`` discover multicast DNS services
(`issue #463 <https://github.com/platformio/platformio-core/issues/463>`_)
* Fixed platforms, packages, and libraries updating behind proxy
(`issue #1061 <https://github.com/platformio/platformio-core/issues/1061>`_)
* Fixed missing toolchain include paths for project generator

2
docs

Submodule docs updated: 0c984c49f2...441416c380

View File

@ -93,11 +93,17 @@ def cli(ctx, **options):
"--interactive",
is_flag=True,
help="Allow to make a choice for all prompts")
@click.option(
"-f",
"--force",
is_flag=True,
help="Reinstall/redownload library if exists")
@click.pass_obj
def lib_install(lm, libraries, silent, interactive):
def lib_install(lm, libraries, silent, interactive, force):
# @TODO "save" option
for library in libraries:
lm.install(library, silent=silent, interactive=interactive)
lm.install(
library, silent=silent, interactive=interactive, force=force)
@cli.command("uninstall", short_help="Uninstall libraries")

View File

@ -295,15 +295,21 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches
@click.option("--with-package", multiple=True)
@click.option("--without-package", multiple=True)
@click.option("--skip-default-package", is_flag=True)
@click.option(
"-f",
"--force",
is_flag=True,
help="Reinstall/redownload dev/platform and its packages if exist")
def platform_install(platforms, with_package, without_package,
skip_default_package):
skip_default_package, force):
pm = PlatformManager()
for platform in platforms:
if pm.install(
name=platform,
with_packages=with_package,
without_packages=without_package,
skip_default_package=skip_default_package):
skip_default_package=skip_default_package,
force=force):
click.secho(
"The platform '%s' has been successfully installed!\n"
"The rest of packages will be installed automatically "

View File

@ -240,7 +240,8 @@ class LibraryManager(BasePkgManager):
requirements=None,
silent=False,
trigger_event=True,
interactive=False):
interactive=False,
force=False):
pkg_dir = None
try:
_name, _requirements, _url = self.parse_pkg_uri(name, requirements)
@ -251,8 +252,13 @@ class LibraryManager(BasePkgManager):
silent=silent,
interactive=interactive)
requirements = _requirements
pkg_dir = BasePkgManager.install(self, name, requirements, silent,
trigger_event)
pkg_dir = BasePkgManager.install(
self,
name,
requirements,
silent=silent,
trigger_event=trigger_event,
force=force)
except exception.InternetIsOffline as e:
if not silent:
click.secho(str(e), fg="yellow")
@ -271,7 +277,12 @@ class LibraryManager(BasePkgManager):
for filters in self.normalize_dependencies(manifest['dependencies']):
assert "name" in filters
if any([s in filters.get("version", "") for s in ("\\", "/")]):
self.install("{name}={version}".format(**filters))
self.install(
"{name}={version}".format(**filters),
silent=silent,
trigger_event=trigger_event,
interactive=interactive,
force=force)
else:
try:
lib_info = self.search_for_library(filters, silent,
@ -284,14 +295,18 @@ class LibraryManager(BasePkgManager):
if filters.get("version"):
self.install(
lib_info['id'],
requirements=filters.get("version"),
filters.get("version"),
silent=silent,
trigger_event=trigger_event)
trigger_event=trigger_event,
interactive=interactive,
force=force)
else:
self.install(
lib_info['id'],
silent=silent,
trigger_event=trigger_event)
trigger_event=trigger_event,
interactive=interactive,
force=force)
return pkg_dir
@staticmethod

View File

@ -602,7 +602,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
name,
requirements=None,
silent=False,
trigger_event=True):
trigger_event=True,
force=False):
name, requirements, url = self.parse_pkg_uri(name, requirements)
package_dir = self.get_package_dir(name, requirements, url)
@ -614,6 +615,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
return package_dir
self.INSTALL_HISTORY.append(history_key)
if package_dir and force:
self.uninstall(package_dir)
package_dir = None
if not package_dir or not silent:
msg = "Installing " + click.style(name, fg="cyan")
if requirements:

View File

@ -63,9 +63,10 @@ class PlatformManager(BasePkgManager):
skip_default_package=False,
trigger_event=True,
silent=False,
force=False,
**_): # pylint: disable=too-many-arguments, arguments-differ
platform_dir = BasePkgManager.install(
self, name, requirements, silent=silent)
self, name, requirements, silent=silent, force=force)
p = PlatformFactory.newPlatform(platform_dir)
# @Hook: when 'update' operation (trigger_event is False),
@ -76,7 +77,8 @@ class PlatformManager(BasePkgManager):
with_packages,
without_packages,
skip_default_package,
silent=silent)
silent=silent,
force=force)
self.cleanup_packages(p.packages.keys())
return True
@ -248,11 +250,13 @@ class PlatformFactory(object):
class PlatformPackagesMixin(object):
def install_packages(self,
with_packages=None,
without_packages=None,
skip_default_package=False,
silent=False):
def install_packages( # pylint: disable=too-many-arguments
self,
with_packages=None,
without_packages=None,
skip_default_package=False,
silent=False,
force=False):
with_packages = set(self.find_pkg_names(with_packages or []))
without_packages = set(self.find_pkg_names(without_packages or []))
@ -268,9 +272,10 @@ class PlatformPackagesMixin(object):
elif (name in with_packages or
not (skip_default_package or opts.get("optional", False))):
if ":" in version:
self.pm.install("%s=%s" % (name, version), silent=silent)
self.pm.install(
"%s=%s" % (name, version), silent=silent, force=force)
else:
self.pm.install(name, version, silent=silent)
self.pm.install(name, version, silent=silent, force=force)
return True