From 2b804da9c202f66a7cc531860004cca88cf6bd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Audiger?= <31616285+jaudiger@users.noreply.github.com> Date: Thu, 30 Jan 2025 03:48:37 +0100 Subject: [PATCH] feat(libpsl): add initial package (#224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(libpsl): add initial package Signed-off-by: Jérémy Audiger * refactor(alsa_lib): rename variable for consistency in main function Signed-off-by: Jérémy Audiger --------- Signed-off-by: Jérémy Audiger --- packages/alsa_lib/project.bri | 4 +- packages/libpsl/brioche.lock | 9 ++++ packages/libpsl/project.bri | 77 +++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 packages/libpsl/brioche.lock create mode 100644 packages/libpsl/project.bri diff --git a/packages/alsa_lib/project.bri b/packages/alsa_lib/project.bri index bc4bd9b..cb3f0da 100644 --- a/packages/alsa_lib/project.bri +++ b/packages/alsa_lib/project.bri @@ -35,8 +35,8 @@ export async function test() { int main(void) { - const char *alsa_version = snd_asoundlib_version(); - printf("%s", alsa_version); + const char *version = snd_asoundlib_version(); + printf("%s", version); return 0; } diff --git a/packages/libpsl/brioche.lock b/packages/libpsl/brioche.lock new file mode 100644 index 0000000..ca0c42a --- /dev/null +++ b/packages/libpsl/brioche.lock @@ -0,0 +1,9 @@ +{ + "dependencies": {}, + "downloads": { + "https://github.com/rockdaboot/libpsl/releases/download/0.21.5/libpsl-0.21.5.tar.gz": { + "type": "sha256", + "value": "1dcc9ceae8b128f3c0b3f654decd0e1e891afc6ff81098f227ef260449dae208" + } + } +} diff --git a/packages/libpsl/project.bri b/packages/libpsl/project.bri new file mode 100644 index 0000000..63c2948 --- /dev/null +++ b/packages/libpsl/project.bri @@ -0,0 +1,77 @@ +import * as std from "std"; +import nushell from "nushell"; +import python from "python"; + +export const project = { + name: "libpsl", + version: "0.21.5", +}; + +const source = Brioche.download( + `https://github.com/rockdaboot/libpsl/releases/download/${project.version}/libpsl-${project.version}.tar.gz`, +) + .unarchive("tar", "gzip") + .peel(); + +export default function libPsl(): std.Recipe { + const libpsl = std.runBash` + ./configure --prefix=/ + make install DESTDIR="$BRIOCHE_OUTPUT" + ` + .workDir(source) + .dependencies(std.toolchain(), python()) + .toDirectory(); + + return std.setEnv(libpsl, { + CPATH: { append: [{ path: "include" }] }, + LIBRARY_PATH: { append: [{ path: "lib" }] }, + PKG_CONFIG_PATH: { append: [{ path: "lib/pkgconfig" }] }, + }); +} + +export async function test() { + const src = std.file(std.indoc` + #include + #include + + int main(void) + { + const char *version = psl_get_version(); + printf("%s", version); + + return 0; + } + `); + + const script = std.runBash` + cp "$src" main.c + gcc main.c -o main -lpsl + ./main | tee "$BRIOCHE_OUTPUT" + ` + .dependencies(std.toolchain(), libPsl()) + .env({ src: src }); + + const result = await script.toFile().read(); + + // Check that the result contains the expected version + const expected = `${project.version} (no IDNA support)`; + std.assert(result === expected, `expected '${expected}', got '${result}'`); + + return script; +} + +export function autoUpdate() { + const src = std.file(std.indoc` + let version = http get https://api.github.com/repos/rockdaboot/libpsl/releases/latest + | get tag_name + + $env.project | from json | update version $version | to json + `); + + return std.withRunnable(std.directory(), { + command: "nu", + args: [src], + env: { project: JSON.stringify(project) }, + dependencies: [nushell()], + }); +}