diff options
| author | ruki <[email protected]> | 2023-11-23 22:54:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-23 22:54:44 +0800 |
| commit | ac1fc1f6e3b62960d5cf7c01c6779cb3e1b2b838 (patch) | |
| tree | ca66275bb7cae50cbc884b038b39e7824a2380e3 /core | |
| parent | 401d67ca9824632d1531889a6261f458fa161c4c (diff) | |
improve xmakesrc pack
Diffstat (limited to 'core')
| -rw-r--r-- | core/xpack.lua | 61 |
1 files changed, 19 insertions, 42 deletions
diff --git a/core/xpack.lua b/core/xpack.lua index c81509da0..d3d434aa1 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -77,51 +77,28 @@ xpack_component("LongPath") end) xpack("xmakesrc") - set_formats("src_zip", "src_targz") + set_formats("zip", "targz") set_basename("xmake-v$(version)") on_load(function (package) - local format = package:format() - if format == "src_zip" then - package:set("extension", ".zip") - elseif format == "src_targz" then - package:set("extension", ".tar.gz") - end + local prefixdir = "xmake-" .. package:version() + local rootdir = path.directory(os.projectdir()) + local extraconf = {rootdir = rootdir, prefixdir = prefixdir} + package:add("installfiles", path.join(rootdir, "core/**|src/pdcurses/**|src/luajit/**|src/tbox/tbox/src/demo/**"), extraconf) + package:add("installfiles", path.join(rootdir, "xmake/**"), extraconf) + package:add("installfiles", path.join(rootdir, "*.md"), extraconf) + package:add("installfiles", path.join(rootdir, "configure"), extraconf) + package:add("installfiles", path.join(rootdir, "scripts/*.sh"), extraconf) + package:add("installfiles", path.join(rootdir, "scripts/man/**"), extraconf) + package:add("installfiles", path.join(rootdir, "scripts/debian/**"), extraconf) + package:add("installfiles", path.join(rootdir, "scripts/msys/**"), extraconf) end) - on_package(function (package) + before_package(function (package) import("devel.git") - import("utils.archive") - print("packing %s", package:outputfile()) - local tmpdir = os.tmpfile() .. ".dir" - local repodir = path.join(tmpdir, "repo") - local srcdir = path.join(package:rootdir(), "xmakesrc") - local topdir = path.join(srcdir, "xmake-" .. package:version()) - os.tryrm(repodir) - os.tryrm(topdir) - os.cp(path.directory(path.absolute(os.projectdir())), repodir) - git.clean({repodir = repodir, force = true, all = true}) - git.reset({repodir = repodir, hard = true}) - if os.isfile(path.join(repodir, ".gitmodules")) then - git.submodule.clean({repodir = repodir, force = true, all = true}) - git.submodule.reset({repodir = repodir, hard = true}) + local rootdir = path.directory(os.projectdir()) + git.clean({repodir = rootdir, force = true, all = true}) + git.reset({repodir = rootdir, hard = true}) + if os.isfile(path.join(rootdir, ".gitmodules")) then + git.submodule.clean({repodir = rootdir, force = true, all = true}) + git.submodule.reset({repodir = rootdir, hard = true}) end - os.mkdir(path.join(topdir, "scripts")) - os.vcp(path.join(repodir, "core"), topdir) - os.vcp(path.join(repodir, "xmake"), topdir) - os.vcp(path.join(repodir, "*.md"), topdir) - os.vcp(path.join(repodir, "configure"), topdir) - os.vcp(path.join(repodir, "scripts", "*.sh"), path.join(topdir, "scripts")) - os.vcp(path.join(repodir, "scripts", "man"), path.join(topdir, "scripts")) - os.vcp(path.join(repodir, "scripts", "debian"), path.join(topdir, "scripts")) - os.vcp(path.join(repodir, "scripts", "msys"), path.join(topdir, "scripts")) - os.rm(path.join(topdir, "core", "src", "tbox", "tbox", "src", "demo")) - os.rm(path.join(topdir, "core", "src", "luajit")) - os.rm(path.join(topdir, "core", "src", "pdcurses")) - - -- archive files - local oldir = os.cd(srcdir) - local archivefiles = os.files("**") - os.cd(oldir) - archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = srcdir, compress = "best"}) - os.tryrm(tmpdir) end) - |
