feat: andax (#2874)

cherry picks @38414e6 @aa21bc8 @3566e7e
This commit is contained in:
sadlerm4
2025-01-05 05:23:07 +11:00
committed by GitHub
parent d8ff2aa555
commit 361b7ab97c
3 changed files with 50 additions and 0 deletions
+22
View File
@@ -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);
}
+26
View File
@@ -0,0 +1,26 @@
import "anda::cfg" as cfg;
fn install(labels) {
if labels.script_path == () {
print("fatal: labels.script_path is empty");
terminate();
}
let releasever = sh("rpm -E '%fedora'", #{"stdout": "piped"}).ctx.stdout;
releasever.trim();
let basearch = sh("rpm -E '%_arch'", #{"stdout": "piped"}).ctx.stdout;
basearch.trim();
let hcl = cfg::load_file(sub(`(.+/)[^.]+\.rhai`, "${1}anda.hcl", labels.script_path));
for repo in hcl.project.pkg.rpm.extra_repos {
repo = sub(`\$releasever`, releasever, repo);
repo = sub(`\$basearch`, basearch, repo);
let filename = sub(`\W`, "_", repo);
let file = open_file(`/etc/yum.repos.d/${filename}.repo`);
file.write(`
[filename]
name=${filename}
baseurl=${repo}
enabled=1
gpgcheck=0
`);
}
}
+2
View File
@@ -0,0 +1,2 @@
import "anda::cfg" as cfg;
print(cfg::load_file(labels.project).project.pkg.labels.to_json());