Skip to content

Commit b09a1a6

Browse files
anlu85olofk
authored andcommitted
Adds support for URL-based library syncing
Extends library synchronization to support downloading and managing libraries from URLs, specifically ZIP archives. This introduces a new 'url' sync-type option, allowing users to specify a URL to a ZIP file as the library source. The system downloads the ZIP archive and extracts its contents into the library location.
1 parent b23b83d commit b09a1a6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

fusesoc/librarymanager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ def __init__(
2020
sync_version=None,
2121
auto_sync=True,
2222
):
23-
if sync_type and not sync_type in ["local", "git"]:
23+
if sync_type and not sync_type in ["local", "git", "url"]:
2424
raise ValueError(
2525
"Library {} ({}) Invalid sync-type '{}'".format(
2626
name, location, sync_type
2727
)
2828
)
2929

30-
if sync_type in ["git"]:
30+
if sync_type in ["git", "url"]:
3131
if not sync_uri:
3232
raise ValueError(
33-
"Library {} ({}) sync-uri must be set when using sync_type 'git'".format(
34-
name, location
35-
)
33+
f"Library name ({location}) {sync_uri} must be set when using sync_type '{sync_type}'"
3634
)
3735

3836
self.name = name

fusesoc/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def get_parser():
625625
parser_library_add.add_argument(
626626
"--sync-type",
627627
help="The provider type for the library. Defaults to 'git'.",
628-
choices=["git", "local"],
628+
choices=["git", "local", "url"],
629629
dest="sync-type",
630630
)
631631
parser_library_add.add_argument(

fusesoc/provider/url.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525

2626

2727
class Url(Provider):
28+
@staticmethod
29+
def init_library(library):
30+
try:
31+
logger.info(f"Downloading library from {library.sync_uri}...")
32+
Url._download(library.sync_uri, library.location, "zip")
33+
logger.info(f"Library stored at {library.location}")
34+
except Exception as e:
35+
raise RuntimeError(str(e))
36+
37+
@staticmethod
38+
def update_library(library):
39+
try:
40+
Url._download(library.sync_uri, library.location, "zip")
41+
except Exception as e:
42+
raise RuntimeError(str(e))
43+
2844
def _checkout(self, local_dir):
2945
url = self.config.get("url")
3046
logger.info("Downloading...")

0 commit comments

Comments
 (0)