Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ We provide the following list of available keys:
- `modules` --- Declare submodules to be included inside source preparation
(source archives creation and placeholders substitution)
- `files` --- List of external files to be downloaded. It has to be provided
with the combination of a `url` and a verification method. A verification
method is either a checksum file or a signature file with public GPG keys.
with the combination of a `url`/`git-url` and a verification method. For
`url`, a verification method is either a checksum file or a signature file
with public GPG keys. For `git-url`, it's either GPG key to verity a tag, or
explicit commit id.
- `url` --- URL of the external file to download.
- `sha256` --- Path to `sha256` checksum file relative to source directory (in
combination with `url`).
Expand All @@ -409,6 +411,15 @@ We provide the following list of available keys:
- `uncompress` --- Uncompress external file downloaded before verification.
- `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.
- `tag` --- Specific tag to fetch from `git-url` and verify with a key
specified in `pubkeys`. Can use `@VERSION@` placeholder.
- `commit-id` --- Specific pre-verified commit to fetch from `git-url`. No
extra verification is performed.
- `git-basename` --- Specify basename for archive created out of git
repository. This is also used for the top level directory inside the archive.
If not set, final component of the `git-url` (minus `.git` if applicable),
plus a commit id or tag will be used.

Here is a non-exhaustive list of distribution-specific keys:
- `host-fc32` --- Fedora 32 for the `host` package set content only
Expand Down
19 changes: 19 additions & 0 deletions qubesbuilder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import re
import shutil
import tempfile
Expand Down Expand Up @@ -76,6 +77,24 @@ def is_filename_valid(
return True


def get_archive_name(file: dict):
if "url" in file:
fn = os.path.basename(file["url"])
if file.get("uncompress", False):
return Path(fn).with_suffix("").name
return fn
if "git-basename" in file:
return f"{file['git-basename']}.tar.gz"
else:
archive_base = os.path.basename(file["git-url"]).partition(".git")[0]
if "tag" in file:
assert "/" not in file["tag"]
return f"{archive_base}-{file['tag']}.tar.gz"
if "commit-id" in file:
return f"{archive_base}-{file['commit-id']}.tar.gz"
return None


# Originally from QubesOS/qubes-builder/rpc-services/qubesbuilder.BuildLog
def sanitize_line(untrusted_line):
line = bytearray(untrusted_line)
Expand Down
Loading