Skip to content

Commit

Permalink
improve add_patches to support archive file
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 29, 2024
1 parent 7659e6d commit bde7839
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import("core.base.global")
import("net.http")
import("net.proxy")
import("devel.git")
import("utils.archive")

-- check sha256
function _check_sha256(patch_hash, patch_file)
Expand Down Expand Up @@ -97,8 +98,31 @@ function _patch(package, patch_url, patch_hash)
end
end

-- apply the patch file
git.apply(patch_file)
-- is archive file? we need extract it first
local extension = archive.extension(patch_file)
if extension and #extension > 0 then
local patchdir = patch_file .. ".dir"
local patchdir_tmp = patchdir .. ".tmp"
os.tryrm(patchdir_tmp)
if archive.extract(patch_file, patchdir_tmp) then
os.tryrm(patchdir)
os.mv(patchdir_tmp, patchdir)
else
os.tryrm(patchdir_tmp)
os.tryrm(patchdir)
raise("cannot extract %s", patch_file)
end

-- apply patch files
for _, file in ipairs(os.files(path.join(patchdir, "**"))) do
vprint("applying patch %s", file)
git.apply(file)
end
else
-- apply single plain patch file
vprint("applying patch %s", patch_file)
git.apply(patch_file)
end
end

-- patch the given package
Expand Down

0 comments on commit bde7839

Please sign in to comment.