From f718ee7c72c0e30278dc4f6eef0e9344956eee29 Mon Sep 17 00:00:00 2001 From: madonuko Date: Mon, 23 Dec 2024 17:20:35 +0800 Subject: [PATCH] refactor --- anda/fusion/ffmpeg/VERSION_tesseract.txt | 2 +- anda/fusion/ffmpeg/update.rhai | 24 ++++++------------------ andax/bump_extras.rhai | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 andax/bump_extras.rhai diff --git a/anda/fusion/ffmpeg/VERSION_tesseract.txt b/anda/fusion/ffmpeg/VERSION_tesseract.txt index d50359de1..c7ba1e87f 100644 --- a/anda/fusion/ffmpeg/VERSION_tesseract.txt +++ b/anda/fusion/ffmpeg/VERSION_tesseract.txt @@ -1 +1 @@ -5.5.0 +5.5.0 \ No newline at end of file diff --git a/anda/fusion/ffmpeg/update.rhai b/anda/fusion/ffmpeg/update.rhai index 3a30619fa..8acce106e 100644 --- a/anda/fusion/ffmpeg/update.rhai +++ b/anda/fusion/ffmpeg/update.rhai @@ -1,21 +1,9 @@ -rpm.version(find(`ffmpeg-([\d.]+?)\.tar\.xz`, get("https://ffmpeg.org/download.html"), 1)); +import "andax/bump_extras.rhai" as bump; + +//rpm.version(find(`ffmpeg-([\d.]+?)\.tar\.xz`, get("https://ffmpeg.org/download.html"), 1)); let ffmpeg_ver = get(`https://madoguchi.fyralabs.com/v4/terra${labels.branch}/packages/x265`).json().ver; -open_file("anda/fusion/ffmpeg/VERSION_x265.txt").write(ffmpeg_ver); +open_file("anda/fusion/ffmpeg/VERSION_x265.txt", "w").write(ffmpeg_ver); -let release = labels.branch; -if release.starts_with("el") { - release.crop(2); - if release == "10" { - release = "EPEL-10.0" - } else { - release = `EPEL-${release}`; - } -} else if release.starts_with("f") { - release = labels.nbranch; -} else { - print(`ffmpeg: unsupported branch: ${labels.branch}`); - terminate(); -} -let tesseract_ver = get(`https://bodhi.fedoraproject.org/updates/?search=tesseract&status=stable&releases=${release}&rows_per_page=1&page=1`).json().updates[0].title; -open_file("anda/fusion/ffmpeg/VERSION_tesseract.txt").write(tesseract_ver); +let tesseract_ver = bump::bodhi("tesseract", 42); +open_file("anda/fusion/ffmpeg/VERSION_tesseract.txt", "w").write(tesseract_ver); diff --git a/andax/bump_extras.rhai b/andax/bump_extras.rhai new file mode 100644 index 000000000..c7c21db7b --- /dev/null +++ b/andax/bump_extras.rhai @@ -0,0 +1,22 @@ +fn as_bodhi_ver(branch) { + if branch.starts_with("el") { + branch.crop(2); + if branch == "10" { + return "EPEL-10.0"; + } + return `EPEL-${release}`; + } else if branch == "frawhide" { + return "42"; + } else if branch.starts_with("f") { + branch.crop(1); + return branch; + } else { + print(`E: unsupported branch: ${labels.branch}`); + terminate(); + } +} + +fn bodhi(pkg, branch) { + let url = `https://bodhi.fedoraproject.org/updates/?search=${pkg}&status=stable&releases=${branch}&rows_per_page=1&page=1`; + return find(`^${pkg}-([\d.]+)-\d+\.[\w\d]+$`, get(url).json().updates[0].title, 1); +}