mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 20:15:10 +00:00
fix(binaries): report a version for git ffmpeg builds
Dated builds (N-<rev>-g<hash>-YYYYMMDD, YYYY-MM-DD-git-<hash>, shallow-clone git-YYYY-MM-DD-<hash>) report YYYYMMDD; undated ones N-<rev>.
This commit is contained in:
@@ -13,8 +13,13 @@ from unshackle.core.binaries import binary_version, parse_version, probe_output
|
|||||||
("text", "expected"),
|
("text", "expected"),
|
||||||
[
|
[
|
||||||
("ffmpeg version n9.0.1-11-ge47273f4d9 Copyright (c) 2000-2026\nbuilt with gcc 15.2.0", "9.0.1"),
|
("ffmpeg version n9.0.1-11-ge47273f4d9 Copyright (c) 2000-2026\nbuilt with gcc 15.2.0", "9.0.1"),
|
||||||
("ffmpeg version 2024-03-07-git-97beb63a66-full_build\n built with gcc 12.2.0", None),
|
("ffmpeg version 2024-03-07-git-97beb63a66-full_build\n built with gcc 12.2.0", "20240307"),
|
||||||
("ffmpeg version N-113672-g1e2a6dbb46-20240307\n built with gcc 13.2.0", None),
|
("ffmpeg version N-113672-g1e2a6dbb46-20240307\n built with gcc 13.2.0", "20240307"),
|
||||||
|
("ffprobe version N-119416-g1dbc5675c1-20250503 Copyright (c) 2007-2025", "20250503"),
|
||||||
|
("ffmpeg version N-113672-g1e2a6dbb46 Copyright (c) 2000-2024", "N-113672"),
|
||||||
|
("ffmpeg version N-128263-g9f9b9548583-tessus Copyright (c) 2000-2026", "N-128263"),
|
||||||
|
("ffmpeg version N-71064-gd5e603ddc0-static Copyright (c) 2000-2024", "N-71064"),
|
||||||
|
("ffmpeg version git-2026-11-02-b034eb5 Copyright (c) 2000-2026", "20261102"),
|
||||||
("packager-linux-x64 version v2.6.1-634af65-release", "2.6.1"),
|
("packager-linux-x64 version v2.6.1-634af65-release", "2.6.1"),
|
||||||
("MP4 Decrypter - Version 1.4\n(Bento4 Version 1.6.0.0)", "1.4"),
|
("MP4 Decrypter - Version 1.4\n(Bento4 Version 1.6.0.0)", "1.4"),
|
||||||
("mkvmerge v88.0 ('All I Know') 64-bit", "88.0"),
|
("mkvmerge v88.0 ('All I Know') 64-bit", "88.0"),
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ def get_registered_dependencies() -> list[dict]:
|
|||||||
DOTTED_NUMBER = r"\d+\.\d+(?:\.\d+)*"
|
DOTTED_NUMBER = r"\d+\.\d+(?:\.\d+)*"
|
||||||
VERSION_RE = re.compile(DOTTED_NUMBER)
|
VERSION_RE = re.compile(DOTTED_NUMBER)
|
||||||
LABELLED_VERSION_RE = re.compile(rf"(?i)\bversion[:\s]+[a-z]?({DOTTED_NUMBER})")
|
LABELLED_VERSION_RE = re.compile(rf"(?i)\bversion[:\s]+[a-z]?({DOTTED_NUMBER})")
|
||||||
|
GIT_BUILD_RE = re.compile(r"\bversion\s+(?:N-\d+-g[0-9a-f]+-(\d{8})\b|(?:git-)?(\d{4}-\d{2}-\d{2})\b|(N-\d+)-g)")
|
||||||
VERSION_WORD_RE = re.compile(r"(?i)\bversion\b")
|
VERSION_WORD_RE = re.compile(r"(?i)\bversion\b")
|
||||||
BARE_VERSION_TOOLS = {"mp4decrypt"}
|
BARE_VERSION_TOOLS = {"mp4decrypt"}
|
||||||
PROBE_TIMEOUT = 5.0
|
PROBE_TIMEOUT = 5.0
|
||||||
@@ -118,10 +119,14 @@ def parse_version(text: str) -> Optional[str]:
|
|||||||
"""Return the version from the first line that says "version" or holds a dotted number.
|
"""Return the version from the first line that says "version" or holds a dotted number.
|
||||||
|
|
||||||
That line is the tool's own banner; later lines carry library and compiler versions.
|
That line is the tool's own banner; later lines carry library and compiler versions.
|
||||||
|
A git build of FFmpeg has no release number, so its build date (YYYYMMDD) stands in, or N-<revision> when undated.
|
||||||
"""
|
"""
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
if match := LABELLED_VERSION_RE.search(line):
|
if match := LABELLED_VERSION_RE.search(line):
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
if match := GIT_BUILD_RE.search(line):
|
||||||
|
date, dashed_date, revision = match.groups()
|
||||||
|
return revision or (date or dashed_date).replace("-", "")
|
||||||
if VERSION_WORD_RE.search(line):
|
if VERSION_WORD_RE.search(line):
|
||||||
return None
|
return None
|
||||||
if match := VERSION_RE.search(line):
|
if match := VERSION_RE.search(line):
|
||||||
|
|||||||
Reference in New Issue
Block a user