summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-18 23:34:22 +0800
committerruki <[email protected]>2023-12-18 23:34:22 +0800
commitcc7b17ab9e0d9fc523b88a2508fb79947d440fef (patch)
tree89502c797db8452ca78e92bd261cd76fb7a50b96
parent92a0f01114b8001e035b0b6a01c4e689ed6a41ee (diff)
translate path
-rw-r--r--tests/plugins/pack/xmake.lua2
-rw-r--r--xmake/plugins/pack/srpm/main.lua21
-rw-r--r--xmake/scripts/xpack/srpm/srpm.spec2
3 files changed, 16 insertions, 9 deletions
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua
index b1a4c641b..abf67234c 100644
--- a/tests/plugins/pack/xmake.lua
+++ b/tests/plugins/pack/xmake.lua
@@ -41,7 +41,7 @@ xpack("test")
end)
after_installcmd(function (package, batchcmds)
- if package:from_source() then
+ if package:format() == "runself" then
batchcmds:runv("echo", {"hello"})
else
batchcmds:mkdir(package:installdir("resources"))
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
index b7a7d7665..b30596a96 100644
--- a/xmake/plugins/pack/srpm/main.lua
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -58,6 +58,11 @@ function _get_archivefile(package)
return path.absolute(path.join(package:buildir(), package:basename() .. ".tar.gz"))
end
+-- translate the file path
+function _translate_filepath(package, filepath)
+ return filepath:replace(package:install_rootdir(), "%{buildroot}", {plain = true})
+end
+
-- get install command
function _get_installcmd(package, installcmds, cmd)
local opt = cmd.opt or {}
@@ -66,7 +71,7 @@ function _get_installcmd(package, installcmds, cmd)
local srcfiles = os.files(cmd.srcpath)
for _, srcfile in ipairs(srcfiles) do
-- the destination is directory? append the filename
- local dstfile = cmd.dstpath
+ local dstfile = _translate_filepath(package, cmd.dstpath)
if #srcfiles > 1 or path.islastsep(dstfile) then
if opt.rootdir then
dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir))
@@ -74,23 +79,23 @@ function _get_installcmd(package, installcmds, cmd)
dstfile = path.join(dstfile, path.filename(srcfile))
end
end
- table.insert(installcmds, string.format("cp -p \"%s\" \"%s\"", srcfile, dstfile))
+ table.insert(installcmds, string.format("install -Dpm0644 \"%s\" \"%s\"", srcfile, dstfile))
end
elseif kind == "rm" then
- local filepath = cmd.filepath
+ local filepath = _translate_filepath(package, cmd.filepath)
table.insert(installcmds, string.format("rm -f \"%s\"", filepath))
elseif kind == "rmdir" then
- local dir = cmd.dir
+ local dir = _translate_filepath(package, cmd.dir)
table.insert(installcmds, string.format("rm -rf \"%s\"", dir))
elseif kind == "mv" then
- local srcpath = cmd.srcpath
- local dstpath = cmd.dstpath
+ local srcpath = _translate_filepath(package, cmd.srcpath)
+ local dstpath = _translate_filepath(package, cmd.dstpath)
table.insert(installcmds, string.format("mv \"%s\" \"%s\"", srcfile, dstfile))
elseif kind == "cd" then
- local dir = cmd.dir
+ local dir = _translate_filepath(package, cmd.dir)
table.insert(installcmds, string.format("cd \"%s\"", dir))
elseif kind == "mkdir" then
- local dir = cmd.dir
+ local dir = _translate_filepath(package, cmd.dir)
table.insert(installcmds, string.format("mkdir -p \"%s\"", dir))
elseif cmd.program then
table.insert(installcmds, string.format("%s", os.args(table.join(cmd.program, cmd.argv))))
diff --git a/xmake/scripts/xpack/srpm/srpm.spec b/xmake/scripts/xpack/srpm/srpm.spec
index fd652c394..fa16a64af 100644
--- a/xmake/scripts/xpack/srpm/srpm.spec
+++ b/xmake/scripts/xpack/srpm/srpm.spec
@@ -27,6 +27,8 @@ ${PACKAGE_INSTALLCMDS}
%check
%files
+/resources/assets/file1.txt
+/resources/assets/file2.txt
%changelog
* ${PACKAGE_DATE} ${PACKAGE_MAINTAINER} - ${PACKAGE_VERSION}-1