summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-23 16:08:08 +0800
committerGitHub <[email protected]>2023-11-23 16:08:08 +0800
commit6b400aa1f7a578694079ccb84813a02192cb28e6 (patch)
tree0a557d8e8f9d0a047895ebd9d42820e85d4dc89e
parent401d67ca9824632d1531889a6261f458fa161c4c (diff)
parentb83dfc02b51b0c0538d547d3247c6e3246653f5b (diff)
Merge pull request #4416 from xmake-io/xmakesrc
improve xmakesrc pack
-rw-r--r--.github/workflows/macos.yml2
-rw-r--r--.github/workflows/windows.yml2
-rw-r--r--.github/workflows/windows_luajit.yml2
-rw-r--r--core/xpack.lua65
-rwxr-xr-xscripts/makeppa2
-rw-r--r--xmake/modules/utils/archive/archive.lua6
6 files changed, 32 insertions, 47 deletions
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index c143fa72e..b35c61e1a 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -43,7 +43,7 @@ jobs:
brew install gnu-tar
gem install --no-document fpm
cd core
- xmake pack --autobuild=n --formats=src_zip,src_targz --basename=xmake -o ../artifacts
+ xmake pack --autobuild=n --basename=xmake -o ../artifacts xmakesrc
cd ..
scripts/makeself/build-runfile.sh
- uses: actions/upload-artifact@v2
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 4a16620a8..b667f3e81 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -65,7 +65,7 @@ jobs:
run: |
cd core
xrepo update-repo
- xmake pack -vD -y --formats=nsis,zip --autobuild=n -o ../artifacts/${{env.RELEASE_NAME}} --basename=xmake
+ xmake pack -vD -y --formats=nsis,zip --autobuild=n -o ../artifacts/${{env.RELEASE_NAME}} --basename=xmake xmake
(Get-FileHash ../artifacts/${{env.RELEASE_NAME}}/xmake.zip -Algorithm SHA256).Hash.ToLower() + " *xmake.zip`n" | Out-File ./shafile -Encoding ASCII -NoNewLine -Append
Copy-Item shafile ../artifacts/${{env.RELEASE_NAME}}
cd ..
diff --git a/.github/workflows/windows_luajit.yml b/.github/workflows/windows_luajit.yml
index 9386acbff..86715fea9 100644
--- a/.github/workflows/windows_luajit.yml
+++ b/.github/workflows/windows_luajit.yml
@@ -54,7 +54,7 @@ jobs:
run: |
cd core
xrepo update-repo
- xmake pack -vD -y --formats=nsis,zip --autobuild=n -o ../artifacts/${{env.RELEASE_NAME}} --basename=xmake
+ xmake pack -vD -y --formats=nsis,zip --autobuild=n -o ../artifacts/${{env.RELEASE_NAME}} --basename=xmake xmake
(Get-FileHash ../artifacts/${{env.RELEASE_NAME}}/xmake.zip -Algorithm SHA256).Hash.ToLower() + " *xmake.zip`n" | Out-File ./shafile -Encoding ASCII -NoNewLine -Append
Copy-Item shafile ../artifacts/${{env.RELEASE_NAME}}
cd ..
diff --git a/core/xpack.lua b/core/xpack.lua
index c81509da0..bc2df257e 100644
--- a/core/xpack.lua
+++ b/core/xpack.lua
@@ -77,51 +77,30 @@ xpack_component("LongPath")
end)
xpack("xmakesrc")
- set_formats("src_zip", "src_targz")
+ set_formats("zip", "targz")
set_basename("xmake-v$(version)")
- on_load(function (package)
- local format = package:format()
- if format == "src_zip" then
- package:set("extension", ".zip")
- elseif format == "src_targz" then
- package:set("extension", ".tar.gz")
- end
- end)
- on_package(function (package)
+ before_package(function (package)
import("devel.git")
- import("utils.archive")
- print("packing %s", package:outputfile())
- local tmpdir = os.tmpfile() .. ".dir"
- local repodir = path.join(tmpdir, "repo")
- local srcdir = path.join(package:rootdir(), "xmakesrc")
- local topdir = path.join(srcdir, "xmake-" .. package:version())
- os.tryrm(repodir)
- os.tryrm(topdir)
- os.cp(path.directory(path.absolute(os.projectdir())), repodir)
- git.clean({repodir = repodir, force = true, all = true})
- git.reset({repodir = repodir, hard = true})
- if os.isfile(path.join(repodir, ".gitmodules")) then
- git.submodule.clean({repodir = repodir, force = true, all = true})
- git.submodule.reset({repodir = repodir, hard = true})
+
+ local rootdir = path.join(os.tmpfile(package:name()) .. ".dir", "repo")
+ os.tryrm(rootdir)
+ os.cp(path.directory(os.projectdir()), rootdir)
+
+ git.clean({repodir = rootdir, force = true, all = true})
+ git.reset({repodir = rootdir, hard = true})
+ if os.isfile(path.join(rootdir, ".gitmodules")) then
+ git.submodule.clean({repodir = rootdir, force = true, all = true})
+ git.submodule.reset({repodir = rootdir, hard = true})
end
- os.mkdir(path.join(topdir, "scripts"))
- os.vcp(path.join(repodir, "core"), topdir)
- os.vcp(path.join(repodir, "xmake"), topdir)
- os.vcp(path.join(repodir, "*.md"), topdir)
- os.vcp(path.join(repodir, "configure"), topdir)
- os.vcp(path.join(repodir, "scripts", "*.sh"), path.join(topdir, "scripts"))
- os.vcp(path.join(repodir, "scripts", "man"), path.join(topdir, "scripts"))
- os.vcp(path.join(repodir, "scripts", "debian"), path.join(topdir, "scripts"))
- os.vcp(path.join(repodir, "scripts", "msys"), path.join(topdir, "scripts"))
- os.rm(path.join(topdir, "core", "src", "tbox", "tbox", "src", "demo"))
- os.rm(path.join(topdir, "core", "src", "luajit"))
- os.rm(path.join(topdir, "core", "src", "pdcurses"))
- -- archive files
- local oldir = os.cd(srcdir)
- local archivefiles = os.files("**")
- os.cd(oldir)
- archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = srcdir, compress = "best"})
- os.tryrm(tmpdir)
+ local prefixdir = "xmake-" .. package:version()
+ local extraconf = {rootdir = rootdir, prefixdir = prefixdir}
+ package:add("installfiles", path.join(rootdir, "core/**|src/pdcurses/**|src/luajit/**|src/tbox/tbox/src/demo/**"), extraconf)
+ package:add("installfiles", path.join(rootdir, "xmake/**"), extraconf)
+ package:add("installfiles", path.join(rootdir, "*.md"), extraconf)
+ package:add("installfiles", path.join(rootdir, "configure"), extraconf)
+ package:add("installfiles", path.join(rootdir, "scripts/*.sh"), extraconf)
+ package:add("installfiles", path.join(rootdir, "scripts/man/**"), extraconf)
+ package:add("installfiles", path.join(rootdir, "scripts/debian/**"), extraconf)
+ package:add("installfiles", path.join(rootdir, "scripts/msys/**"), extraconf)
end)
-
diff --git a/scripts/makeppa b/scripts/makeppa
index 6421f0155..53b559e10 100755
--- a/scripts/makeppa
+++ b/scripts/makeppa
@@ -32,7 +32,7 @@ basename=xmake-$version+$patch$serie
tarball=$workdir/$basename.tar.gz
if [ ! -f $tarball ]; then
cd core
- xmake pack --autobuild=n --formats=src_targz --basename=xmake -o ../artifacts || exit -1
+ xmake pack --autobuild=n --formats=targz --basename=xmake -o ../artifacts xmakesrc || exit -1
cd ..
cp ./artifacts/xmake.tar.gz $tarball
fi
diff --git a/xmake/modules/utils/archive/archive.lua b/xmake/modules/utils/archive/archive.lua
index aba6403d3..d21203368 100644
--- a/xmake/modules/utils/archive/archive.lua
+++ b/xmake/modules/utils/archive/archive.lua
@@ -330,6 +330,12 @@ function main(archivefile, inputfiles, opt)
-- get extension
local extension = opt.extension or get_archive_extension(archivefile)
+ -- ensure output directory
+ local archivedir = path.directory(archivefile)
+ if not os.isdir(archivedir) then
+ os.mkdir(archivedir)
+ end
+
-- archive it
return _archive(archivefile, inputfiles, extension, archivers[extension], opt)
end