Пакет rpm-build-spec2macro: Specfile

%define _name spec2macro

Name: rpm-build-%_name
Version: 0.2
Release: alt1

Summary: Convert specfile macros from specfile to rpmmacros file format
License: GPLv2
Group: Development/Other

BuildArch: noarch

%description
This package is used with RPM specfiles. If you do not build software from sources, you don't need this package.

This package contains spec2macro RPM macro that takes a file with a set of macro %%definitions and converts it to a file that can be put to /etc/rpm/macros.d/ directory. It is useful when you want to use a macro in your specfile and at the same time to install this macro from this specfile to /etc/rpm/macros.d/. A simple example (can be inserted in your specfile) follows. First, you include the file with definitions to use in your own spec:

Source10: mymacros.spec

BuildPreReq: rpm-build-spec2macro

%%%%include %%%%SOURCE10

And then, in %%install section, you install these definitions:

mkdir -p %%buildroot%%_sysconfdir/rpm/macros.d
%%spec2macro %%%%SOURCE10 >%%buildroot%%_sysconfdir/rpm/macros.d/mymacros

%install
cat <<__EOF__ >%_name.rpmmacros
%%spec2macro() sed -e 's/^%%%%define[[:space:]]\\\\+/%%%%/' -e 's/^#%%%%%%%%/%%%%/' %%1 >%%2
__EOF__
install -D -m644 %_name.rpmmacros %buildroot/%_sysconfdir/rpm/macros.d/%_name

%files
%_sysconfdir/rpm/macros.d/%_name

%changelog
* Tue Jul 03 2007 Alexey Rusakov <ktirf@altlinux.org> 0.2-alt1
- escape + in the sed script properly.

* Tue Jul 03 2007 Alexey Rusakov <ktirf@altlinux.org> 0.1-alt1
- Initial version