feat(andax): helpers for parsing spec files (#4994) (#5022)

* feat(andax): helpers for parsing spec files

* Update spec.rhai



---------


(cherry picked from commit 9768565ed6)

Signed-off-by: madomado <madonuko@outlook.com>
Co-authored-by: madomado <madonuko@outlook.com>
This commit is contained in:
Raboneko
2025-05-24 05:45:32 -07:00
committed by GitHub
parent c85af507bb
commit 958f399d45
+20
View File
@@ -0,0 +1,20 @@
fn get_version(rpm) {
return `(?m)^Version:\s*(.+)$`.find(rpm.f, 1);
}
fn get_release(rpm) {
let r = `(?m)^Release:\s*(.+)$`.find(rpm.f, 1);
r = sub(`(?m)(%\??dist|%\{\??dist\})\s*$`, "", r);
r.replace("%autorelease", "1");
return r;
}
/// Only supports one-liner `%global`s!
fn get_global(rpm, macro) {
return `(?m)^%global\s+${macro}\s+(.+)$`.find(rpm.f, 1);
}
/// Only supports one-liner `%define`s!
fn get_define(rpm, macro) {
return `(?m)^%define\s+${macro}\s+(.+)$`.find(rpm.f, 1);
}