From 4dd4ad1452efc859af50906633b4538546b475ae Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Sat, 5 Dec 2026 13:46:13 +0900 Subject: [PATCH] xpkg 0.0.69: a recipe outside an index is read with the host's index libs The GitHub archive and its CN mirror on gitcode mcpp-res (the same bytes, sha256 checked by download). The consumer builds against 0.0.69 and reads a recipe outside an index with the libs of the index it names (LoaderContext::pkgindex_dir). Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com> --- pkgs/x/xpkg.lua | 7 +++++++ tests/examples/xpkg/mcpp.toml | 2 +- tests/examples/xpkg/tests/consume.cpp | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pkgs/x/xpkg.lua b/pkgs/x/xpkg.lua index 0d16c2ca..945ffcbf 100644 --- a/pkgs/x/xpkg.lua +++ b/pkgs/x/xpkg.lua @@ -18,6 +18,13 @@ package = { xpm = { linux = { + ["0.0.69"] = { + url = { + GLOBAL = "https://github.com/openxlings/libxpkg/archive/refs/tags/0.0.69.tar.gz", + CN = "https://gitcode.com/mcpp-res/xpkg/releases/download/0.0.69/xpkg-0.0.69.tar.gz", + }, + sha256 = "40c07239d494e463ed8babdc6a94434715e83831ea66845437d848a8e26cc0ee", + }, ["0.0.68"] = { url = { GLOBAL = "https://github.com/openxlings/libxpkg/archive/refs/tags/0.0.68.tar.gz", diff --git a/tests/examples/xpkg/mcpp.toml b/tests/examples/xpkg/mcpp.toml index d0667880..37d24924 100644 --- a/tests/examples/xpkg/mcpp.toml +++ b/tests/examples/xpkg/mcpp.toml @@ -8,4 +8,4 @@ name = "xpkg-tests" version = "0.1.0" [dependencies] -mcpplibs.xpkg = "0.0.68" +mcpplibs.xpkg = "0.0.69" diff --git a/tests/examples/xpkg/tests/consume.cpp b/tests/examples/xpkg/tests/consume.cpp index 8fe24a82..245e56d0 100644 --- a/tests/examples/xpkg/tests/consume.cpp +++ b/tests/examples/xpkg/tests/consume.cpp @@ -1,6 +1,7 @@ // Consuming `mcpplibs.xpkg` through the published index: a recipe is read -// and what it declares comes back, a recipe that is not there is refused, and -// the format's specification the library embeds is there to read. +// and what it declares comes back, a recipe that is not there is refused, a +// recipe outside an index reads the libs of the index the host names, and the +// format's specification the library embeds is there to read. import std; import mcpplibs.xpkg; import mcpplibs.xpkg.loader; @@ -36,6 +37,18 @@ int main() { check(!xpkg::load_package(dir / "absent.lua").has_value(), "a recipe that is not there is refused"); check(xpkg::conformance::specification().contains("xpkg"), "the specification is embedded"); + // 0.0.69: a recipe in no index reads the libs of the index the host names. + fs::create_directories(dir / "host" / "libs"); + std::ofstream(dir / "host" / "libs" / "probelib.lua") << "return { word = function() return 'host' end }\n"; + const auto loose = dir / "loose.lua"; + std::ofstream(loose) << R"(package = { spec = "3", name = "loose", xpm = { linux = { ["1.0.0"] = {} } } } +import("xim.pkgindex.probelib") +local word = probelib.word() +)"; + check(xpkg::load_package(loose, {.platform = "linux", .arch = "x86_64", + .pkgindex_dir = (dir / "host").string()}).has_value(), + "a recipe outside an index reads the host's index libs"); + fs::remove_all(dir); if (failures == 0) std::println("xpkg: ok"); return failures == 0 ? 0 : 1;