File abi.spec of Package headers-abi-current

# Copyright (c) 2010 Lubos Lunak <>
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# norootforbuild

%define pkgname headers
%define pkgdevelnames headers-devel

Name:           %{pkgname}-abi-current
BuildRequires:  %{pkgdevelnames} abi-compliance-checker
License:        Same as %{pkgname}
Group:          Development/Tools/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Summary:        ABI for %{pkgname}
Version:        %(rpm -q --qf "%{VERSION}" `echo %{pkgdevelnames} | awk '{ print $1 }'`)
Release:        1

This package contains ABI information for %{pkgname} that can be used with abi-compliance checker.
When a new version of the package is released, the ABI of that package can be checked for backwards
compatibility using this information.

%setup -c -n %{name}-%{version} -T -q

    echo '<version>' > descriptor.xml
    echo %{version} >> descriptor.xml
    echo '</version>' >> descriptor.xml
    echo '<headers>' >> descriptor.xml
# add grep -v header here to skip unwanted headers (broken, for example)
    for header in `rpm -ql %{pkgdevelnames} \
            | grep /include/ \
        `; do
        if test -f "$header"; then
            echo $header >> descriptor.xml
    echo '</headers>' >> descriptor.xml
    echo '<libs>' >> descriptor.xml
    rpm -ql %{pkgdevelnames} | grep -e /%{_lib} >> descriptor.xml
    echo '</libs>' >> descriptor.xml -l %{pkgname} -dump descriptor.xml || fail=1
    if test -n "$fail"; then
        cat logs/%{pkgname}/%{version}/log
        exit 1

    mkdir -p $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}
    cp -p descriptor.xml $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}-descriptor.xml
    cp -p abi_dumps/%{pkgname}/%{pkgname}_%{version}.abi.tar.gz $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}.abi.tar.gz
    gzip --best -c logs/%{pkgname}/%{version}/log > $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}-log.txt.gz