diff options
| author | ruki <[email protected]> | 2023-12-22 22:55:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-12-22 22:55:05 +0800 |
| commit | 80937fbe6cf18a5372cdadb012a92ffc3985719b (patch) | |
| tree | 7f3d725b78ffc0486e7fc02e429be143cbbb9b6c | |
| parent | e7e4a16ed6bb8e2f1db5fc28d5ad2920e3c8e41b (diff) | |
pack rpm
| -rw-r--r-- | tests/plugins/pack/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/includes/xpack/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/rpm/main.lua | 26 | ||||
| -rw-r--r-- | xmake/plugins/pack/srpm/main.lua | 11 | ||||
| -rw-r--r-- | xmake/plugins/pack/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 7 |
6 files changed, 44 insertions, 6 deletions
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index fc45c7fad..1ce179b33 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", "srpm", "zip", "targz", "srczip", "srctargz", "runself") + set_formats("nsis", "srpm", "rpm", "zip", "targz", "srczip", "srctargz", "runself") set_title("hello") set_author("ruki") set_description("A test installer.") diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index 5b8580172..83731fcd2 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -46,7 +46,7 @@ local apis = { "xpack.set_copyright", -- set company name "xpack.set_company", - -- set package formats, e.g. nsis, deb, srpm, targz, zip, srctargz, srczip, runself, ... + -- set package formats, e.g. nsis, deb, srpm, rpm, targz, zip, srctargz, srczip, runself, ... -- we can also add custom formats "xpack.set_formats", -- set the base name of the output file diff --git a/xmake/plugins/pack/rpm/main.lua b/xmake/plugins/pack/rpm/main.lua new file mode 100644 index 000000000..39b5a172e --- /dev/null +++ b/xmake/plugins/pack/rpm/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(".srpm") + +function main(package) + srpm(package) +end diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua index 1f6a52b57..b6b5467c8 100644 --- a/xmake/plugins/pack/srpm/main.lua +++ b/xmake/plugins/pack/srpm/main.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.base.semver") import("core.base.hashset") import("lib.detect.find_tool") +import("lib.detect.find_file") import("utils.archive") import("private.action.require.impl.packagenv") import("private.action.require.impl.install_packages") @@ -248,11 +249,19 @@ function _pack_srpm(rpmbuild, package) os.tryrm(archivefile) archive.archive(archivefile, archivefiles, {curdir = rootdir, compress = "best"}) - -- do pack + -- pack srpm package os.vrunv(rpmbuild, {"-bs", specfile, "--define", "_topdir " .. package:buildir(), "--define", "_sourcedir " .. package:buildir(), "--define", "_srcrpmdir " .. package:outputdir()}) + + -- pack rpm package + if package:format() == "rpm" then + local srpmfile = find_file("*.src.rpm", package:outputdir()) + if srpmfile then + os.vrunv(rpmbuild, {"--rebuild", srpmfile, "--define", "_rpmdir " .. package:outputdir()}) + end + end end function main(package) diff --git a/xmake/plugins/pack/xmake.lua b/xmake/plugins/pack/xmake.lua index 6ed3b6d3f..0afa83cff 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", "srpm", "runself", "targz", "zip", "srctargz", "srczip"}}, + values = {"nsis", "deb", "srpm", "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 5cf5f24f4..0eae84a7a 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -237,7 +237,8 @@ function xpack:inputkind() srctargz = "source", runself = "source", deb = "source", - srpm = "source" + srpm = "source", + rpm = "source" } inputkind = inputkinds[self:format()] or "binary" end @@ -362,6 +363,7 @@ function xpack:specfile() local extensions = { nsis = ".nsi", srpm = ".spec", + rpm = ".spec", runself = ".lsm" } local extension = extensions[self:format()] or ".spec" @@ -380,7 +382,8 @@ function xpack:extension() srctargz = ".tar.gz", runself = ".gz.run", deb = ".deb", - srpm = ".src.rpm" + srpm = ".src.rpm", + rpm = ".rpm" } extension = extensions[self:format()] or "" end |
