File abi.spec of Package soname-abi-current

#
# Copyright (c) 2010 Lubos Lunak <l.lunak@suse.cz>
#
# 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 soname
%define pkgdevelname %{pkgname}-devel
%define unstablelibs soname

Name:           %{pkgname}-abi-current
BuildRequires:  %{pkgdevelname} abi-compliance-checker
License:        Same as %{pkgname}
#Url:            
Group:          Development/Tools/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Summary:        ABI for %{pkgname}
Version:        %(rpm -q --qf "%{VERSION}" %{pkgdevelname})
Release:        1

%description
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.

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

%build
    for part in stable %{?unstablelibs:%{unstablelibs}}; do
        mkdir $part
        pushd $part
        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 %{pkgdevelname} \
                | grep /include/ \
            `; do
            if test -f "$header"; then
                echo $header >> descriptor.xml
            fi
        done
        echo '</headers>' >> descriptor.xml
        echo '<libs>' >> descriptor.xml
        if test "$part" = "stable"; then
            rpm -ql %{pkgdevelname} | grep /%{_lib} | grep \.so >libs.txt
            for other in %{?unstablelibs:%{unstablelibs}}; do
                cat libs.txt | grep -v lib"$other"\.so >libs2.txt
                mv libs2.txt libs.txt
            done
            if test -z "`cat libs.txt`"; then
                popd
                rm -r $part
            fi
        else
            rpm -ql %{pkgdevelname} | grep /%{_lib} | grep \.so | grep lib"$part"\.so >libs.txt
        fi
        for lib in `cat libs.txt`; do
            readlink -e "$lib" >> descriptor.xml
        done
        echo '</libs>' >> descriptor.xml
        abi-compliance-checker.pl -l %{pkgname} -dump descriptor.xml || fail=1
        if test -n "$fail"; then
            cat logs/%{pkgname}/%{version}/log
            exit 1
        fi
        popd
    done

%install
    DESTDIR=%{?buildroot:%{buildroot}}
    mkdir -p $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}
    for part in stable %{?unstablelibs:%{unstablelibs}}; do
        test -d "$part" || continue
        if test "$part" = "stable"; then
            dir=stable
        else
            dir=unstable-${part}
        fi
        mkdir -p $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}/${dir}
        cp -p ${part}/descriptor.xml $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}/${dir}/descriptor.xml
        cp -p ${part}/abi_dumps/%{pkgname}/%{pkgname}_%{version}.abi.tar.gz $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}/${dir}/%{pkgname}.abi.tar.gz
        gzip --best -c ${part}/logs/%{pkgname}/%{version}/log > $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/%{version}/${dir}/log.txt.gz
    done

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_libdir}/abi-compliance-checker/%{pkgname}

%changelog
openSUSE Build Service is sponsored by