Skip to content

Commit 09d1755

Browse files
committed
feat(ncurses): drop configure-project-installer, inline autotools build
Switch fromsource:ncurses to its own inline autotools build: * paths derived from pkginfo.install_file() * configure + make + install in a single sh -c * fixed -j8 * sysroot include dir wrapped in _sys_usr_includedir() helper * shell cp -r replaces os.dirs / os.files glob (silent no-ops in 0.4.9) * declare upstream url + sha256 Build flag: --without-cxx-binding. ncurses 6.4's C++ binding doesn't compile against gcc 14+ libstdc++ (NCURSES_BOOL alias for `unsigned char` clashes with std::bool in <compare>/<exception_ptr>/<type_traits>). The C ncurses libs we actually ship (libform/libmenu/libncurses/libpanel/libtinfo) are not affected. Verified end-to-end in xlings 0.4.9 iso: ✓ configure -> make -j8 -> make install ✓ produced libform.so.6.4, libmenu.so.6.4, libncurses.so.6.4, libpanel.so.6.4, libtinfo.so.6.4 + soname symlinks ✓ headers (incl. ncursesw/ subdir) copied into subos sysroot Cluster B leaf 3/8.
1 parent 8e08328 commit 09d1755

1 file changed

Lines changed: 53 additions & 31 deletions

File tree

pkgs/n/ncurses.lua

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
function __ncurses_url(version)
2+
return format("https://invisible-mirror.net/archives/ncurses/ncurses-%s.tar.gz", version)
3+
end
4+
15
package = {
26
spec = "1",
37

@@ -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 = "6.4" },
34-
["6.4"] = {},
37+
["6.4"] = {
38+
url = __ncurses_url("6.4"),
39+
sha256 = nil,
40+
},
3541
},
3642
},
3743
}
@@ -50,15 +56,37 @@ local libs = {
5056
}
5157

5258
local xpkg_binding_tree = package.name .. "-binding-tree"
53-
local sys_usr_includedir = path.join(system.subos_sysrootdir(), "usr/include")
59+
60+
local function _sys_usr_includedir()
61+
return path.join(system.subos_sysrootdir(), "usr/include")
62+
end
5463

5564
function install()
56-
local xpkg = package.name .. "@" .. pkginfo.version()
57-
os.tryrm(pkginfo.install_dir())
58-
system.exec("configure-project-installer " .. pkginfo.install_dir()
59-
.. " --xpkg-scode " .. xpkg
60-
.. " --args " .. [[ "--with-shared --with-termlib" ]] -- for libinfo
61-
)
65+
-- Sandbox template (PR #49 bzip2): derive paths from pkginfo.install_file()
66+
-- since path.absolute is nil; chain configure + make + install in single
67+
-- sh -c (os.cd doesn't propagate to system.exec children).
68+
local runtime_dir = path.directory(pkginfo.install_file())
69+
local scode_dir = path.join(runtime_dir, "ncurses-" .. pkginfo.version())
70+
local build_dir = path.join(runtime_dir, "build-ncurses")
71+
local prefix = pkginfo.install_dir()
72+
73+
os.tryrm(build_dir)
74+
os.mkdir(build_dir)
75+
76+
log.info("Configuring + building + installing ncurses (autotools)...")
77+
-- --with-shared: build .so libraries (default would be static-only)
78+
-- --with-termlib: split out libtinfo.so so consumers can link just terminfo
79+
-- --without-cxx-binding: ncurses 6.4 C++ binding doesn't compile against
80+
-- gcc 14+ libstdc++ (NCURSES_BOOL alias for unsigned char vs std::bool
81+
-- in <compare>/<exception_ptr>/<type_traits>); we don't ship libncurses++
82+
-- anyway. Plain C ncurses is unaffected.
83+
system.exec(string.format(
84+
"sh -c 'cd %s && %s/configure --prefix=%s --with-shared --with-termlib "
85+
.. "--without-cxx-binding "
86+
.. "&& make -j8 && make install'",
87+
build_dir, scode_dir, prefix
88+
))
89+
6290
return os.isdir(pkginfo.install_dir())
6391
end
6492

@@ -69,6 +97,7 @@ function config()
6997
local bindir = path.join(pkginfo.install_dir(), "bin")
7098
local libdir = path.join(pkginfo.install_dir(), "lib")
7199
local includedir = path.join(pkginfo.install_dir(), "include")
100+
local sys_inc = _sys_usr_includedir()
72101

73102
log.info("Registering CLI programs...")
74103
for _, prog in ipairs(package.programs) do
@@ -93,17 +122,15 @@ function config()
93122
end
94123

95124
log.info("Installing headers to sysroot...")
125+
if not os.isdir(sys_inc) then os.mkdir(sys_inc) end
96126
if os.isdir(includedir) then
97-
local subdirs = os.dirs(path.join(includedir, "*"))
98-
for _, subdir in ipairs(subdirs) do
99-
local name = path.filename(subdir)
100-
os.tryrm(path.join(sys_usr_includedir, name))
101-
os.cp(subdir, path.join(sys_usr_includedir, name), { force = true })
102-
end
103-
104-
for _, file in ipairs(os.files(path.join(includedir, "*.h"))) do
105-
os.cp(file, sys_usr_includedir)
106-
end
127+
-- shell cp: os.dirs / os.files glob is unreliable in 0.4.9 sandbox.
128+
-- Copy every entry under include/ (subdir like ncursesw/ + flat .h)
129+
-- into sysroot/usr/include/.
130+
system.exec(string.format(
131+
"sh -c 'cp -rf %s/* %s/'",
132+
includedir, sys_inc
133+
))
107134
end
108135

109136
xvm.add(package.name, { binding = binding_tree_version_tag })
@@ -122,18 +149,13 @@ function uninstall()
122149
xvm.remove(lib, package.name .. "-" .. pkginfo.version())
123150
end
124151

125-
local includedir = path.join(pkginfo.install_dir(), "include")
126-
if os.isdir(includedir) then
127-
local subdirs = os.dirs(path.join(includedir, "*"))
128-
for _, subdir in ipairs(subdirs) do
129-
os.tryrm(path.join(sys_usr_includedir, path.filename(subdir)))
130-
end
131-
132-
for _, file in ipairs(os.files(path.join(includedir, "*.h"))) do
133-
os.tryrm(path.join(sys_usr_includedir, path.filename(file)))
134-
end
135-
end
152+
-- ncurses ships under include/ncursesw/ + flat .h files; sweep both.
153+
local sys_inc = _sys_usr_includedir()
154+
system.exec(string.format(
155+
"sh -c 'rm -rf %s/ncurses %s/ncursesw && rm -f %s/ncurses.h %s/curses.h %s/term.h %s/termcap.h %s/eti.h %s/form.h %s/menu.h %s/panel.h %s/unctrl.h 2>/dev/null || true'",
156+
sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc, sys_inc
157+
))
136158

137159
xvm.remove(xpkg_binding_tree)
138160
return true
139-
end
161+
end

0 commit comments

Comments
 (0)