From f2c2fa93c9fc5c50da24698d239c0ddd7c4df2c102972bc32de62668cb0aa685 Mon Sep 17 00:00:00 2001 From: sisungo Date: Fri, 11 Sep 2026 07:20:18 +0000 Subject: [PATCH] feat: add support for configure scripts Signed-off-by: sisungo --- lib/make.py | 8 ++++++++ lib/pkgcomposer.py | 9 +++++++++ packages/ca-certificates/configure/refresh | 6 ++++++ packages/ca-certificates/pkgbuild.py | 2 ++ x.py | 3 +++ 5 files changed, 28 insertions(+) create mode 100644 packages/ca-certificates/configure/refresh diff --git a/lib/make.py b/lib/make.py index a144d41..e794772 100644 --- a/lib/make.py +++ b/lib/make.py @@ -16,6 +16,7 @@ _key_links = "links" _key_dependencies = "dependencies" _key_recommendations = "recommendations" _key_provides = "provides" +_key_configure = "configure" _current_pkgname: str = _key_global _pkginfo: dict[str, dict[str, typing.Any]] = { @@ -25,6 +26,7 @@ _pkginfo: dict[str, dict[str, typing.Any]] = { _key_maintainers: [], _key_provides: [], _key_recommendations: [], + _key_configure: [], }, } _supported_arch: typing.Callable[[str], bool] = lambda x: True @@ -87,6 +89,12 @@ def provide(s: str): ] +def configure_script(s: str): + _pkginfo[_current_pkgname][_key_configure] += [ + os.path.realpath(s) + ] + + def _translate_dep_spec(s: str) -> str: return ( s.replace("(same)", "(same-version) @same-arch") diff --git a/lib/pkgcomposer.py b/lib/pkgcomposer.py index eccdf23..97fdb35 100644 --- a/lib/pkgcomposer.py +++ b/lib/pkgcomposer.py @@ -25,6 +25,15 @@ class PkgComposer: json.dump(link, f) f.write("\n") + def add_configure(self, path: str, name: str = None): + if name is None: + name = os.path.basename(path) + configuredir = self.workdir + "/configure/" + dstpath = configuredir + name + os.makedirs(configuredir, exist_ok=True) + shutil.copy2(path, dstpath) + os.chmod(dstpath, 0o755) + def compose(self): subprocess.run( [ diff --git a/packages/ca-certificates/configure/refresh b/packages/ca-certificates/configure/refresh new file mode 100644 index 0000000..4dc103c --- /dev/null +++ b/packages/ca-certificates/configure/refresh @@ -0,0 +1,6 @@ +#!/bin/sh + +[ "${ACTION}" = "remove" ] && exit 0 +command -v certutil >/dev/null 2>&1 || exit 0 + +certutil refresh diff --git a/packages/ca-certificates/pkgbuild.py b/packages/ca-certificates/pkgbuild.py index ca061a1..ef28f24 100644 --- a/packages/ca-certificates/pkgbuild.py +++ b/packages/ca-certificates/pkgbuild.py @@ -27,4 +27,6 @@ def pack(composer): package("ca-certificates") arch_any() +configure_script("configure/refresh") +recommend("certutil") on_pack(pack) diff --git a/x.py b/x.py index f92119e..19cbcc6 100644 --- a/x.py +++ b/x.py @@ -123,6 +123,9 @@ def cmd_build_package(package: str): } composer.write_manifest(manifest) composer.write_links(pkginfo[lib.make._key_links]) + for i in pkginfo[lib.make._key_configure]: + composer.add_configure(i) + composer.compose() # Build success