summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-22 00:00:18 +0800
committerruki <[email protected]>2023-12-22 00:00:18 +0800
commit6417898f2e1076a642d85fc91478c84b9e67a39a (patch)
tree12d6f70502c4617d03bd2536f5446559da6ae207
parent17733b58e60dbc2729de94c17aedf48d6495136c (diff)
pack xmake install to srpm
-rw-r--r--core/xpack.lua2
-rw-r--r--xmake/plugins/pack/batchcmds.lua25
-rw-r--r--xmake/plugins/pack/srpm/main.lua1
3 files changed, 21 insertions, 7 deletions
diff --git a/core/xpack.lua b/core/xpack.lua
index f8a1726cc..94e21f7a2 100644
--- a/core/xpack.lua
+++ b/core/xpack.lua
@@ -127,6 +127,6 @@ xpack("xmakesrc")
if format == "runself" then
batchcmds:runv("./scripts/get.sh", {"__local__"})
elseif format == "srpm" then
- batchcmds:runv("make", {"install", "PREFIX=%{buildroot}"})
+ batchcmds:runv("make", {"install", path(package:install_rootdir(), function (p) return "PREFIX=" .. p end)})
end
end)
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index 2403b5bca..9f74ad606 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -183,6 +183,12 @@ function _on_target_installcmd_headeronly(target, batchcmds_, opt)
_install_headers(target, batchcmds_, includedir)
end
+-- on install source target command
+function _on_target_installcmd_source(target, batchcmds_, opt)
+ local package = opt.package
+ batchcmds_:vrunv("xmake", {"install", "-o", path(package:install_rootdir()), target:name()})
+end
+
-- on build target command
function _on_target_buildcmd(target, batchcmds_, opt)
local package = opt.package
@@ -192,6 +198,10 @@ end
-- on install target command
function _on_target_installcmd(target, batchcmds_, opt)
local package = opt.package
+ if package:from_source() then
+ _on_target_installcmd_source(target, batchcmds_, opt)
+ return
+ end
-- install target binaries
local scripts = {
@@ -278,9 +288,18 @@ function _on_target_uninstallcmd_headeronly(target, batchcmds_, opt)
_uninstall_headers(target, batchcmds_, includedir)
end
+-- on uninstall source target command
+function _on_target_uninstallcmd_source(target, batchcmds_, opt)
+ -- TODO
+end
+
-- on uninstall target command
function _on_target_uninstallcmd(target, batchcmds_, opt)
local package = opt.package
+ if package:from_source() then
+ _on_target_uninstallcmd_source(target, batchcmds_, opt)
+ return
+ end
-- uninstall target binaries
local scripts = {
@@ -412,9 +431,6 @@ 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])
@@ -426,9 +442,6 @@ 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})
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
index 2c9a0cb1b..1ffbdc6ed 100644
--- a/xmake/plugins/pack/srpm/main.lua
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -99,6 +99,7 @@ function _get_customcmd(package, installcmds, cmd)
local dir = _translate_filepath(package, cmd.dir)
table.insert(installcmds, string.format("mkdir -p \"%s\"", dir))
elseif cmd.program then
+ -- TODO translate path
table.insert(installcmds, string.format("%s", os.args(table.join(cmd.program, cmd.argv))))
end
end