#------------------------------------------------------------------------------ # Macros for further automated spec %setup and patch application # default to plain patch %__scm patch # meh, figure something saner %__scm_username rpm-build %__scm_usermail %__scm_author %{__scm_username} %{__scm_usermail} # Plain patch (-m is unused) %__scm_setup_patch(q) %{nil} %__scm_apply_patch(qp:m:)\ %{__patch} %{-p:-p%{-p*}} %{-q:-s} --fuzz=%{_default_patch_fuzz} %{_default_patch_flags} # Mercurial (aka hg) %__scm_setup_hg(q)\ %{__hg} init %{-q} .\ %{__hg} add %{-q} .\ %{__hg} commit %{-q} --user "%{__scm_author}" -m "%{name}-%{version} base" %__scm_apply_hg(qp:m:)\ %{__hg} import - %{-p:-p%{-p*}} %{-q} -m %{-m*} --user "%{__scm_author}" # Git %__scm_setup_git(q)\ %{__git} init %{-q}\ %{__git} config user.name "%{__scm_username}"\ %{__git} config user.email "%{__scm_usermail}"\ %{__git} add .\ %{__git} commit %{-q} -a\\\ --author "%{__scm_author}" -m "%{name}-%{version} base" %__scm_apply_git(qp:m:)\ %{__git} apply --index %{-p:-p%{-p*}} -\ %{__git} commit %{-q} -m %{-m*} --author "%{__scm_author}" # Git, using "git am" (-m is unused) %__scm_setup_git_am(q)\ %{expand:%__scm_setup_git %{-q}} %__scm_apply_git_am(qp:m:)\ %{__git} am %{-q} %{-p:-p%{-p*}} # Single patch application %apply_patch(qp:m:)\ %{lua:\ local file = rpm.expand("%{1}")\ 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.."\\n"))\ else\ print("echo 'Cannot read "..file.."'; exit 1;".."\\n")\ end} # Automatically apply all patches %autopatch(vp:)\ %{lua:\ local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")\ for i, p in ipairs(patches) do\ print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..options..p.."\\n"))\ end} # One macro to (optionally) do it all. # -S Sets the used patch application style, eg '-S git' enables # usage of git repository and per-patch commits. # -N Disable automatic patch application # -p Use -p for patch application %autosetup(a:b:cDn:TvNS:p:)\ %setup %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{!-v:-q}\ %{-S:%global __scm %{-S*}}\ %{-S:%{expand:%__scm_setup_%{-S*} %{!-v:-q}}}\ %{!-N:%autopatch %{-v} %{-p:-p%{-p*}}} # \endverbatim #*/