Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/175'
Browse files Browse the repository at this point in the history
* origin/pr/175:
  Support uncompressed archives fetched via git
  • Loading branch information
marmarek committed Jan 21, 2025
2 parents b90374e + 609c9e0 commit b2c6bbb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ We provide the following list of available keys:
- `signature` --- URL of the signature file of downloaded external file (in
combination with `url` and `pubkeys`).
- `uncompress` --- Uncompress external file downloaded before verification.
In case of tarball created from git, do not compress it.
- `pubkeys` --- List of public GPG keys to use for verifying the downloaded
signature file (in combination with `url` and `signature`).
- `git-url` --- URL of a repository to fetch and create a tarball from.
Expand Down
8 changes: 5 additions & 3 deletions qubesbuilder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ def get_archive_name(file: dict):
return Path(fn).with_suffix("").name
return fn
if "git-basename" in file:
return f"{file['git-basename']}.tar.gz"
suffix = "tar" if file.get("uncompress", False) else "tar.gz"
return f"{file['git-basename']}.{suffix}"
else:
archive_base = os.path.basename(file["git-url"]).partition(".git")[0]
suffix = "tar" if file.get("uncompress", False) else "tar.gz"
if "tag" in file:
assert "/" not in file["tag"]
return f"{archive_base}-{file['tag']}.tar.gz"
return f"{archive_base}-{file['tag']}.{suffix}"
if "commit-id" in file:
return f"{archive_base}-{file['commit-id']}.tar.gz"
return f"{archive_base}-{file['commit-id']}.{suffix}"
return None


Expand Down
9 changes: 9 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,12 @@ def test_get_archive_name_git_url():
}
fn = get_archive_name(file)
assert fn == "repo-2.0.0.tar.gz"

file = {
"git-url": "https://github.com/owner/repo",
"tag": "v2.0.0",
"git-basename": "repo-2.0.0",
"uncompress": True,
}
fn = get_archive_name(file)
assert fn == "repo-2.0.0.tar"

0 comments on commit b2c6bbb

Please sign in to comment.