Browse Source

libsolv: add package. (#7853)

* libsolv: add package. (with deps)

* update.

* update.

* update.
RedbeanW 1 month ago
parent
commit
65d896ce39

+ 25 - 0
packages/l/libsolv/patches/fix-compile-on-mingw-w64.patch

@@ -0,0 +1,25 @@
+From 7c9611d9940b7dd55a06f458284ef231cb8ef65e Mon Sep 17 00:00:00 2001
+From: Redbeanw44602 <[email protected]>
+Date: Thu, 24 Jul 2025 13:43:26 +0800
+Subject: [PATCH] fix compile on mingw-w64.
+
+---
+ ext/solv_xfopen.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ext/solv_xfopen.h b/ext/solv_xfopen.h
+index 24b68252..92255361 100644
+--- a/ext/solv_xfopen.h
++++ b/ext/solv_xfopen.h
+@@ -10,7 +10,7 @@
+ 
+ #include <stddef.h>
+ 
+-#ifdef _WIN32
++#ifdef _MSC_VER
+   #include <BaseTsd.h>
+   typedef SSIZE_T ssize_t;
+ #else
+-- 
+2.50.1
+

+ 25 - 0
packages/l/libsolv/patches/fix-msvc-c2036.patch

@@ -0,0 +1,25 @@
+From c56131ef7d3e707fc3b2acc404bb986b5498091a Mon Sep 17 00:00:00 2001
+From: Redbeanw44602 <[email protected]>
+Date: Thu, 24 Jul 2025 13:42:07 +0800
+Subject: [PATCH] fix msvc c2036.
+
+---
+ src/repo_write.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/repo_write.c b/src/repo_write.c
+index c965a76e..5de1bd6f 100644
+--- a/src/repo_write.c
++++ b/src/repo_write.c
+@@ -188,7 +188,7 @@ write_compressed_blob(Repodata *data, void *blob, int len)
+ 	  write_u8(data, clen);
+ 	  write_blob(data, cpage, clen);
+ 	}
+-      blob += chunk;
++      blob = (char*)blob + chunk;
+       len -= chunk;
+     }
+ }
+-- 
+2.50.1
+

+ 186 - 0
packages/l/libsolv/xmake.lua

@@ -0,0 +1,186 @@
+package("libsolv")
+    set_homepage("https://github.com/openSUSE/libsolv")
+    set_description("Library for solving packages and reading repositories.")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/openSUSE/libsolv/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/openSUSE/libsolv.git")
+
+    add_versions("0.7.34", "fd9c8a75d3ca09d9ff7b0d160902fac789b3ce6f9fb5b46a7647895f9d3eaf05")
+
+    add_patches("<=0.7.34", "patches/fix-msvc-c2036.patch", "a924517033d4f8ba18e922e892953834d3ca1a4fa5a69ae04fd308df40d1b2e8")
+    add_patches("<=0.7.34", "patches/fix-compile-on-mingw-w64.patch", "e6ba565110c918363a4499a4fc949f29777e0a189f192c231c81a47da821d21d")
+
+    -- when using mingw, cmake cannot force export of all symbols.
+    if is_plat("mingw", "msys", "cygwin") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
+    add_configs("tools", {description = "Build tools.", default = false, type = "boolean"}) 
+
+     -- needs rpm, rpmdb, rpmio, rpmmisc, db
+    add_configs("rpmdb",             {description = "Build with rpm database support.", default = false, type = "boolean"})
+    add_configs("rpmdb_librpm",      {description = "Use librpm to access the rpm database.", default = false, type = "boolean"})
+    add_configs("rpmdb_bdb",         {description = "Use BerkeleyDB to access the rpm database.", default = false, type = "boolean"})
+    add_configs("rpmdb_byrpmheader", {description = "Build with rpmdb Header support.", default = false, type = "boolean"})
+    add_configs("rpmpkg",            {description = "Build with rpm package support.", default = false, type = "boolean"})
+    add_configs("rpmpkg_librpm",     {description = "Use librpm to access rpm header information.", default = false, type = "boolean"})
+    add_configs("pubkey",            {description = "Build with pubkey support.", default = false, type = "boolean"})
+    add_configs("rpmmd",             {description = "Build with rpmmd repository support.", default = false, type = "boolean"})
+    add_configs("rpm5",              {description = "Enabling RPM 5 support.", default = false, type = "boolean"})
+
+    add_configs("suserepo",  {description = "Build with suse repository support.", default = false, type = "boolean"})
+    add_configs("comps",     {description = "Build with fedora comps support.", default = false, type = "boolean"})
+    add_configs("helixrepo", {description = "Build with helix repository support.", default = false, type = "boolean"})
+    add_configs("debian",    {description = "Build with debian package/repository support.", default = false, type = "boolean"})
+    add_configs("mdkrepo",   {description = "Build with mandriva/mageia repository support.", default = false, type = "boolean"})
+    add_configs("archrepo",  {description = "Build with archlinux repository support.", default = false, type = "boolean"})
+    add_configs("apk",       {description = "Build with apk package/repository support.", default = false, type = "boolean"})
+    add_configs("cudfrepo",  {description = "Build with cudf repository support.", default = false, type = "boolean"})
+
+    add_configs("haiku",     {description = "Build with Haiku package support.", default = false, type = "boolean"})
+    add_configs("conda",     {description = "Build with conda dependency support.", default = false, type = "boolean"})
+    add_configs("appdata",   {description = "Build with AppStream appdata support.", default = false, type = "boolean"})
+    add_configs("multi_semantics", {description = "Build with support for multiple distribution types.", default = false, type = "boolean"})
+
+    add_configs("lzma_compression",   {description = "Build with lzma/xz compression support.", default = false, type = "boolean"})
+    add_configs("bzip2_compression",  {description = "Build with bzip2 compression support.", default = false, type = "boolean"})
+    add_configs("zstd_compression",   {description = "Build with zstd compression support.", default = false, type = "boolean"})
+    add_configs("zchunk_compression", {description = "Build with zchunk compression support.", default = false, type = "boolean"})
+
+    add_configs("libxml2", {description = "Build with libxml2 instead of libexpat.", default = false, type = "boolean"})
+    if not is_plat("windows", "mingw", "msys", "cygwin") then
+        add_configs("cookieopen", {description = "Enable the use of stdio cookie opens.", default = true, type = "boolean"})
+    else
+        add_configs("cookieopen", {description = "Enable the use of stdio cookie opens.", default = false, type = "boolean", readonly = true})
+    end
+
+    add_configs("FEDORA",    {description = "Building for Fedora.", default = false, type = "boolean"})
+    add_configs("DEBIAN",    {description = "Building for Debian.", default = false, type = "boolean"})
+    add_configs("SUSE",      {description = "Building for SUSE.", default = false, type = "boolean"})
+    add_configs("ARCHLINUX", {description = "Building for Archlinux.", default = false, type = "boolean"})
+    add_configs("MANDRIVA",  {description = "Building for Mandriva.", default = false, type = "boolean"})
+    add_configs("MAGEIA",    {description = "Building for Mageia.", default = false, type = "boolean"})
+    add_configs("HAIKU",     {description = "Building for Haiku.", default = false, type = "boolean"}) -- needs haiku be, network, package.
+
+    add_deps("cmake")
+    if not is_subhost("windows") then
+        add_deps("pkg-config")
+    else
+        add_deps("pkgconf")
+    end
+    on_load(function (package)
+        local libxml2_or_expat_enabled = false
+
+        if package:config("ARCHLINUX") then
+            package:config_set("archrepo", true)
+        end
+        if package:config("MANDRIVA") then
+            package:config_set("mdkrepo", true)
+        end
+        if package:config("MAGEIA") then
+            package:config_set("mdkrepo", true)
+            package:config_set("lzma_compression", true)
+        end
+        if package:config("DEBIAN") then
+            package:config_set("debian", true)
+        end
+        if package:config("SUSE") then
+            package:config_set("suserepo", true)
+            package:config_set("helixrepo", true)
+        end
+
+        if package:config("rpm5") then
+            package:config_set("rpmmd", true)
+        end
+        if package:config("archrepo") or package:config("debian") then
+            package:config_set("lzma_compression", true)
+        end
+        if package:config("apk") then
+            package:config_set("zstd_compression", true)
+        end
+        if package:config("rpmmd") or package:config("suserepo") or package:config("appdata") or package:config("comps") or package:config("helixrepo") or mdkrepo_enabled then
+            libxml2_or_expat_enabled = true
+        end
+
+        package:add("deps", "zlib")
+        if package:config("lzma_compression") then
+            package:add("deps", "xz")
+        end
+        if package:config("bzip2_compression") then
+            package:add("deps", "bzip2")
+        end
+        if package:config("zstd_compression") then
+            package:add("deps", "zstd")
+        end
+        if package:config("zchunk_compression") then
+            package:add("deps", "zchunk")
+        end
+        if libxml2_or_expat_enabled then
+            if package:config("libxml2") then
+                package:add("deps", "libxml2")
+            else
+                package:add("deps", "expat")
+            end
+        end
+    end)
+
+    on_install(function (package)
+        local configs = {}
+        table.insert(configs, "-DENABLE_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
+        table.insert(configs, "-DDISABLE_SHARED=" .. (package:config("shared") and "OFF" or "ON"))
+
+        local options = {
+            "rpmdb", "rpmdb_librpm", "rpmdb_bdb", "rpmdb_byrpmheader", "rpmpkg", "rpmpkg_librpm", "pubkey", "rpmmd", "rpm5",
+            "suserepo", "comps", "helixrepo", "debian", "mdkrepo", "archrepo", "apk", "cudfrepo",
+            "haiku", "conda", "appdata", "multi_semantics",
+            "lzma_compression", "bzip2_compression", "zstd_compression", "zchunk_compression"
+        }
+        local no_prefix_options = {
+            "multi_semantics", "rpm5"
+        }
+        for _, option in ipairs(options) do
+            if package:config(option) then
+                if not table.contains(no_prefix_options, option) then
+                    table.insert(configs, ("-DENABLE_%s=ON"):format(option:upper()))
+                else
+                    table.insert(configs, ("-D%s=ON"):format(option:upper()))
+                end
+            end
+        end
+
+        table.insert(configs, "-DWITHOUT_COOKIEOPEN=" .. (package:config("cookieopen") and "OFF" or "ON"))
+        table.insert(configs, "-DWITH_LIBXML2=" .. (package:config("libxml2") and "ON" or "OFF"))
+        if package:config("zchunk_compression") then
+            table.insert(configs, "-DWITH_SYSTEM_ZCHUNK=ON")
+        end
+
+        if not package:config("tools") then
+            io.replace("CMakeLists.txt", "ADD_SUBDIRECTORY (tools)", "", {plain = true})
+        end
+        io.replace("CMakeLists.txt", "ADD_SUBDIRECTORY (examples)", "", {plain = true})
+        io.replace("CMakeLists.txt", "ADD_SUBDIRECTORY (doc)", "", {plain = true})
+        io.replace("ext/CMakeLists.txt", "repo_testcase.c", "", {plain = true})
+        io.replace("ext/CMakeLists.txt", "testcase.c", "", {plain = true})
+        io.replace("ext/CMakeLists.txt", "testcase.h", "", {plain = true})
+
+        if package:config("cookieopen") then
+            -- @see https://developer.android.com/ndk/guides/common-problems
+            -- funopen() is sometimes not available when API < 24.
+            if package:is_plat("android") and package:is_arch("armeabi-v7a") then
+                local ndk_sdkver = package:toolchain("ndk"):config("ndk_sdkver")
+                if ndk_sdkver and tonumber(ndk_sdkver) < 24 then
+                    io.replace("CMakeLists.txt", "ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)", "", {plain = true})
+                end
+            end
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_csnippets({test = [[
+            void test() {
+                Pool *pool = pool_create();
+            }
+        ]]}, {configs = {languages = "c99"}, includes = "solv/pool.h"}))
+    end)

+ 36 - 0
packages/l/libzchunk/patches/fix-cdecl.patch

@@ -0,0 +1,36 @@
+From dc93b626e8b58044262725684cc0b848ffa395bc Mon Sep 17 00:00:00 2001
+From: Redbeanw44602 <[email protected]>
+Date: Sat, 26 Jul 2025 04:47:13 +0800
+Subject: [PATCH] fix cdecl.
+
+---
+ include/zck.h.in | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/include/zck.h.in b/include/zck.h.in
+index 8696231..5ff7ab4 100644
+--- a/include/zck.h.in
++++ b/include/zck.h.in
+@@ -77,6 +77,10 @@ typedef size_t (*zck_wcb)(void *ptr, size_t l, size_t c, void *dl_v);
+     #define ZCK_PUBLIC_API __attribute__((visibility("default")))
+ #endif
+ 
++#ifdef __cplusplus
++extern "C" {
++#endif
++
+ /*******************************************************************
+  * Reading a zchunk file
+  *******************************************************************/
+@@ -410,4 +414,8 @@ size_t ZCK_PUBLIC_API zck_write_chunk_cb(void *ptr, size_t l, size_t c, void *dl
+ size_t ZCK_PUBLIC_API zck_write_zck_header_cb(void *ptr, size_t l, size_t c, void *dl_v);
+ size_t ZCK_PUBLIC_API zck_header_cb(char *b, size_t l, size_t c, void *dl_v);
+ 
++#ifdef __cplusplus
++}
++#endif
++
+ #endif
+-- 
+2.50.1
+

+ 57 - 0
packages/l/libzchunk/xmake.lua

@@ -0,0 +1,57 @@
+package("libzchunk")
+    set_homepage("https://github.com/zchunk/zchunk")
+    set_description("A file format designed for highly efficient deltas while maintaining good compression.")
+    set_license("BSD-2-Clause")
+
+    add_urls("https://github.com/zchunk/zchunk/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/zchunk/zchunk.git")
+
+    add_versions("1.5.1", "2c187055e2206e62cef4559845e7c2ec6ec5a07ce1e0a6044e4342e0c5d7771d")
+
+    add_patches("<=1.5.1", "patches/fix-cdecl.patch", "7ca1cbabe8516152e5d4e5cd5dc7c14b2fd0134f8ad7a8fa64159e07998ebeb4")
+
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
+    add_configs("zstd", {description = "Enable compression support.", default = false, type = "boolean"})
+    add_configs("openssl", {description = "Use openssl or bundled sha libraries.", default = false, type = "boolean"})
+
+    add_deps("meson", "ninja")
+    if not is_subhost("windows") then
+        add_deps("pkg-config")
+    else
+        add_deps("pkgconf")
+    end
+    on_load(function(package)
+        if not package:config("shared") then
+            package:add("defines", "ZCHUNK_STATIC_LIB")
+        end
+        if package:config("zstd") then
+            package:add("deps", "zstd")
+        end
+        if package:config("openssl") then
+            package:add("deps", "openssl3")
+        end
+    end)
+
+    -- @see https://github.com/zchunk/zchunk/issues/94
+    on_install("!mingw and !msys and !cygwin", function (package)
+        local configs = {
+            '-Ddocs=false',
+            '-Dtests=false',
+            '-Dwith-curl=disabled'
+        }
+        table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
+        table.insert(configs, "-Dwith-zstd=" .. (package:config("zstd") and "enabled" or "disabled"))
+        table.insert(configs, "-Dwith-openssl=" .. (package:config("openssl") and "enabled" or "disabled"))
+
+        io.replace("meson.build", "subdir('src')", "subdir('src/lib')", {plain = true})
+        io.replace("meson.build", "not argplib.found()", "false", {plain = true})
+
+        import("package.tools.meson").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("zck_create", {configs = {languages = "c99"}, includes = "zck.h"}))
+    end)

+ 0 - 1
scripts/test.lua

@@ -290,7 +290,6 @@ end
 -- @see https://github.com/xmake-io/xmake-repo/issues/6940
 function _lock_packages(packages)
     local locked_packages = {
-        "libsolv",
         "libnfc",
         "flashlight",
         "telegram-bot-api",