Skip to content

core: add xscript module - #109

Merged
Sunrisepeak merged 3 commits into
mainfrom
xscript_base
Aug 14, 2025
Merged

Sunrisepeak merged 3 commits into
mainfrom
xscript_base

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member
  1. xscript module
  • entry point: xpkg_main
  • command: xlings script file.lua [option]
  • option args: --xscript-info
  1. fix find_tool issues - workaround/tmp?
  2. xpkg: fix version ref issues

1. xscript module
 - entry point: xpkg_main
 - command: xlings script file.lua [option]
 - option args: --xscript-info

2. fix find_tool issues - workaround/tmp?
3. xpkg: fix version ref issues

Signed-off-by: sunrisepeak <[email protected]>
@Sunrisepeak

Sunrisepeak commented Aug 14, 2025 •

Copy link
Copy Markdown
Member Author

xpkg/xscript 即是包也是脚本 - 复用机制

当xpkg包被用 type字段标识为"script"时, 使用xlings install他时就会创建一个 对应二进制程序 并支持xvm多版本管理和切换

  • 视角1 - 包管理器/xpkg: 安装/卸载以及版本切换 - 即可被xlings管理和分发 - 天然属性
  • 视角2 - 程序: 被安装后 会用包名生成一个二进制程序 当成正常程序使用

基本功能

  • 天然具备xpkg包属性, 可被xlings的包管理器 分发和管理
  • 跨平台 + 二进制使用习惯 + 多版本共存切换
  • lua基本语法
  • 可以使用libxpkg运行时库
  • 程序进入点: xpkg_main (规避main函数的加载时的导入问题

可能适用场景

  • 简单的跨平台工具
  • 对其他工具的脚本wrapper

测试命令

安装脚本

xim --add-xpkg musl-cross-make.lua
xlings install musl-cross-make

使用脚本

musl-cross-make

切换脚本版本

xlings use musl-cross-make

测试脚本xpkg文件 / xscript脚本复用

package = {
    -- base info
    name = "musl-cross-make",
    description = "Simple makefile-based build for musl cross compiler",

    authors = "Rich Felker, et al.",
    contributors = "https://github.com/richfelker/musl-cross-make/graphs/contributors",
    licenses = "MIT",
    repo = "https://github.com/richfelker/musl-cross-make",

    -- xim pkg info
    type = "script",
    status = "stable",
    categories = {"linux", "build-helper", "toolchain"},
    keywords = {"linux", "musl", "libc", "toolchain", "compiler", "makefile", "gcc"},

    -- xvm: xlings version management
    xvm_enable = true,

    xpm = {
        linux = {
            ["latest"] = { ref = "0.0.1" },
            ["0.0.1"] = { },
        },
    },
}

import("xim.libxpkg.xvm")

-- function main() inherits failed for package?
-- avoid to call main when import this package?
function xpkg_main(...)
    print("hello world - 0.0.4")
    --print(xvm.info("musl-cross-make", "0.0.1"))
end

@Sunrisepeak Sunrisepeak left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Sunrisepeak
Sunrisepeak merged commit b9b972f into main Aug 14, 2025
@Sunrisepeak
Sunrisepeak deleted the xscript_base branch August 14, 2025 09:19
Sunrisepeak added a commit that referenced this pull request May 2, 2026
CI 4th attempt with main HEAD (3f1462d) failed: post-#108 pkgindex
schema needs hooks that v0.4.13 doesn't yet wire up:
  - gcc-specs-config (added in #109) doesn't auto-activate; gcc's
    config hook fails 'no version set for gcc-specs-config'
  - node has runtime dep on xim:gcc but its rpath closure misses
    gcc's libstdc++ subdir → libstdc++.so.6 not found

These need fixes in either xlings (resolver/config hook ordering)
or xim-pkgindex (gcc-specs-config registration / lib paths) — both
out of scope for this CI bump.

Pin XIM_PKGINDEX_REF back to 83044b5 (verified known-good for v0.4.13
during PR #257 release CI). Future bump: in lockstep with the next
xlings release that supports post-#108 schema.
Sunrisepeak added a commit that referenced this pull request May 2, 2026
* ci: bump bootstrap xlings v0.4.8 → v0.4.13 + xim-pkgindex pin

Co-bump BOOTSTRAP_XLINGS_VERSION and XIM_PKGINDEX_REF across all four
workflows that clone the fixture (xlings-ci-linux, xlings-ci-macos,
xlings-ci-windows, release).

  BOOTSTRAP_XLINGS_VERSION: v0.4.8 → v0.4.13
  XIM_PKGINDEX_REF: 83044b5 (pre-#108) → 3f1462d (xim-pkgindex main
                                          tip as of v0.4.13)

Why co-bump: the bootstrap xlings's resolver / elfpatch / catalog
behavior must match the pkgindex schema (legacy deps array vs new
runtime/build split, namespace conventions, exports.runtime.loader,
etc.). Bumping one without the other risks an in-flight pkgindex
breaking a stable bootstrap or vice versa — exactly what happened
during the 0.4.13 hotfix sequence (xim-pkgindex#108 added bare-name
deps that 0.4.8's resolver couldn't disambiguate, cascading through
E2E-05 dual-mount).

v0.4.13 contains the elfpatch op-order fix (libxpkg PR #13 / v0.0.37)
and pairs with xim-pkgindex 3f1462d (PRs #110/#111 namespace fixes
applied). Both refs verified together via PR #257's CI.

The earlier fixture-pin comment is reframed: it's not a one-off
workaround but a permanent bump-in-lockstep policy.

* ci: revert XIM_PKGINDEX_REF to 83044b5 (last known-good vs v0.4.13)

CI 4th attempt with main HEAD (3f1462d) failed: post-#108 pkgindex
schema needs hooks that v0.4.13 doesn't yet wire up:
  - gcc-specs-config (added in #109) doesn't auto-activate; gcc's
    config hook fails 'no version set for gcc-specs-config'
  - node has runtime dep on xim:gcc but its rpath closure misses
    gcc's libstdc++ subdir → libstdc++.so.6 not found

These need fixes in either xlings (resolver/config hook ordering)
or xim-pkgindex (gcc-specs-config registration / lib paths) — both
out of scope for this CI bump.

Pin XIM_PKGINDEX_REF back to 83044b5 (verified known-good for v0.4.13
during PR #257 release CI). Future bump: in lockstep with the next
xlings release that supports post-#108 schema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant