forked from platformio/platformio-core
Reinstall/redownload package with a new `-f, --force
` option // Resolve #778
This commit is contained in:
27
HISTORY.rst
27
HISTORY.rst
@ -9,19 +9,16 @@ PlatformIO 3.0
|
|||||||
|
|
||||||
* PIO Home
|
* PIO Home
|
||||||
* Integration with `Jenkins CI <http://docs.platformio.org/en/latest/ci/jenkins.html>`_
|
* 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
|
folder for project's header files
|
||||||
(`issue #1107 <https://github.com/platformio/platformio-core/issues/1107>`_)
|
(`issue #1107 <https://github.com/platformio/platformio-core/issues/1107>`_)
|
||||||
* Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion)
|
* 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>`__
|
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.
|
Drop support for ``*_stage`` dev/platform names (use VCS URL instead).
|
||||||
* New options for `platformio device list <http://docs.platformio.org/en/latest/userguide/cmd_device.html#platformio-device-list>`__
|
* Reinstall/redownload package with a new ``-f, --force`` option for `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__
|
||||||
command:
|
and `platformio platform install <http://docs.platformio.org/page/userguide/platforms/cmd_install.html>`__
|
||||||
|
commands
|
||||||
- ``--serial`` list available serial ports (default)
|
(`issue #778 <https://github.com/platformio/platformio-core/issues/778>`_)
|
||||||
- ``--logical`` list logical devices
|
|
||||||
- ``--mdns`` discover multicast DNS services
|
|
||||||
(`issue #463 <https://github.com/platformio/platformio-core/issues/463>`_)
|
|
||||||
|
|
||||||
* `Library Dependency Finder (LDF) <http://docs.platformio.org/page/librarymanager/ldf.html>`__:
|
* `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>`__
|
- 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>`__
|
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
|
* Fixed platforms, packages, and libraries updating behind proxy
|
||||||
(`issue #1061 <https://github.com/platformio/platformio-core/issues/1061>`_)
|
(`issue #1061 <https://github.com/platformio/platformio-core/issues/1061>`_)
|
||||||
* Fixed missing toolchain include paths for project generator
|
* Fixed missing toolchain include paths for project generator
|
||||||
|
2
docs
2
docs
Submodule docs updated: 0c984c49f2...441416c380
@ -93,11 +93,17 @@ def cli(ctx, **options):
|
|||||||
"--interactive",
|
"--interactive",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
help="Allow to make a choice for all prompts")
|
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
|
@click.pass_obj
|
||||||
def lib_install(lm, libraries, silent, interactive):
|
def lib_install(lm, libraries, silent, interactive, force):
|
||||||
# @TODO "save" option
|
# @TODO "save" option
|
||||||
for library in libraries:
|
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")
|
@cli.command("uninstall", short_help="Uninstall libraries")
|
||||||
|
@ -295,15 +295,21 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches
|
|||||||
@click.option("--with-package", multiple=True)
|
@click.option("--with-package", multiple=True)
|
||||||
@click.option("--without-package", multiple=True)
|
@click.option("--without-package", multiple=True)
|
||||||
@click.option("--skip-default-package", is_flag=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,
|
def platform_install(platforms, with_package, without_package,
|
||||||
skip_default_package):
|
skip_default_package, force):
|
||||||
pm = PlatformManager()
|
pm = PlatformManager()
|
||||||
for platform in platforms:
|
for platform in platforms:
|
||||||
if pm.install(
|
if pm.install(
|
||||||
name=platform,
|
name=platform,
|
||||||
with_packages=with_package,
|
with_packages=with_package,
|
||||||
without_packages=without_package,
|
without_packages=without_package,
|
||||||
skip_default_package=skip_default_package):
|
skip_default_package=skip_default_package,
|
||||||
|
force=force):
|
||||||
click.secho(
|
click.secho(
|
||||||
"The platform '%s' has been successfully installed!\n"
|
"The platform '%s' has been successfully installed!\n"
|
||||||
"The rest of packages will be installed automatically "
|
"The rest of packages will be installed automatically "
|
||||||
|
@ -240,7 +240,8 @@ class LibraryManager(BasePkgManager):
|
|||||||
requirements=None,
|
requirements=None,
|
||||||
silent=False,
|
silent=False,
|
||||||
trigger_event=True,
|
trigger_event=True,
|
||||||
interactive=False):
|
interactive=False,
|
||||||
|
force=False):
|
||||||
pkg_dir = None
|
pkg_dir = None
|
||||||
try:
|
try:
|
||||||
_name, _requirements, _url = self.parse_pkg_uri(name, requirements)
|
_name, _requirements, _url = self.parse_pkg_uri(name, requirements)
|
||||||
@ -251,8 +252,13 @@ class LibraryManager(BasePkgManager):
|
|||||||
silent=silent,
|
silent=silent,
|
||||||
interactive=interactive)
|
interactive=interactive)
|
||||||
requirements = _requirements
|
requirements = _requirements
|
||||||
pkg_dir = BasePkgManager.install(self, name, requirements, silent,
|
pkg_dir = BasePkgManager.install(
|
||||||
trigger_event)
|
self,
|
||||||
|
name,
|
||||||
|
requirements,
|
||||||
|
silent=silent,
|
||||||
|
trigger_event=trigger_event,
|
||||||
|
force=force)
|
||||||
except exception.InternetIsOffline as e:
|
except exception.InternetIsOffline as e:
|
||||||
if not silent:
|
if not silent:
|
||||||
click.secho(str(e), fg="yellow")
|
click.secho(str(e), fg="yellow")
|
||||||
@ -271,7 +277,12 @@ class LibraryManager(BasePkgManager):
|
|||||||
for filters in self.normalize_dependencies(manifest['dependencies']):
|
for filters in self.normalize_dependencies(manifest['dependencies']):
|
||||||
assert "name" in filters
|
assert "name" in filters
|
||||||
if any([s in filters.get("version", "") for s in ("\\", "/")]):
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
lib_info = self.search_for_library(filters, silent,
|
lib_info = self.search_for_library(filters, silent,
|
||||||
@ -284,14 +295,18 @@ class LibraryManager(BasePkgManager):
|
|||||||
if filters.get("version"):
|
if filters.get("version"):
|
||||||
self.install(
|
self.install(
|
||||||
lib_info['id'],
|
lib_info['id'],
|
||||||
requirements=filters.get("version"),
|
filters.get("version"),
|
||||||
silent=silent,
|
silent=silent,
|
||||||
trigger_event=trigger_event)
|
trigger_event=trigger_event,
|
||||||
|
interactive=interactive,
|
||||||
|
force=force)
|
||||||
else:
|
else:
|
||||||
self.install(
|
self.install(
|
||||||
lib_info['id'],
|
lib_info['id'],
|
||||||
silent=silent,
|
silent=silent,
|
||||||
trigger_event=trigger_event)
|
trigger_event=trigger_event,
|
||||||
|
interactive=interactive,
|
||||||
|
force=force)
|
||||||
return pkg_dir
|
return pkg_dir
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -602,7 +602,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
|||||||
name,
|
name,
|
||||||
requirements=None,
|
requirements=None,
|
||||||
silent=False,
|
silent=False,
|
||||||
trigger_event=True):
|
trigger_event=True,
|
||||||
|
force=False):
|
||||||
name, requirements, url = self.parse_pkg_uri(name, requirements)
|
name, requirements, url = self.parse_pkg_uri(name, requirements)
|
||||||
package_dir = self.get_package_dir(name, requirements, url)
|
package_dir = self.get_package_dir(name, requirements, url)
|
||||||
|
|
||||||
@ -614,6 +615,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
|||||||
return package_dir
|
return package_dir
|
||||||
self.INSTALL_HISTORY.append(history_key)
|
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:
|
if not package_dir or not silent:
|
||||||
msg = "Installing " + click.style(name, fg="cyan")
|
msg = "Installing " + click.style(name, fg="cyan")
|
||||||
if requirements:
|
if requirements:
|
||||||
|
@ -63,9 +63,10 @@ class PlatformManager(BasePkgManager):
|
|||||||
skip_default_package=False,
|
skip_default_package=False,
|
||||||
trigger_event=True,
|
trigger_event=True,
|
||||||
silent=False,
|
silent=False,
|
||||||
|
force=False,
|
||||||
**_): # pylint: disable=too-many-arguments, arguments-differ
|
**_): # pylint: disable=too-many-arguments, arguments-differ
|
||||||
platform_dir = BasePkgManager.install(
|
platform_dir = BasePkgManager.install(
|
||||||
self, name, requirements, silent=silent)
|
self, name, requirements, silent=silent, force=force)
|
||||||
p = PlatformFactory.newPlatform(platform_dir)
|
p = PlatformFactory.newPlatform(platform_dir)
|
||||||
|
|
||||||
# @Hook: when 'update' operation (trigger_event is False),
|
# @Hook: when 'update' operation (trigger_event is False),
|
||||||
@ -76,7 +77,8 @@ class PlatformManager(BasePkgManager):
|
|||||||
with_packages,
|
with_packages,
|
||||||
without_packages,
|
without_packages,
|
||||||
skip_default_package,
|
skip_default_package,
|
||||||
silent=silent)
|
silent=silent,
|
||||||
|
force=force)
|
||||||
self.cleanup_packages(p.packages.keys())
|
self.cleanup_packages(p.packages.keys())
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -248,11 +250,13 @@ class PlatformFactory(object):
|
|||||||
|
|
||||||
class PlatformPackagesMixin(object):
|
class PlatformPackagesMixin(object):
|
||||||
|
|
||||||
def install_packages(self,
|
def install_packages( # pylint: disable=too-many-arguments
|
||||||
with_packages=None,
|
self,
|
||||||
without_packages=None,
|
with_packages=None,
|
||||||
skip_default_package=False,
|
without_packages=None,
|
||||||
silent=False):
|
skip_default_package=False,
|
||||||
|
silent=False,
|
||||||
|
force=False):
|
||||||
with_packages = set(self.find_pkg_names(with_packages or []))
|
with_packages = set(self.find_pkg_names(with_packages or []))
|
||||||
without_packages = set(self.find_pkg_names(without_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
|
elif (name in with_packages or
|
||||||
not (skip_default_package or opts.get("optional", False))):
|
not (skip_default_package or opts.get("optional", False))):
|
||||||
if ":" in version:
|
if ":" in version:
|
||||||
self.pm.install("%s=%s" % (name, version), silent=silent)
|
self.pm.install(
|
||||||
|
"%s=%s" % (name, version), silent=silent, force=force)
|
||||||
else:
|
else:
|
||||||
self.pm.install(name, version, silent=silent)
|
self.pm.install(name, version, silent=silent, force=force)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user