From c1bba747f0859fb6f559169563973f28905c71f7 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 18 Dec 2023 22:41:39 +0800 Subject: [PATCH] call rpmbuild --- tests/plugins/pack/xmake.lua | 1 + xmake/includes/xpack/xmake.lua | 2 ++ xmake/plugins/pack/srpm/main.lua | 19 +++---------------- xmake/plugins/pack/xpack.lua | 1 + xmake/scripts/xpack/srpm/srpm.spec | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index 34b7414060f..b1a4c641b69 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -24,6 +24,7 @@ xpack("test") set_author("ruki") set_description("A test installer.") set_homepage("https://xmake.io") + set_license("Apache-2.0") set_licensefile("LICENSE.md") add_targets("test", "foo") add_installfiles("src/(assets/*.png)", {prefixdir = "images"}) diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index bbc7c505048..ad26db9c47b 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -79,6 +79,8 @@ local apis = { "xpack.set_specfile", -- set icon file path, e.g foo.ico "xpack.set_iconfile", + -- set package license + "xpack.set_license", -- set package license file, we will also get them from target "xpack.set_licensefile", -- add source files diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua index 7fd300c3343..8963db27210 100644 --- a/xmake/plugins/pack/srpm/main.lua +++ b/xmake/plugins/pack/srpm/main.lua @@ -55,6 +55,7 @@ end -- get specvars function _get_specvars(package) local specvars = table.clone(package:specvars()) + specvars.PACKAGE_SOURCEDIR = package:sourcedir() return specvars end @@ -100,22 +101,8 @@ function _pack_srpm(rpmbuild, package) 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", "srpm", "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]] - + -- do pack + os.vrunv(rpmbuild, {"-bs", specfile, "--define", "_srcrpmdir " .. package:outputfile()}) end function main(package) diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 4f9f01ad225..5cf5f24f459 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -302,6 +302,7 @@ function xpack:specvars() PACKAGE_COPYRIGHT = self:get("copyright") or "", PACKAGE_COMPANY = self:get("company") or "", PACKAGE_ICONFILE = self:get("iconfile") or "", + PACKAGE_LICENSE = self:license() or "", PACKAGE_LICENSEFILE = self:get("licensefile") or "" } diff --git a/xmake/scripts/xpack/srpm/srpm.spec b/xmake/scripts/xpack/srpm/srpm.spec index 9372e49bf2f..bde3d768afb 100644 --- a/xmake/scripts/xpack/srpm/srpm.spec +++ b/xmake/scripts/xpack/srpm/srpm.spec @@ -7,9 +7,9 @@ Version: ${PACKAGE_VERSION} Release: 1%{?dist} Summary: ${PACKAGE_TITLE} -License: Apache-2.0 AND LicenseRef-Fedora-Public-Domain AND BSD +License: ${PACKAGE_LICENSE} URL: ${PACKAGE_HOMEPAGE} -Source0: https://github.com/xmake-io/xmake/releases/download/v%{version}/%{name}-v%{version}.tar.gz +Source0: ${PACKAGE_SOURCEDIR} BuildRequires: gcc BuildRequires: gcc-c++