summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-15 23:56:05 +0800
committerruki <[email protected]>2023-12-15 23:56:05 +0800
commitbd85dc661e4cc386d27aa9cd855b91096b5b203c (patch)
treeeca01fc5eebe661f09dc4da6a1f4dd211ecb9d41 /xmake/plugins
parent86739912c5630ad7033b1d7f4c206489b6d201b0 (diff)
add srpm
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/pack/srpm/main.lua69
-rw-r--r--xmake/plugins/pack/xmake.lua2
-rw-r--r--xmake/plugins/pack/xpack.lua4
3 files changed, 72 insertions, 3 deletions
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
new file mode 100644
index 000000000..e5368d2be
--- /dev/null
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -0,0 +1,69 @@
+--!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 rpmbuild
+function _get_rpmbuild()
+
+ -- enter the environments of rpmbuild
+ local oldenvs = packagenv.enter("rpm")
+
+ -- find rpmbuild
+ local packages = {}
+ local rpmbuild = find_tool("rpmbuild")
+ if not rpmbuild then
+ table.join2(packages, install_packages("rpm"))
+ 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 rpmbuild then
+ rpmbuild = find_tool("rpmbuild", {force = true})
+ end
+ assert(rpmbuild, "rpmbuild not found!")
+ return rpmbuild, oldenvs
+end
+
+function main(package)
+
+ if not is_host("linux") then
+ return
+ end
+
+ cprint("packing %s", package:outputfile())
+
+ -- get rpmbuild
+ local rpmbuild, oldenvs = _get_rpmbuild()
+
+
+ -- done
+ os.setenvs(oldenvs)
+end
diff --git a/xmake/plugins/pack/xmake.lua b/xmake/plugins/pack/xmake.lua
index 96b0d2070..6ed3b6d3f 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", "srctargz", "srczip"}},
+ values = {"nsis", "deb", "srpm", "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 64e9d77dc..67216b928 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -237,7 +237,7 @@ function xpack:inputkind()
srctargz = "source",
runself = "source",
deb = "source",
- rpm = "source"
+ srpm = "source"
}
inputkind = inputkinds[self:format()] or "binary"
end
@@ -377,7 +377,7 @@ function xpack:extension()
srctargz = ".tar.gz",
runself = ".gz.run",
deb = ".deb",
- rpm = ".rpm"
+ srpm = ".src.rpm"
}
extension = extensions[self:format()] or ""
end