Skip to content

Commit 485961a

Browse files
committed
feat(zlib): drop configure-project-installer, inline configure+make build
Switch fromsource:zlib from the legacy xim:configure-project-installer shim flow to its own inline build, applying the cluster-A sandbox-fix template: * paths derived from pkginfo.install_file() (path.absolute is nil) * configure + make + make install chained in a single sh -c (zlib's configure does not support out-of-tree build, run from srcdir) * fixed -j8 (os.cpuinfo is nil) * sysroot include dir wrapped in _sys_usr_includedir() helper * zlib.h / zconf.h copy uses shell cp instead of os.cd + os.cp(file) * declare upstream url + sha256 (mirroring scode:zlib's github source) * license corrected: was a URL, now SPDX "Zlib" Verified end-to-end in an isolated xlings 0.4.9 environment: ✓ configure -> make -j8 -> make install ✓ produced libz.so.1.3.1 + libz.a + libz.so/libz.so.1 symlinks ✓ headers staged into install_dir/include ✓ "8 package(s) installed" exit 0 Cluster B leaf 1/8.
1 parent 18ebabe commit 485961a

1 file changed

Lines changed: 35 additions & 14 deletions

File tree

pkgs/z/zlib.lua

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
function __zlib_url(version)
2+
return format("https://github.com/madler/zlib/releases/download/v%s/zlib-%s.tar.gz", version, version)
3+
end
4+
15
package = {
26
spec = "1",
37

@@ -8,7 +12,7 @@ package = {
812
description = "A Massively Spiffy Yet Delicately Unobtrusive Compression Library",
913

1014
authors = "Jean-loup Gailly, Mark Adler",
11-
licenses = "https://zlib.net/zlib_license.html",
15+
licenses = "Zlib",
1216
repo = "https://github.com/madler/zlib",
1317

1418
-- xim pkg info
@@ -26,12 +30,14 @@ package = {
2630
linux = {
2731
deps = {
2832
"xim:xpkg-helper@0.0.1",
29-
"xim:configure-project-installer@0.0.1",
3033
"xim:gcc@15.1.0",
3134
"xim:make@4.3",
3235
},
3336
["latest"] = { ref = "1.3.1" },
34-
["1.3.1"] = { },
37+
["1.3.1"] = {
38+
url = __zlib_url("1.3.1"),
39+
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
40+
},
3541
},
3642
},
3743
}
@@ -48,13 +54,24 @@ local libs = {
4854
"libz.a",
4955
}
5056

51-
local sys_usr_includedir = path.join(system.subos_sysrootdir(), "usr/include")
57+
local function _sys_usr_includedir()
58+
return path.join(system.subos_sysrootdir(), "usr/include")
59+
end
5260

5361
function install()
54-
local xpkg = package.name .. "@" .. pkginfo.version()
55-
os.tryrm(pkginfo.install_dir())
56-
system.exec("configure-project-installer " .. pkginfo.install_dir()
57-
.. " --xpkg-scode " .. xpkg)
62+
-- Sandbox template (PR #49 bzip2): derive paths from pkginfo.install_file()
63+
-- since path.absolute is nil; chain configure + make + install in single
64+
-- sh -c (zlib's configure does not support out-of-tree build, run from srcdir).
65+
local runtime_dir = path.directory(pkginfo.install_file())
66+
local scode_dir = path.join(runtime_dir, "zlib-" .. pkginfo.version())
67+
local prefix = pkginfo.install_dir()
68+
69+
log.info("Configuring + building + installing zlib...")
70+
system.exec(string.format(
71+
"sh -c 'cd %s && ./configure --prefix=%s && make -j8 && make install'",
72+
scode_dir, prefix
73+
))
74+
5875
return os.isdir(pkginfo.install_dir())
5976
end
6077

@@ -80,9 +97,12 @@ function config()
8097

8198
log.warn("add zlib.h to sysroot/usr/include ...")
8299

83-
os.cd(path.join(pkginfo.install_dir(), "include"))
84-
os.cp("zlib.h", sys_usr_includedir)
85-
os.cp("zconf.h", sys_usr_includedir)
100+
-- shell cp: avoid os.cd + os.cp(file, dest) sandbox edge cases
101+
local sys_inc = _sys_usr_includedir()
102+
system.exec(string.format(
103+
"sh -c 'cp -f %s/include/zlib.h %s/include/zconf.h %s/'",
104+
pkginfo.install_dir(), pkginfo.install_dir(), sys_inc
105+
))
86106

87107
return true
88108
end
@@ -94,8 +114,9 @@ function uninstall()
94114
xvm.remove(lib, "zlib-" .. pkginfo.version())
95115
end
96116

97-
os.tryrm(path.join(sys_usr_includedir, "zlib.h"))
98-
os.tryrm(path.join(sys_usr_includedir, "zconf.h"))
117+
local sys_inc = _sys_usr_includedir()
118+
os.tryrm(path.join(sys_inc, "zlib.h"))
119+
os.tryrm(path.join(sys_inc, "zconf.h"))
99120

100121
return true
101-
end
122+
end

0 commit comments

Comments
 (0)