diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 1aae6c0b..5825fd81 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -42,7 +42,7 @@ jobs: if: startsWith(matrix.os, 'macos') env: PIO_INSTALL_DEVPLATFORMS_OWNERNAMES: "platformio" - PIO_INSTALL_DEVPLATFORMS_IGNORE: "ststm8,infineonxmc,microchippic32,lattice_ice40" + PIO_INSTALL_DEVPLATFORMS_IGNORE: "ststm8,infineonxmc,microchippic32,lattice_ice40,gd32v" run: | df -h tox -e testexamples diff --git a/HISTORY.rst b/HISTORY.rst index e1073378..f0e541db 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,7 @@ PlatformIO Core 5 - Show a warning message about deprecated support for Python 2 and Python 3.5 - Do not provide "intelliSenseMode" option when generating configuration for VSCode C/C++ extension - Fixed a "git-sh-setup: file not found" error when installing project dependencies from Git VCS (`issue #3740 `_) +- Fixed an issue with package publishing on Windows when Unix permissions are not preserved (`issue #3776 `_) 5.0.3 (2020-11-12) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/commands/package.py b/platformio/commands/package.py index bda36570..0013d158 100644 --- a/platformio/commands/package.py +++ b/platformio/commands/package.py @@ -23,6 +23,7 @@ from platformio.clients.registry import RegistryClient from platformio.compat import ensure_python3 from platformio.package.meta import PackageSpec, PackageType from platformio.package.pack import PackagePacker +from platformio.package.unpack import FileUnpacker, TARArchiver def validate_datetime(ctx, param, value): # pylint: disable=unused-argument @@ -81,6 +82,17 @@ def package_pack(package, output): ) def package_publish(package, owner, released_at, private, notify): assert ensure_python3() + + # publish .tar.gz instantly without repacking + if not os.path.isdir(package) and isinstance( + FileUnpacker.new_archiver(package), TARArchiver + ): + response = RegistryClient().publish_package( + package, owner, released_at, private, notify + ) + click.secho(response.get("message"), fg="green") + return + with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member with fs.cd(tmp_dir): p = PackagePacker(package) diff --git a/platformio/package/unpack.py b/platformio/package/unpack.py index 9956b46a..2913660d 100644 --- a/platformio/package/unpack.py +++ b/platformio/package/unpack.py @@ -134,27 +134,28 @@ class FileUnpacker(object): self.path = path self._archiver = None - def _init_archiver(self): + def __enter__(self): + self._archiver = self.new_archiver(self.path) + return self + + def __exit__(self, *args): + if self._archiver: + self._archiver.close() + + @staticmethod + def new_archiver(path): magic_map = { b"\x1f\x8b\x08": TARArchiver, b"\x42\x5a\x68": TARArchiver, b"\x50\x4b\x03\x04": ZIPArchiver, } magic_len = max(len(k) for k in magic_map) - with open(self.path, "rb") as fp: + with open(path, "rb") as fp: data = fp.read(magic_len) for magic, archiver in magic_map.items(): if data.startswith(magic): - return archiver(self.path) - raise PackageException("Unknown archive type '%s'" % self.path) - - def __enter__(self): - self._archiver = self._init_archiver() - return self - - def __exit__(self, *args): - if self._archiver: - self._archiver.close() + return archiver(path) + raise PackageException("Unknown archive type '%s'" % path) def unpack( self, dest_dir=None, with_progress=True, check_unpacked=True, silent=False