# # autosetup v0.01 # # Crazy rpm macros to further automate %setup and especially %patch # work + integration with git & mercurial. # %autosetup is intended as a drop-in replacement for %setup and # supports everything that %setup does but unlike %setup, # runs quietly by default (for verbose mode, use -v). Additionally # it can automatically setup git/hg repository in the build directory # when -S is used, eg '%autosetup -S git' to create git repository. # Another new option compared to %setup is -A, which automatically # applies all patches to the unpacked source (requires all patches # to be applicaple with -p1, if not %autopatch can be called separately # with appropriate -p). If git/hg repository was set up,, # patches are added as separate commits for easy bisecting etc. %__scm_author rpm-build # Plain patch %__scm_apply_patch(qp:m:)\ %{__patch} %{!-p:-p1}%{-p} %{-q:-s} # Mercurial (aka hg) %__hg %{_bindir}/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} %{-q} %{-m} --user "%{__scm_author}" # Git %__git %{_bindir}/git %__scm_setup_git(q)\ %{__git} init %{-q}\ %{__git} add .\ %{__git} commit %{-q} -a\\\ --author "%{__scm_author}" -m "%{name}-%{version} base" %__scm_apply_git(qp:m:)\ %{__git} apply %{-p} -\ %{__git} commit %{-q} -a %{-m} --author "%{__scm_author}" %apply_patch(qp:m:)\ %{uncompress:%{1}} | %{expand:%__scm_apply_%{__scm} %{-q} %{-p} %{-m}} %autopatch(vp:)\ %{lua:\ for i, p in ipairs(patches) do\ print(rpm.expand("%apply_patch "..rpm.expand("%{!-v:-q} %{-p} -m '%{basename:"..p.."}' ")..p.."\\n"))\ end} %autosetup(a:b:cDn:TvAS:)\ %setup %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{!-v:-q}\ %{-S:%global __scm %{-S*}}%{!-S:%global __scm patch}\ %{-S:%{expand:%__scm_setup_%{-S*} %{!-v:-q}}}\ %{-A:%autopatch %{-v}}