[Rpm-maint] [rpm-software-management/rpm] set a %_specfile macro during build, holding full path to spec file (#202)

proyvind notifications at github.com
Tue Apr 25 16:33:44 UTC 2017


https://github.com/proyvind/rpm/blob/pyspec/python/rpm/generate.py

I'm using it in the python module spec generator (dependent on rpminterp PR, pyspec branch depends on _specfile which is why a new branch were created), where the python script reads the spec file to determine what sections etc. that is defined in the spec or not.

This allows for overriding defaults from the generated spec easily as a regular spec without having to pass extra arguments to the pyspec() function generating the spec.

Default pyspec() example:
$ cat ~/rpmbuild/SPECS/python-pyliblzma.spec 
%{python:pyspec("pyliblzma")}

$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec 
Name:           python-pyliblzma
Version:        0.5.3
Release:        1
Summary:        Python bindings for liblzma
Source0:        https://pypi.python.org/packages/17/48/5292ade507dafe573360560ba53783395587dc42eb32b347feb2ac70fc6b/pyliblzma-0.5.3.tar.bz2
License:        LGPLv3
Group:          Development/Python
Url:            https://launchpad.net/pyliblzma
BuildRequires:  pkgconfig(python-2.7) python-setuptools

%description
PylibLZMA provides a python interface for the liblzma library.
        to read and write data that has been compressed or can be decompressed
        by Lasse Collin's xz / lzma utils.

%prep
%setup -qDTn pyliblzma-0.5.3

%build
CFLAGS='-O2 -g' python2 setup.py  build --executable='python2 -s'

%install
CFLAGS='-O2 -g' python2 setup.py  install -O1 --skip-build --root /home/peroyvind/rpmbuild/BUILDROOT/python-pyliblzma-0.5.3-1.x86_64

%check
python2 setup.py test

%files
%doc COPYING
%doc NEWS
%doc THANKS
/usr/lib64/python2.7/site-packages/liblzma.py*
/usr/lib64/python2.7/site-packages/lzma.so
/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info

Example with custom sections:
cat ~/rpmbuild/SPECS/python-pyliblzma.spec 
Patch0: somepatch.patch
Version: 0.5.2
Release: 2

%{python:pyspec("pyliblzma")}


%build
whoopidoopidoo

%install
somestufff

%check
someotherstuff

$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec
Patch0: somepatch.patch
Version: 0.5.2
Release: 2

Name:           python-pyliblzma
Summary:        Python bindings for liblzma
Source0:        https://pypi.python.org/packages/79/d7/2ca6de56df030a6be411b664e48cee3a3feaf1312bfa9556fd9abab4dcd1/pyliblzma-0.5.2.tar.bz2
License:        LGPLv3
Group:          Development/Python
Url:            https://launchpad.net/pyliblzma
BuildRequires:  pkgconfig(python-2.7) python-setuptools

%description
PylibLZMA provides a python interface for the liblzma library.
        to read and write data that has been compressed or can be decompressed
        by Lasse Collin's xz / lzma utils.

%prep
%setup -qDTn pyliblzma-0.5.2
/bin/cat /home/peroyvind/rpmbuild/SOURCES/somepatch.patch | 
/bin/patch -p1 -s --fuzz=0 -s -U

%files
%doc COPYING
%doc NEWS
%doc THANKS
/usr/lib64/python2.7/site-packages/liblzma.py*
/usr/lib64/python2.7/site-packages/lzma.so
/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info


%build
whoopidoopidoo

%install
somestufff

%check
someotherstuff


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/202#issuecomment-297088253
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170425/ece06101/attachment.html>


More information about the Rpm-maint mailing list