diff options
| author | ruki <[email protected]> | 2024-09-05 17:15:02 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-09-05 17:15:02 +0800 |
| commit | e9df84ad021c7c8ec020384e250ca5b95fe3e700 (patch) | |
| tree | 3986286cf9b04a0340ca413c01ad242214957ea1 | |
| parent | a3f50282bfed783a402b7d97485820ca8ceb0691 (diff) | |
| parent | ee4935050a6165e1da500731fb00f3b08265c266 (diff) | |
Merge pull request #5570 from xmake-io/cpfile
Improve to copy file
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rw-r--r-- | core/src/xmake/os/cpfile.c | 4 | ||||
| -rw-r--r-- | xmake/actions/create/main.lua | 3 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/pack/deb/main.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/runself/main.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/srpm/main.lua | 2 |
7 files changed, 11 insertions, 5 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject 57e57a3271ad925936b3fbf37877f9eceb49ee4 +Subproject e222f61667fdafb9189849d2970c01e13940b0b diff --git a/core/src/xmake/os/cpfile.c b/core/src/xmake/os/cpfile.c index 153f51de0..06184cf21 100644 --- a/core/src/xmake/os/cpfile.c +++ b/core/src/xmake/os/cpfile.c @@ -49,6 +49,10 @@ tb_int_t xm_os_cpfile(lua_State* lua) if (is_symlink) flags |= TB_FILE_COPY_LINK; + tb_bool_t is_writeable = lua_toboolean(lua, 4); + if (is_writeable) + flags |= TB_FILE_COPY_WRITEABLE; + // do copy lua_pushboolean(lua, tb_file_copy(src, dst, flags)); return 1; diff --git a/xmake/actions/create/main.lua b/xmake/actions/create/main.lua index 69aa52997..6f65b2785 100644 --- a/xmake/actions/create/main.lua +++ b/xmake/actions/create/main.lua @@ -98,7 +98,8 @@ function _create_project(language, templateid, targetname) local sourcedir = path.join(tempinst:scriptdir(), "project") if os.isdir(sourcedir) then for _, filedir in ipairs(os.filedirs(path.join(sourcedir, "*"))) do - os.cp(filedir, projectdir) + -- https://github.com/xmake-io/xmake/issues/5138#issuecomment-2329238617 + os.cp(filedir, projectdir, {writeable = true}) table.insert(filedirs, path.relative(filedir, sourcedir)) end os.cp(path.join(os.programdir(), "scripts", "gitignore"), path.join(projectdir, ".gitignore")) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 2dba50509..6a1151e23 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -70,6 +70,7 @@ function os._cp(src, dst, rootdir, opt) -- is file or link? local symlink = opt.symlink + local writeable = opt.writeable if os.isfile(src) or (symlink and os.islink(src)) then -- the destination is directory? append the filename @@ -85,7 +86,7 @@ function os._cp(src, dst, rootdir, opt) if opt.force and os.isfile(dst) then os.rmfile(dst) end - if not os.cpfile(src, dst, symlink) then + if not os.cpfile(src, dst, symlink, writeable) then local errors = os.strerror() if symlink and os.islink(src) then local reallink = os.readlink(src) diff --git a/xmake/plugins/pack/deb/main.lua b/xmake/plugins/pack/deb/main.lua index 076b88da3..8088d39bd 100644 --- a/xmake/plugins/pack/deb/main.lua +++ b/xmake/plugins/pack/deb/main.lua @@ -191,7 +191,7 @@ function _pack_deb(debuild, package) local debiandir = path.join(sourcedir, "debian") if not os.isdir(debiandir) then local debiandir_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "deb", "debian") - os.cp(debiandir_template, debiandir) + os.cp(debiandir_template, debiandir, {writeable = true}) end -- replace variables in specfile diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index 4343b1a76..91284edc0 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -111,7 +111,7 @@ function _pack_runself(makeself, package) local specfile = path.join(package:buildir(), package:basename() .. ".lsm") if not os.isfile(specfile) then local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "runself", "makeself.lsm") - os.cp(specfile_template, specfile) + os.cp(specfile_template, specfile, {writeable = true}) end -- replace variables in specfile diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua index a0b2d2dad..72b76563e 100644 --- a/xmake/plugins/pack/srpm/main.lua +++ b/xmake/plugins/pack/srpm/main.lua @@ -205,7 +205,7 @@ function _pack_srpm(rpmbuild, package) local specfile = path.join(package:buildir(), package:basename() .. ".spec") if not os.isfile(specfile) then local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "srpm", "srpm.spec") - os.cp(specfile_template, specfile) + os.cp(specfile_template, specfile, {writeable = true}) end -- replace variables in specfile |
