diff --git a/apio/managers/installer.py b/apio/managers/installer.py index b112c57b..3de63148 100644 --- a/apio/managers/installer.py +++ b/apio/managers/installer.py @@ -163,6 +163,7 @@ def get_download_url(self, package: dict, platform: str) -> str: * Release - tag_name - compressed_name + - uncompressed_name - package_name - extension - url_version @@ -186,6 +187,18 @@ def get_download_url(self, package: dict, platform: str) -> str: # -- Replace the '%P' parameter with the platform self.compressed_name = compressed_name_version.replace("%P", platform) + # -- Get the uncompressed name. It is also a template with the + # -- same parameters: %V and %P + uncompressed_name = package["release"]["uncompressed_name"] + + # -- Replace the '%V' parameter + uncompress_name_version = uncompressed_name.replace("%V", self.version) + + # -- Replace the '%P' parameter + self.uncompressed_name = uncompress_name_version.replace( + "%P", platform + ) + # -- Build the package tarball filename # --- Ex. 'apio-examples-0.0.35.zip' tarball = f"{self.compressed_name}.{self.extension}" @@ -287,8 +300,17 @@ def _install_package(self, dlpath: Path): # -- Remove it! shutil.rmtree(package_dir) - # -- Uncompress it!! - self._unpack(dlpath, package_dir) + # -- If there is a folder name for uncompressing the tarball + # -- Ex. 'apio-examples-0.0.35' + if self.uncompressed_name: + + # -- Uncompress it!! + # -- Ex. folder: /home/obijuan/.apio/packages + self._unpack(dlpath, self.packages_dir) + + # -- Use the calculated destination file + else: + self._unpack(dlpath, package_dir) # -- Remove the downloaded compress file # -- Ex. remove '/home/obijuan/.apio/packages/ diff --git a/apio/managers/unpacker.py b/apio/managers/unpacker.py index bc26a015..7c38a38d 100644 --- a/apio/managers/unpacker.py +++ b/apio/managers/unpacker.py @@ -146,12 +146,13 @@ def start(self) -> bool: items = self._unpacker.get_items() # -- Progress bar... - with click.progressbar(items, - length=len(items), - label=click.style("Unpacking..", fg="yellow"), - fill_char=click.style("█", fg="blue"), - empty_char=click.style("░", fg="blue"), - ) as pbar: + with click.progressbar( + items, + length=len(items), + label=click.style("Unpacking..", fg="yellow"), + fill_char=click.style("█", fg="blue"), + empty_char=click.style("░", fg="blue"), + ) as pbar: # -- Go though all the files in the archive... for item in pbar: diff --git a/apio/resources/packages.json b/apio/resources/packages.json index 526c4d3f..3b8daacf 100644 --- a/apio/resources/packages.json +++ b/apio/resources/packages.json @@ -7,6 +7,7 @@ "release": { "tag_name": "%V", "compressed_name": "apio-examples-%V", + "uncompressed_name": "apio-examples-%V", "package_name": "examples", "extension": "zip", "url_version": "https://github.com/FPGAwars/apio-examples/raw/master/VERSION" @@ -22,6 +23,7 @@ "release": { "tag_name": "v%V", "compressed_name": "tools-oss-cad-suite-%P-%V", + "uncompressed_name": "", "package_name": "tools-oss-cad-suite", "extension": "tar.gz", "url_version": "https://github.com/FPGAwars/tools-oss-cad-suite/raw/main/VERSION_DEV" @@ -37,6 +39,7 @@ "release": { "tag_name": "v%V", "compressed_name": "tool-gtkwave-%P-%V", + "uncompressed_name": "", "package_name": "tool-gtkwave", "extension": "tar.gz", "url_version": "https://github.com/FPGAwars/tool-gtkwave/raw/master/VERSION", @@ -57,6 +60,7 @@ "release": { "tag_name": "v%V", "compressed_name": "tools-drivers-%P-%V", + "uncompressed_name": "", "package_name": "tools-drivers", "extension": "tar.gz", "url_version": "https://github.com/FPGAwars/tools-drivers/raw/master/VERSION", @@ -69,4 +73,3 @@ "description": "Drivers tools for Windows" } } -