# Single patch application %apply_patch(qp:m:)\ %{lua:\ local file = rpm.expand("%{1}")\ local num = rpm.expand("%{2}")\ if posix.access(file, "r") then\ local options = rpm.expand("%{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}")\ local scm_apply = rpm.expand("%__scm_apply_%{__scm}")\ print(rpm.expand("%{uncompress:"..file.."} | "..scm_apply.." "..options.." "..file.." "..num.."\\n"))\ else\ print("echo 'Cannot read "..file.."'; exit 1;".."\\n")\ end}
# Automatically apply all patches # -m<min> Apply patches with number >= min only # -M<max> Apply patches with number <= max only %autopatch(vp:m:M:)\ %{lua:\ local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")\ local low_limit = tonumber(rpm.expand("%{-m:%{-m*}}"))\ local high_limit = tonumber(rpm.expand("%{-M:%{-M*}}"))\ for i, p in ipairs(patches) do\ local inum = patch_nums[i]\ if ((not low_limit or inum>=low_limit) and (not high_limit or inum<=high_limit)) \ then\ print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..options..p.." "..i.."\\n")) \ end\ end}
%{lua: local i = 1 for l in io.lines('debian/patches/series') do print(string.format('Patch%04d:\t%s\n', i, l)) i = i + 1 end }
然后,重新定义 %autopatch 宏,在 %apply_patch 时传递正确的路径:
1 2 3 4 5 6 7 8 9 10 11 12
%define autopatch(vp:m:M:)\ %{lua:\ local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")\ local low_limit = tonumber(rpm.expand("%{-m:%{-m*}}"))\ local high_limit = tonumber(rpm.expand("%{-M:%{-M*}}"))\ for i, p in ipairs(patches) do\ local inum = patch_nums[i]\ if ((not low_limit or inum>=low_limit) and (not high_limit or inum<=high_limit)) \ then\ print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..options.."debian/patches/%{basename:"..p.."} "..i.."\\n")) \ end\ end}
需要注意 p 是带 %{_sourcedir}/ 前缀的全路径,因此需要加上一个 basename 的处理。
error: Bad file: ./0049-PVE-savevm-async-register-yank-before-migration_inco.patch: No such file or directory error: Bad file: ./0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch: No such file or directory