| 109 | |
| 110 | |
| 111 | def destination_to_source_name(dest_name: str, tag: str, build_datetime: str) -> str: |
| 112 | pattern = DESTINATION_TAG_RE_TEMPLATE.format(tag=re.escape(tag)) |
| 113 | if (match := re.match(pattern, dest_name)) is None: |
| 114 | raise MirrorError( |
| 115 | f"release filename does not contain expected tag {tag}: {dest_name}" |
| 116 | ) |
| 117 | |
| 118 | source_name = f"{match.group(1)}-{match.group(2)}" |
| 119 | |
| 120 | if source_name.endswith("-full.tar.zst"): |
| 121 | prefix = source_name.removesuffix("-full.tar.zst") |
| 122 | return f"{prefix}-{build_datetime}.tar.zst" |
| 123 | |
| 124 | if source_name.endswith(".tar.gz"): |
| 125 | prefix = source_name.removesuffix(".tar.gz") |
| 126 | return f"{prefix}-{build_datetime}.tar.gz" |
| 127 | |
| 128 | raise MirrorError(f"unsupported release filename: {dest_name}") |
| 129 | |
| 130 | |
| 131 | def build_upload_entries( |