diff options
| author | ruki <[email protected]> | 2024-03-01 00:50:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-01 00:50:16 +0800 |
| commit | 9b8384ff002380fce4ba8ca4cd3f6e0e354fb9dc (patch) | |
| tree | 440df557186868b57313538be1526bce47d87dfe | |
| parent | 95029452b5b1ebf71986a6bd2d2d45f459861c19 (diff) | |
apply reversed patches for package
| -rw-r--r-- | xmake/core/package/package.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/patch_sources.lua | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index eef05d80e..9ef2abfe6 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1998,6 +1998,12 @@ function _instance:fetch_librarydeps() end -- get the patches of the current version +-- +-- @code +-- add_patches("6.7.6", "https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-6.7.6.xz", +-- "a394326aa325f8a930a4ce33c69ba7b8b454aef1107a4d3c2a8ae12908615fc4", {reverse = true}) +-- @endcode +-- function _instance:patches() local patches = self._PATCHES if patches == nil then @@ -2009,7 +2015,8 @@ function _instance:patches() patches = {} patchinfo = table.wrap(patchinfo) for idx = 1, #patchinfo, 2 do - table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1]}) + local extra = self:extraconf("patches." .. version_str, patchinfo[idx]) + table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1], extra = extra}) end else -- match semver, e.g add_patches(">=1.0.0", url, sha256) @@ -2018,7 +2025,8 @@ function _instance:patches() patches = patches or {} patchinfo = table.wrap(patchinfo) for idx = 1, #patchinfo, 2 do - table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1]}) + local extra = self:extraconf("patches." .. range, patchinfo[idx]) + table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1], extra = extra}) end end end diff --git a/xmake/modules/private/action/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua index b5203471f..49f4363cb 100644 --- a/xmake/modules/private/action/require/impl/actions/patch_sources.lua +++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua @@ -49,7 +49,10 @@ function _check_sha256(patch_hash, patch_file) end -- do patch -function _patch(package, patch_url, patch_hash) +function _patch(package, patchinfo) + local patch_url = patchinfo.url + local patch_hash = patchinfo.hash + local patch_extra = patchinfo.extra or {} -- trace patch_url = proxy.mirror(patch_url) or patch_url @@ -116,12 +119,12 @@ function _patch(package, patch_url, patch_hash) -- apply patch files for _, file in ipairs(os.files(path.join(patchdir, "**"))) do vprint("applying patch %s", file) - git.apply(file) + git.apply(file, {reverse = patch_extra.reverse}) end else -- apply single plain patch file vprint("applying patch %s", patch_file) - git.apply(patch_file) + git.apply(patch_file, {reverse = patch_extra.reverse}) end end @@ -141,6 +144,6 @@ function main(package) -- do all patches for _, patchinfo in ipairs(patches) do - _patch(package, patchinfo.url, patchinfo.sha256) + _patch(package, patchinfo) end end |
