From 95195e3199a3e03e66e6be94bf14c83c694cc8ff Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 23 Nov 2023 22:38:03 +0800 Subject: add runself stub --- xmake/plugins/pack/runself/main.lua | 76 +++++++++++++++++++++++++++++++++++++ xmake/plugins/pack/xpack.lua | 6 ++- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 xmake/plugins/pack/runself/main.lua diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua new file mode 100644 index 000000000..aaf267454 --- /dev/null +++ b/xmake/plugins/pack/runself/main.lua @@ -0,0 +1,76 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.base.semver") +import("lib.detect.find_tool") +import("private.action.require.impl.packagenv") +import("private.action.require.impl.install_packages") +import(".batchcmds") + +-- get the makeself +function _get_makeself() + + -- enter the environments of makeself + local oldenvs = packagenv.enter("makeself") + + -- find makeself + local packages = {} + local makeself = find_tool("makeself") + if not makeself then + table.join2(packages, install_packages("makeself")) + end + + -- enter the environments of installed packages + for _, instance in ipairs(packages) do + instance:envs_enter() + end + + -- we need to force detect and flush detect cache after loading all environments + if not makeself then + makeself = find_tool("makeself", {force = true}) + end + assert(makeself, "makeself not found!") + return makeself, oldenvs +end + +-- pack runself package +function _pack_runself(makeself, package) +end + +function main(package) + + -- only for windows + if not is_subhost("windows") then + return + end + + cprint("packing %s", package:outputfile()) + + -- get makeself + local makeself, oldenvs = _get_makeself() + + -- pack runself package + _pack_runself(makeself.program, package) + + -- done + os.setenvs(oldenvs) +end diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index e5829fd45..6715fb178 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -325,7 +325,8 @@ end -- get the specfile path function xpack:specfile() local extensions = { - nsis = ".nsi" + nsis = ".nsi", + runself = ".sh" } local extension = extensions[self:format()] or ".spec" return self:get("specfile") or path.join(self:buildir(), self:basename() .. extension) @@ -338,7 +339,8 @@ function xpack:extension() local extensions = { nsis = ".exe", zip = ".zip", - targz = ".tar.gz" + targz = ".tar.gz", + runself = ".sh" } extension = extensions[self:format()] or "" end -- cgit v1.3.1 From 4725c68c0ea12f684646c6cba4844c189051ae4a Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 00:46:17 +0800 Subject: add makeself cmd --- core/xpack.lua | 2 +- tests/plugins/pack/xmake.lua | 2 +- xmake/plugins/pack/runself/main.lua | 46 +++++++++++++++++++++++++++++++++---- xmake/plugins/pack/xpack.lua | 3 +-- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/core/xpack.lua b/core/xpack.lua index bc2df257e..b8dcdc5c5 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -77,7 +77,7 @@ xpack_component("LongPath") end) xpack("xmakesrc") - set_formats("zip", "targz") + set_formats("zip", "targz", "runself") set_basename("xmake-v$(version)") before_package(function (package) import("devel.git") diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index a93fc18f6..5b34dec36 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -19,7 +19,7 @@ target("foo") add_packages("zlib") xpack("test") - set_formats("nsis", "zip", "targz") + set_formats("nsis", "zip", "targz", "runself") set_title("hello") set_description("A test installer.") set_homepage("https://xmake.io") diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index aaf267454..b45b20e33 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -34,7 +34,7 @@ function _get_makeself() -- find makeself local packages = {} - local makeself = find_tool("makeself") + local makeself = find_tool("makeself.sh") if not makeself then table.join2(packages, install_packages("makeself")) end @@ -46,20 +46,58 @@ function _get_makeself() -- we need to force detect and flush detect cache after loading all environments if not makeself then - makeself = find_tool("makeself", {force = true}) + makeself = find_tool("makeself.sh", {force = true}) end assert(makeself, "makeself not found!") return makeself, oldenvs end +-- get specvars +function _get_specvars(package) + local specvars = table.clone(package:specvars()) + return specvars +end + -- pack runself package function _pack_runself(makeself, package) + + -- install the initial specfile + local specfile = package:specfile() + if not os.isfile(specfile) then + local specfile_template = path.join(os.programdir(), "scripts", "xpack", "runself", "makeself.lsm") + os.cp(specfile_template, specfile) + end + + -- replace variables in specfile + local specvars = _get_specvars(package) + local pattern = package:extraconf("specfile", "pattern") or "%${([^\n]-)}" + io.gsub(specfile, "(" .. pattern .. ")", function(_, name) + name = name:trim() + local value = specvars[name] + if type(value) == "function" then + value = value() + end + if value ~= nil then + dprint(" > replace %s -> %s", name, value) + end + if type(value) == "table" then + dprint("invalid variable value", value) + end + return value + end) + + local archivedir = package:buildir() + local setupfile = path.join(package:buildir(), "setup.sh") + io.writefile(setupfile, [[#!/bin/bash + echo hello]]) + + -- make package + os.vrunv(makeself, {"--gzip", "--sha256", "--lsm", specfile, archivedir, package:outputfile(), "setup.sh", "hello"}) end function main(package) - -- only for windows - if not is_subhost("windows") then + if is_subhost("windows") then return end diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 6715fb178..2fe43137a 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -325,8 +325,7 @@ end -- get the specfile path function xpack:specfile() local extensions = { - nsis = ".nsi", - runself = ".sh" + nsis = ".nsi" } local extension = extensions[self:format()] or ".spec" return self:get("specfile") or path.join(self:buildir(), self:basename() .. extension) -- cgit v1.3.1 From e680f0fbac744bce8488af3479c14d835705176d Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 00:49:00 +0800 Subject: add makeself setup --- xmake/plugins/pack/runself/main.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index b45b20e33..f8a646427 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -86,13 +86,14 @@ function _pack_runself(makeself, package) return value end) - local archivedir = package:buildir() - local setupfile = path.join(package:buildir(), "setup.sh") - io.writefile(setupfile, [[#!/bin/bash - echo hello]]) + -- install the setup.sh script + local installdir = package:installdir() + local setupfile = path.join(installdir, "__setup__.sh") + os.cp(path.join(os.programdir(), "scripts", "xpack", "runself", "setup.sh"), setupfile) -- make package - os.vrunv(makeself, {"--gzip", "--sha256", "--lsm", specfile, archivedir, package:outputfile(), "setup.sh", "hello"}) + os.vrunv(makeself, {"--gzip", "--sha256", "--lsm", specfile, + installdir, package:outputfile(), package:basename(), "./__setup__.sh"}) end function main(package) -- cgit v1.3.1 From 9217b528138fe4384403c0b573e8617bdcc18358 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 00:52:07 +0800 Subject: add install cmds --- xmake/plugins/pack/runself/main.lua | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index f8a646427..91d1f9426 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -58,6 +58,50 @@ function _get_specvars(package) return specvars end +-- write install command +function _write_installcmd(package, scriptfile, cmd) + local opt = cmd.opt or {} + local kind = cmd.kind + if kind == "cp" then + local srcfiles = os.files(cmd.srcpath) + for _, srcfile in ipairs(srcfiles) do + -- the destination is directory? append the filename + local dstfile = cmd.dstpath + if #srcfiles > 1 or path.islastsep(dstfile) then + if opt.rootdir then + dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir)) + else + dstfile = path.join(dstfile, path.filename(srcfile)) + end + end + scriptfile:print("cp -p \"%s\" \"%s\"", srcfile, dstfile) + end + elseif kind == "rm" then + local filepath = cmd.filepath + scriptfile:print("rm -f \"%s\"", filepath) + elseif kind == "rmdir" then + local dir = cmd.dir + scriptfile:print("rm -rf \"%s\"", dir) + elseif kind == "mv" then + local srcpath = cmd.srcpath + local dstpath = cmd.dstpath + scriptfile:print("mv \"%s\" \"%s\"", srcfile, dstfile) + elseif kind == "cd" then + local dir = cmd.dir + scriptfile:print("cd \"%s\"", dir) + elseif kind == "mkdir" then + local dir = cmd.dir + scriptfile:print("mkdir -p \"%s\"", dir) + end +end + +-- write install commands +function _write_installcmds(package, scriptfile, cmds) + for _, cmd in ipairs(cmds) do + _write_installcmd(package, scriptfile, cmd) + end +end + -- pack runself package function _pack_runself(makeself, package) @@ -90,6 +134,16 @@ function _pack_runself(makeself, package) local installdir = package:installdir() local setupfile = path.join(installdir, "__setup__.sh") os.cp(path.join(os.programdir(), "scripts", "xpack", "runself", "setup.sh"), setupfile) + local scriptfile = io.open(setupfile, "a+") + if scriptfile then + _write_installcmds(package, scriptfile, batchcmds.get_installcmds(package):cmds()) + for _, component in table.orderpairs(package:components()) do + if component:get("default") ~= false then + _write_installcmds(package, scriptfile, batchcmds.get_installcmds(component):cmds()) + end + end + scriptfile:close() + end -- make package os.vrunv(makeself, {"--gzip", "--sha256", "--lsm", specfile, -- cgit v1.3.1 From afbbacc9085b29e39cc13e00d5673202a70f7645 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:34:15 +0800 Subject: add sourcefiles for xpack --- tests/plugins/pack/xmake.lua | 12 +++++- xmake/includes/xpack/xmake.lua | 12 +++++- xmake/plugins/pack/archive.lua | 28 ++++++++++--- xmake/plugins/pack/main.lua | 8 ++-- xmake/plugins/pack/nsis/main.lua | 2 +- xmake/plugins/pack/srctargz/main.lua | 26 ++++++++++++ xmake/plugins/pack/srczip/main.lua | 26 ++++++++++++ xmake/plugins/pack/xmake.lua | 2 +- xmake/plugins/pack/xpack.lua | 70 ++++++++++++++++++++++++++++---- xmake/plugins/pack/xpack_component.lua | 21 ++++++++-- xmake/scripts/xpack/runself/makeself.lsm | 11 +++++ xmake/scripts/xpack/runself/setup.sh | 1 + 12 files changed, 194 insertions(+), 25 deletions(-) create mode 100644 xmake/plugins/pack/srctargz/main.lua create mode 100644 xmake/plugins/pack/srczip/main.lua create mode 100644 xmake/scripts/xpack/runself/makeself.lsm create mode 100755 xmake/scripts/xpack/runself/setup.sh diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index 5b34dec36..e8d2cdd53 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -19,17 +19,25 @@ target("foo") add_packages("zlib") xpack("test") - set_formats("nsis", "zip", "targz", "runself") + set_formats("nsis", "zip", "targz", "srczip", "srctargz", "runself") set_title("hello") set_description("A test installer.") set_homepage("https://xmake.io") set_licensefile("LICENSE.md") add_targets("test", "foo") - set_basename("test-$(plat)-$(arch)-v$(version)") add_installfiles("src/(assets/*.png)", {prefixdir = "images"}) + add_sourcefiles("(src/**)") set_iconfile("src/assets/xmake.ico") add_components("LongPath") + on_load(function (package) + if package:from_source() then + package:set("basename", "test-$(plat)-src-v$(version)") + else + package:set("basename", "test-$(plat)-$(arch)-v$(version)") + end + end) + after_installcmd(function (package, batchcmds) batchcmds:mkdir(package:installdir("resources")) batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"}) diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index 345431ffc..8572b2a87 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -36,11 +36,13 @@ local apis = { "xpack.set_title", -- set package description "xpack.set_description", + -- set input kind, e.g. binary, source + "xpack.set_inputkind", -- set package copyright "xpack.set_copyright", -- set company name "xpack.set_company", - -- set package formats, e.g. nsis, deb, rpm, targz, zip, runself, ... + -- set package formats, e.g. nsis, deb, rpm, targz, zip, srctargz, srczip, runself, ... -- we can also add custom formats "xpack.set_formats", -- set the base name of the output file @@ -75,8 +77,14 @@ local apis = { "xpack.set_iconfile", -- set package license file, we will also get them from target "xpack.set_licensefile", + -- add source files + "xpack.add_sourcefiles", -- add install files, we will also get them from target - "xpack.add_installfiles" + "xpack.add_installfiles", + -- add source files for component + "xpack_component.add_sourcefiles", + -- add install files for component + "xpack_component.add_installfiles" }, script = { -- add custom load script diff --git a/xmake/plugins/pack/archive.lua b/xmake/plugins/pack/archive.lua index 818404345..dd1861ca4 100644 --- a/xmake/plugins/pack/archive.lua +++ b/xmake/plugins/pack/archive.lua @@ -26,16 +26,32 @@ import("batchcmds") -- pack archive package function _pack_archive(package) - -- do install - batchcmds.get_installcmds(package):runcmds() - for _, component in table.orderpairs(package:components()) do - if component:get("default") ~= false then - batchcmds.get_installcmds(component):runcmds() + -- archive source files + if package:from_source() then + local srcfiles, dstfiles = package:sourcefiles() + for idx, srcfile in ipairs(srcfiles) do + os.vcp(srcfile, dstfiles[idx]) + end + for _, component in table.orderpairs(package:components()) do + if component:get("default") ~= false then + local srcfiles, dstfiles = component:sourcefiles() + for idx, srcfile in ipairs(srcfiles) do + os.vcp(srcfile, dstfiles[idx]) + end + end + end + else + -- archive binary files + batchcmds.get_installcmds(package):runcmds() + for _, component in table.orderpairs(package:components()) do + if component:get("default") ~= false then + batchcmds.get_installcmds(component):runcmds() + end end end -- archive install files - local rootdir = package:rootdir() + local rootdir = package:from_source() and package:source_rootdir() or package:install_rootdir() local oldir = os.cd(rootdir) local archivefiles = os.files("**") os.cd(oldir) diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua index 3f145cf86..f89c84835 100644 --- a/xmake/plugins/pack/main.lua +++ b/xmake/plugins/pack/main.lua @@ -80,9 +80,11 @@ end function _build_targets() local targetnames = {} for _, package in ipairs(xpack.packages()) do - local targets = package:get("targets") - if targets then - table.join2(targetnames, targets) + if package:from_binary() then + local targets = package:get("targets") + if targets then + table.join2(targetnames, targets) + end end end if #targetnames > 0 then diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index d7d69fdef..b8f6d4dc4 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -88,7 +88,7 @@ end -- translate the file path function _translate_filepath(package, filepath) - return filepath:replace(package:rootdir(), "$InstDir", {plain = true}) + return filepath:replace(package:install_rootdir(), "$InstDir", {plain = true}) end -- get command string diff --git a/xmake/plugins/pack/srctargz/main.lua b/xmake/plugins/pack/srctargz/main.lua new file mode 100644 index 000000000..fe511bff9 --- /dev/null +++ b/xmake/plugins/pack/srctargz/main.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import(".archive") + +function main(package) + archive(package) +end diff --git a/xmake/plugins/pack/srczip/main.lua b/xmake/plugins/pack/srczip/main.lua new file mode 100644 index 000000000..fe511bff9 --- /dev/null +++ b/xmake/plugins/pack/srczip/main.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import(".archive") + +function main(package) + archive(package) +end diff --git a/xmake/plugins/pack/xmake.lua b/xmake/plugins/pack/xmake.lua index 3d7c02ddf..96b0d2070 100644 --- a/xmake/plugins/pack/xmake.lua +++ b/xmake/plugins/pack/xmake.lua @@ -32,7 +32,7 @@ task("pack") "e.g.", " - xmake pack -f nsis,deb,rpm", "values:", - values = {"nsis", "deb", "rpm", "runself", "targz", "zip"}}, + values = {"nsis", "deb", "rpm", "runself", "targz", "zip", "srctargz", "srczip"}}, {}, {nil, "packages", "vs", nil, "The package names."} } diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 2fe43137a..4873e3fa1 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -225,6 +225,35 @@ function xpack:format() return self._FORMAT end +-- get the input kind +function xpack:inputkind() + local inputkind = self:get("inputkind") + if inputkind == nil then + local inputkinds = { + nsis = "binary", + zip = "binary", + targz = "binary", + srczip = "source", + srctargz = "source", + runself = "source", + deb = "source", + rpm = "source" + } + inputkind = inputkinds[self:format()] or "binary" + end + return inputkind +end + +-- pack from source files? +function xpack:from_source() + return self:inputkind() == "source" +end + +-- pack from binary files? +function xpack:from_binary() + return self:inputkind() == "binary" +end + -- get the build directory function xpack:buildir() return path.join(config.buildir(), ".xpack", self:name()) @@ -244,6 +273,9 @@ function xpack:basename() local basename = option.get("basename") or self:get("basename") if basename == nil then basename = self:name() + if self:from_source() then + basename = basename .. "-src" + end local version = self:version() if version then basename = basename .. "-" .. version @@ -336,10 +368,14 @@ function xpack:extension() local extension = self:get("extension") if extension == nil then local extensions = { - nsis = ".exe", - zip = ".zip", - targz = ".tar.gz", - runself = ".sh" + nsis = ".exe", + zip = ".zip", + targz = ".tar.gz", + srczip = ".zip", + srctargz = ".tar.gz", + runself = ".sh", + deb = ".deb", + rpm = ".rpm" } extension = extensions[self:format()] or "" end @@ -466,15 +502,15 @@ function xpack:installfiles() return self:_copiedfiles("installfiles", self:installdir()) end --- get the root directory, this is just a temporary sandbox installation path, +-- get the installed root directory, this is just a temporary sandbox installation path, -- we may replace it with the actual installation path in the specfile -function xpack:rootdir() +function xpack:install_rootdir() return path.join(self:buildir(), "installed", self:format()) end -- get the installed directory function xpack:installdir(...) - local installdir = self:rootdir() + local installdir = self:install_rootdir() local prefixdir = self:get("prefixdir") if prefixdir then installdir = path.join(installdir, prefixdir) @@ -482,6 +518,26 @@ function xpack:installdir(...) return path.normalize(path.join(installdir, ...)) end +-- get the source files +function xpack:sourcefiles() + return self:_copiedfiles("sourcefiles", self:sourcedir()) +end + +-- get the source root directory +function xpack:source_rootdir() + return path.join(self:buildir(), "source", self:format()) +end + +-- get the source directory +function xpack:sourcedir(...) + local sourcedir = self:source_rootdir() + local prefixdir = self:get("prefixdir") + if prefixdir then + sourcedir = path.join(sourcedir, prefixdir) + end + return path.normalize(path.join(sourcedir, ...)) +end + -- get the binary directory function xpack:bindir() local bindir = self:get("bindir") diff --git a/xmake/plugins/pack/xpack_component.lua b/xmake/plugins/pack/xpack_component.lua index 59d2fae8f..bb0f5f454 100644 --- a/xmake/plugins/pack/xpack_component.lua +++ b/xmake/plugins/pack/xpack_component.lua @@ -240,10 +240,10 @@ function xpack_component:installfiles() return self:_copiedfiles("installfiles", self:package():installdir()) end --- get the root directory, this is just a temporary sandbox installation path, +-- get the installed root directory, this is just a temporary sandbox installation path, -- we may replace it with the actual installation path in the specfile -function xpack_component:rootdir() - return self:package():rootdir() +function xpack_component:install_rootdir() + return self:package():install_rootdir() end -- get the installed directory @@ -251,6 +251,21 @@ function xpack_component:installdir(...) return self:package():installdir(...) end +-- get the source files +function xpack_component:sourcefiles() + return self:_copiedfiles("sourcefiles", self:package():sourcedir()) +end + +-- get the source root directory +function xpack_component:source_rootdir() + return self:package():souece_rootdir() +end + +-- get the source directory +function xpack_component:sourcedir(...) + return self:package():sourcedir(...) +end + -- get the binary directory function xpack_component:bindir() return self:package():bindir() diff --git a/xmake/scripts/xpack/runself/makeself.lsm b/xmake/scripts/xpack/runself/makeself.lsm new file mode 100644 index 000000000..f71ea98c7 --- /dev/null +++ b/xmake/scripts/xpack/runself/makeself.lsm @@ -0,0 +1,11 @@ +Begin3 +Title: ${PACKAGE_TITLE} +Version: ${PACKAGE_VERSION} +Description: ${PACKAGE_DESCRIPTION} +Keywords: make build +Author: ruki (waruqi@gmail.com) +Maintained-by: ruki (waruqi@gmail.com) +Original-site: ${PACKAGE_HOMEPAGE} +Platform: Unix; Windows +Copying-policy: ${PACKAGE_COPYRIGHT} +End diff --git a/xmake/scripts/xpack/runself/setup.sh b/xmake/scripts/xpack/runself/setup.sh new file mode 100755 index 000000000..1a2485251 --- /dev/null +++ b/xmake/scripts/xpack/runself/setup.sh @@ -0,0 +1 @@ +#!/bin/sh -- cgit v1.3.1 From 19b444e7d0f05b1efa7a52b9d8c001be7cba14c2 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:35:48 +0800 Subject: improve xmakesrc xpack --- core/xpack.lua | 36 ++++++++++++++++++---------------- xmake/plugins/pack/main.lua | 48 ++++++++++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/core/xpack.lua b/core/xpack.lua index b8dcdc5c5..19c4ca0e7 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -77,30 +77,32 @@ xpack_component("LongPath") end) xpack("xmakesrc") - set_formats("zip", "targz", "runself") + set_formats("srczip", "srctargz", "runself") set_basename("xmake-v$(version)") before_package(function (package) import("devel.git") - local rootdir = path.join(os.tmpfile(package:name()) .. ".dir", "repo") - os.tryrm(rootdir) - os.cp(path.directory(os.projectdir()), rootdir) + local rootdir = path.join(os.tmpfile(package:basename()) .. ".dir", "repo") + if not os.isdir(rootdir) then + os.tryrm(rootdir) + os.cp(path.directory(os.projectdir()), rootdir) - 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}) + 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 end local prefixdir = "xmake-" .. package:version() 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) + package:add("sourcefiles", path.join(rootdir, "core/**|src/pdcurses/**|src/luajit/**|src/tbox/tbox/src/demo/**"), extraconf) + package:add("sourcefiles", path.join(rootdir, "xmake/**"), extraconf) + package:add("sourcefiles", path.join(rootdir, "*.md"), extraconf) + package:add("sourcefiles", path.join(rootdir, "configure"), extraconf) + package:add("sourcefiles", path.join(rootdir, "scripts/*.sh"), extraconf) + package:add("sourcefiles", path.join(rootdir, "scripts/man/**"), extraconf) + package:add("sourcefiles", path.join(rootdir, "scripts/debian/**"), extraconf) + package:add("sourcefiles", path.join(rootdir, "scripts/msys/**"), extraconf) end) diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua index f89c84835..c9576774f 100644 --- a/xmake/plugins/pack/main.lua +++ b/xmake/plugins/pack/main.lua @@ -26,6 +26,28 @@ import("private.service.remote_build.action", {alias = "remote_build_action"}) import("actions.build.main", {rootdir = os.programdir(), alias = "build_action"}) import("xpack") +-- get packages +function _get_packages() + + -- get need formats + local formats_need = option.get("formats") + if formats_need then + formats_need = formats_need:split(",") + if formats_need[1] == "all" then + formats_need = nil + end + end + + local packages = {} + for _, package in ipairs(xpack.packages()) do + if not formats_need or table.contains(formats_need, package:format()) then + table.insert(packages, package) + end + end + return packages +end + +-- load package function _load_package(package) -- ensure build and output directories @@ -39,47 +61,37 @@ function _load_package(package) end end +-- pack the given package function _on_package(package) import(package:format())(package) end function _pack_package(package) - -- get need formats - local formats_need = option.get("formats") - if formats_need then - formats_need = formats_need:split(",") - if formats_need[1] == "all" then - formats_need = nil - end - end - -- do pack local scripts = { package:script("package_before"), package:script("package", _on_package), package:script("package_after") } - if not formats_need or table.contains(formats_need, package:format()) then - _load_package(package) - for i = 1, 3 do - local script = scripts[i] - if script ~= nil then - script(package) - end + _load_package(package) + for i = 1, 3 do + local script = scripts[i] + if script ~= nil then + script(package) end end end function _pack_packages() - for _, package in ipairs(xpack.packages()) do + for _, package in ipairs(_get_packages()) do _pack_package(package) end end function _build_targets() local targetnames = {} - for _, package in ipairs(xpack.packages()) do + for _, package in ipairs(_get_packages()) do if package:from_binary() then local targets = package:get("targets") if targets then -- cgit v1.3.1 From f99a2826a56540608b01075a072eba11f4da6fc5 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:37:42 +0800 Subject: improve test --- tests/plugins/pack/xmake.lua | 9 ++++++--- xmake/plugins/pack/runself/main.lua | 22 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index e8d2cdd53..3000c9f28 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -39,9 +39,12 @@ xpack("test") end) after_installcmd(function (package, batchcmds) - batchcmds:mkdir(package:installdir("resources")) - batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"}) - batchcmds:mkdir(package:installdir("stub")) + if package:from_source() then + else + batchcmds:mkdir(package:installdir("resources")) + batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"}) + batchcmds:mkdir(package:installdir("stub")) + end end) after_uninstallcmd(function (package, batchcmds) diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index 91d1f9426..8f5774f61 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -130,9 +130,23 @@ function _pack_runself(makeself, package) return value end) - -- install the setup.sh script - local installdir = package:installdir() - local setupfile = path.join(installdir, "__setup__.sh") + -- archive source files + local srcfiles, dstfiles = package:sourcefiles() + for idx, srcfile in ipairs(srcfiles) do + os.vcp(srcfile, dstfiles[idx]) + end + for _, component in table.orderpairs(package:components()) do + if component:get("default") ~= false then + local srcfiles, dstfiles = component:sourcefiles() + for idx, srcfile in ipairs(srcfiles) do + os.vcp(srcfile, dstfiles[idx]) + end + end + end + + -- generate the setup.sh script + local sourcedir = package:sourcedir() + local setupfile = path.join(sourcedir, "__setup__.sh") os.cp(path.join(os.programdir(), "scripts", "xpack", "runself", "setup.sh"), setupfile) local scriptfile = io.open(setupfile, "a+") if scriptfile then @@ -147,7 +161,7 @@ function _pack_runself(makeself, package) -- make package os.vrunv(makeself, {"--gzip", "--sha256", "--lsm", specfile, - installdir, package:outputfile(), package:basename(), "./__setup__.sh"}) + sourcedir, package:outputfile(), package:basename(), "./__setup__.sh"}) end function main(package) -- cgit v1.3.1 From ce57069b6de7abaa758f791e29f89fa5dec34448 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:39:32 +0800 Subject: improve batchcmds --- xmake/plugins/pack/batchcmds.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua index 1b3023283..af55cc707 100644 --- a/xmake/plugins/pack/batchcmds.lua +++ b/xmake/plugins/pack/batchcmds.lua @@ -363,6 +363,9 @@ end -- on install command function _on_installcmd(package, batchcmds_) + if not package:from_binary() then + return + end local srcfiles, dstfiles = package:installfiles() for idx, srcfile in ipairs(srcfiles) do batchcmds_:cp(srcfile, dstfiles[idx]) @@ -374,6 +377,9 @@ end -- on uninstall command function _on_uninstallcmd(package, batchcmds_) + if not package:from_binary() then + return + end local _, dstfiles = package:installfiles() for _, dstfile in ipairs(dstfiles) do batchcmds_:rm(dstfile, {emptydirs = true}) -- cgit v1.3.1 From 3b725a5ad461e3085a475ee820ca9da01adeb363 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:40:46 +0800 Subject: improve batchcmds for runself --- tests/plugins/pack/xmake.lua | 1 + xmake/plugins/pack/runself/main.lua | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index 3000c9f28..5f4be60a3 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -40,6 +40,7 @@ xpack("test") after_installcmd(function (package, batchcmds) if package:from_source() then + batchcmds:runv("echo", {"hello"}) else batchcmds:mkdir(package:installdir("resources")) batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"}) diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index 8f5774f61..8f25c3e80 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -92,6 +92,8 @@ function _write_installcmd(package, scriptfile, cmd) elseif kind == "mkdir" then local dir = cmd.dir scriptfile:print("mkdir -p \"%s\"", dir) + elseif cmd.program then + scriptfile:print("%s", os.args(table.join(cmd.program, cmd.argv))) end end -- cgit v1.3.1 From abe98fd13ddd1643cba02d9e65f2e8a72cedc0b7 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 24 Nov 2023 22:42:04 +0800 Subject: add startup file for runself --- core/xpack.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/xpack.lua b/core/xpack.lua index 19c4ca0e7..d0d139317 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -106,3 +106,7 @@ xpack("xmakesrc") package:add("sourcefiles", path.join(rootdir, "scripts/debian/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "scripts/msys/**"), extraconf) end) + + on_installcmd(function (package, batchcmds) + batchcmds:runv("./scripts/get.sh", {"__local__"}) + end) -- cgit v1.3.1 From cdf118d061648db234dbded8c4d1ca9a27f9638f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 25 Nov 2023 00:02:42 +0800 Subject: fix ci --- .github/workflows/macos.yml | 2 +- scripts/makeppa | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b35c61e1a..121abcd07 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -43,7 +43,7 @@ jobs: brew install gnu-tar gem install --no-document fpm cd core - xmake pack --autobuild=n --basename=xmake -o ../artifacts xmakesrc + xmake pack -y --autobuild=n --basename=xmake -o ../artifacts xmakesrc cd .. scripts/makeself/build-runfile.sh - uses: actions/upload-artifact@v2 diff --git a/scripts/makeppa b/scripts/makeppa index 53b559e10..2cf5fcc24 100755 --- a/scripts/makeppa +++ b/scripts/makeppa @@ -32,7 +32,7 @@ basename=xmake-$version+$patch$serie tarball=$workdir/$basename.tar.gz if [ ! -f $tarball ]; then cd core - xmake pack --autobuild=n --formats=targz --basename=xmake -o ../artifacts xmakesrc || exit -1 + xmake pack --autobuild=n -y --formats=srctargz --basename=xmake -o ../artifacts xmakesrc || exit -1 cd .. cp ./artifacts/xmake.tar.gz $tarball fi -- cgit v1.3.1 From e297fa3482ddfd802f949ea6d5a8bb79a2fbf167 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 25 Nov 2023 00:03:05 +0800 Subject: improve macos ci --- .github/workflows/macos.yml | 16 ---------------- xmake/plugins/pack/xpack.lua | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 121abcd07..765bf1822 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -45,15 +45,10 @@ jobs: cd core xmake pack -y --autobuild=n --basename=xmake -o ../artifacts xmakesrc cd .. - scripts/makeself/build-runfile.sh - uses: actions/upload-artifact@v2 with: name: xmake-latest.gz.run path: artifacts/xmake.gz.run - - uses: actions/upload-artifact@v2 - with: - name: xmake-latest.xz.run - path: artifacts/xmake.xz.run - uses: actions/upload-artifact@v2 with: name: xmake-latest.tar.gz @@ -99,17 +94,6 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.gz.run asset_content_type: application/zip - - name: Publish xz runfile - if: github.event.action == 'published' - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: artifacts/xmake.xz.run - asset_name: xmake-${{ steps.tagName.outputs.tag }}.xz.run - asset_content_type: application/zip - - name: Publish gz archive if: github.event.action == 'published' uses: actions/upload-release-asset@v1.0.1 diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 4873e3fa1..2a4780945 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -373,7 +373,7 @@ function xpack:extension() targz = ".tar.gz", srczip = ".zip", srctargz = ".tar.gz", - runself = ".sh", + runself = ".gz.run", deb = ".deb", rpm = ".rpm" } -- cgit v1.3.1 From e393610e3f53aed9293882a668045fd67f1e1cd5 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 25 Nov 2023 00:42:14 +0800 Subject: fix makeself --- core/xpack.lua | 4 ++-- xmake/plugins/pack/xpack.lua | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/xpack.lua b/core/xpack.lua index d0d139317..e789423c2 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -79,6 +79,7 @@ xpack_component("LongPath") xpack("xmakesrc") set_formats("srczip", "srctargz", "runself") set_basename("xmake-v$(version)") + set_prefixdir("xmake-$(version)") before_package(function (package) import("devel.git") @@ -95,8 +96,7 @@ xpack("xmakesrc") end end - local prefixdir = "xmake-" .. package:version() - local extraconf = {rootdir = rootdir, prefixdir = prefixdir} + local extraconf = {rootdir = rootdir} package:add("sourcefiles", path.join(rootdir, "core/**|src/pdcurses/**|src/luajit/**|src/tbox/tbox/src/demo/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "xmake/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "*.md"), extraconf) diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 2a4780945..4bea5fb86 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -511,7 +511,7 @@ end -- get the installed directory function xpack:installdir(...) local installdir = self:install_rootdir() - local prefixdir = self:get("prefixdir") + local prefixdir = self:prefixdir() if prefixdir then installdir = path.join(installdir, prefixdir) end @@ -531,13 +531,22 @@ end -- get the source directory function xpack:sourcedir(...) local sourcedir = self:source_rootdir() - local prefixdir = self:get("prefixdir") + local prefixdir = self:prefixdir() if prefixdir then sourcedir = path.join(sourcedir, prefixdir) end return path.normalize(path.join(sourcedir, ...)) end +-- get the prefixdir +function xpack:prefixdir() + local prefixdir = self:get("prefixdir") + if prefixdir then + return filter.handle(prefixdir, self) + end + return prefixdir +end + -- get the binary directory function xpack:bindir() local bindir = self:get("bindir") -- cgit v1.3.1 From 103bbe833dc6c1e8203cab0e842e49cfa426d0a4 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 25 Nov 2023 00:43:45 +0800 Subject: remove build-runfile --- scripts/makeself/build-runfile.sh | 67 --------------------------------------- 1 file changed, 67 deletions(-) delete mode 100755 scripts/makeself/build-runfile.sh diff --git a/scripts/makeself/build-runfile.sh b/scripts/makeself/build-runfile.sh deleted file mode 100755 index d3149a2cd..000000000 --- a/scripts/makeself/build-runfile.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# path constants -cd "$(dirname "$0")/../.." -xmakeroot=`pwd` -buildroot=$xmakeroot/scripts/makeself -artifactsdir=$xmakeroot/artifacts -if [ ! -d $artifactsdir ]; then - mkdir $artifactsdir -fi -tmpdir=/tmp/xmake-makeself -if [ -d $tmpdir ]; then - rm -rf $tmpdir -fi -mkdir -p $tmpdir - -# copy xmake repo to tmpdir/repo, remove git ignored files -cp -r $xmakeroot $tmpdir/repo -cd $tmpdir/repo || exit -git reset --hard HEAD -git clean -dfX -git submodule foreach git clean -dfX - -# copy files to tmpdir/xmake -mkdir -p $tmpdir/xmake/scripts -cd $tmpdir/repo || exit -cp -r ./xmake $tmpdir/xmake/xmake -cp -r ./core $tmpdir/xmake -cp ./scripts/*.sh $tmpdir/xmake/scripts -cp ./*.md $tmpdir/xmake -cp configure $tmpdir/xmake -cd $tmpdir/xmake || exit -rm -rf ./core/src/tbox/tbox/src/demo -rm -rf ./core/src/tbox/tbox/src/tbox/platform/windows -rm -rf ./core/src/pdcurses -rm -rf ./core/src/luajit - -# prepare info texts -cd $tmpdir -cp $buildroot/* . -version=`cat ./xmake/core/xmake.lua | grep -E "^set_version" | grep -oE "[0-9]*\.[0-9]*\.[0-9]*"` -perl -pi -e "s/#xmake-version#/$version/g" ./header -perl -pi -e "s/#xmake-version#/$version/g" ./lsm - -# make run file -cd $tmpdir -makeself_version="2.5.0" -curl -fsSL https://github.com/megastep/makeself/releases/download/release-$makeself_version/makeself-$makeself_version.run -o ./makeself-$makeself_version.run -sh ./makeself-$makeself_version.run -./makeself-$makeself_version/makeself.sh \ - --gzip \ - --sha256 \ - --lsm ./lsm \ - --help-header ./header \ - ./xmake \ - $artifactsdir/xmake.gz.run \ - xmake-v$version-runfile \ - ./scripts/get.sh __local__ -./makeself-$makeself_version/makeself.sh \ - --xz \ - --sha256 \ - --lsm ./lsm \ - --help-header ./header \ - ./xmake \ - $artifactsdir/xmake.xz.run \ - xmake-v$version-runfile \ - ./scripts/get.sh __local__ -- cgit v1.3.1 From 43ac546cbd551bf06ae37a8211c8a65d9eadbb0b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 25 Nov 2023 00:51:19 +0800 Subject: add set_author and set_maintainer --- scripts/makeself/header | 8 -------- scripts/makeself/lsm | 15 --------------- tests/plugins/pack/xmake.lua | 1 + xmake/includes/xpack/xmake.lua | 4 ++++ xmake/plugins/pack/xpack.lua | 2 ++ xmake/scripts/xpack/runself/makeself.lsm | 6 +++--- 6 files changed, 10 insertions(+), 26 deletions(-) delete mode 100644 scripts/makeself/header delete mode 100644 scripts/makeself/lsm diff --git a/scripts/makeself/header b/scripts/makeself/header deleted file mode 100644 index f247ee7bd..000000000 --- a/scripts/makeself/header +++ /dev/null @@ -1,8 +0,0 @@ -xmake v#xmake-version#, A cross-platform build utility based on Lua -Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io - _ - __ ___ __ __ __ _| | ______ - \ \/ / | \/ |/ _ | |/ / __ \ - > < | \__/ | /_| | < ___/ - /_/\_\_|_| |_|\__ \|_|\_\____| - by ruki, xmake.io diff --git a/scripts/makeself/lsm b/scripts/makeself/lsm deleted file mode 100644 index 012efa4a1..000000000 --- a/scripts/makeself/lsm +++ /dev/null @@ -1,15 +0,0 @@ -Begin3 -Title: xmake -Version: #xmake-version# -Description: xmake is a cross-platform build utility based on lua. - The project focuses on making development and building easier and - provides many features (e.g package, install, plugin, macro, action, option, task ...), - so that any developer can quickly pick it up and - enjoy a productivity boost when developing and building projects. -Keywords: make build -Author: ruki (waruqi@gmail.com) -Maintained-by: ruki (waruqi@gmail.com) -Original-site: https://xmake.io/ -Platform: Unix; Windows -Copying-policy: Apache-2.0 -End diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index 5f4be60a3..33d50b3d2 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -21,6 +21,7 @@ target("foo") xpack("test") set_formats("nsis", "zip", "targz", "srczip", "srctargz", "runself") set_title("hello") + set_author("ruki") set_description("A test installer.") set_homepage("https://xmake.io") set_licensefile("LICENSE.md") diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index 8572b2a87..c6ed04201 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -34,6 +34,10 @@ local apis = { "xpack.set_homepage", -- set package title "xpack.set_title", + -- set author + "xpack.set_author", + -- set maintainer, + "xpack.set_maintainer", -- set package description "xpack.set_description", -- set input kind, e.g. binary, source diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 4bea5fb86..64e9d77dc 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -296,6 +296,8 @@ function xpack:specvars() PACKAGE_TITLE = self:title() or "", PACKAGE_DESCRIPTION = self:description() or "", PACKAGE_FILENAME = self:filename(), + PACKAGE_AUTHOR = self:get("author") or "", + PACKAGE_MAINTAINER = self:get("maintainer") or self:get("author") or "", PACKAGE_HOMEPAGE = self:get("homepage") or "", PACKAGE_COPYRIGHT = self:get("copyright") or "", PACKAGE_COMPANY = self:get("company") or "", diff --git a/xmake/scripts/xpack/runself/makeself.lsm b/xmake/scripts/xpack/runself/makeself.lsm index f71ea98c7..206c302c5 100644 --- a/xmake/scripts/xpack/runself/makeself.lsm +++ b/xmake/scripts/xpack/runself/makeself.lsm @@ -2,9 +2,9 @@ Begin3 Title: ${PACKAGE_TITLE} Version: ${PACKAGE_VERSION} Description: ${PACKAGE_DESCRIPTION} -Keywords: make build -Author: ruki (waruqi@gmail.com) -Maintained-by: ruki (waruqi@gmail.com) +Keywords: ${PACKAGE_NAME} +Author: $(PACKAGE_AUTHOR) +Maintained-by: $(PACKAGE_MAINTAINER) Original-site: ${PACKAGE_HOMEPAGE} Platform: Unix; Windows Copying-policy: ${PACKAGE_COPYRIGHT} -- cgit v1.3.1