diff --git a/autosetup.macros b/autosetup.macros new file mode 100644 index 0000000..b0a0848 --- /dev/null +++ b/autosetup.macros @@ -0,0 +1,78 @@ + +#------------------------------------------------------------------------------ +# 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 +#*/ diff --git a/rpm.spec b/rpm.spec index ba52f0c..8d5e9e5 100644 --- a/rpm.spec +++ b/rpm.spec @@ -61,7 +61,7 @@ Summary: The RPM package management system Name: rpm Epoch: 1 Version: %{libver}.%{minorver} -Release: %{?prereldate:0.%{prereldate}.}74 +Release: %{?prereldate:0.%{prereldate}.}75 License: LGPLv2.1+ Group: System/Configuration/Packaging Url: http://rpm5.org/ @@ -78,6 +78,7 @@ Source2: rpm.rpmlintrc Source3: cpu-os-macros.tar.gz Source4: legacy_compat.macros Source5: RPMBDB-0.1.tar.xz +Source6: autosetup.macros # add squirrel3 support Patch0: rpm-5.4.10-squirrel3.patch # add makeinstall_qt macro to handle install from qmake-generated makefiles @@ -1386,6 +1387,7 @@ mv %{buildroot}%{_bindir}/rpm %{buildroot}/bin/rpm cp -r cpu-os-macros %{buildroot}%{_usrlibrpm}/platform install -m644 %{SOURCE4} -D %{buildroot}%{_sysconfdir}/%{name}/macros.d/legacy_compat.macros +install -m644 %{SOURCE6} -D %{buildroot}%{_sysconfdir}/%{name}/macros.d/autosetup.macros %if %{with docs} install -d %{buildroot}%{_docdir}/rpm