File check.spec of Package libkdepimlibs4-abi-check
#
# 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 libkdepimlibs4
#%define unstablelibs
Name: %{pkgname}-abi-check
BuildRequires: abi-compliance-checker %{pkgname}-abi-last %{pkgname}-abi-current
License: Same as %{pkgname}
#Url:
Group: Development/Tools/Other
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: ABI check for %{pkgname}
%define oldversion %(rpm -q --qf "%{VERSION}" %{pkgname}-abi-last)
%define newversion %(rpm -q --qf "%{VERSION}" %{pkgname}-abi-current)
Version: %{newversion}
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
echo PACKAGE %{pkgname} REPORT: >summary.txt
echo =========================================================== >>summary.txt
rpm -ql %{pkgname}-abi-last | grep -F 'descriptor.xml' | sed 's#.*/\([^/]*\)/descriptor\.xml#\1#' >dirs-last.txt
rpm -ql %{pkgname}-abi-current | grep -F 'descriptor.xml' | sed 's#.*/\([^/]*\)/descriptor\.xml#\1#' >dirs-current.txt
grep -q '^stable$' dirs-last.txt && lasthasstable=1
grep -q '^stable$' dirs-current.txt && currenthasstable=1
if test -n "$lasthasstable" -a -z "$currenthasstable"; then
echo Stable libraries have been removed.
exit 1
fi
test -n "$currenthasstable" && stable=stable
for part in $stable `cat dirs-last.txt | grep -F 'unstable-' | sed 's/unstable-//'`; do
if test "$part" = "stable"; then
dir=stable
else
dir=unstable-${part}
fi
grep -q $dir dirs-current.txt || continue
mkdir $dir
pushd $dir
cat `rpm -ql %{pkgname}-abi-last | grep -F "/$dir/descriptor.xml"` >descriptor1.xml
cat `rpm -ql %{pkgname}-abi-current | grep -F "/$dir/descriptor.xml"` >descriptor2.xml
cat descriptor1.xml | grep -A 100000 -F '<libs>' | grep -B 100000 -F '</libs>' \
| grep -v -F '<libs>' | grep -v -F '</libs>' | sed 's/\(\.so\.[0-9]\+\)\..*/\1/' | sed 's#^.*/\([^/]*\)#\1#' | sort >libs1.txt
cat descriptor2.xml | grep -A 100000 -F '<libs>' | grep -B 100000 -F '</libs>' \
| grep -v -F '<libs>' | grep -v -F '</libs>' | sed 's/\(\.so\.[0-9]\+\)\..*/\1/' | sed 's#^.*/\([^/]*\)#\1#' | sort >libs2.txt
if test "$dir" = "stable"; then
# check for removed headers and libraries from the stable set
removedlibs=`diff -u0 libs1.txt libs2.txt | grep '^-' | grep -v '^---' | sed 's/^-//'`
if test -n "$removedlibs"; then
echo Removed libraries: $removedlibs
exit 1
fi
cat descriptor1.xml | grep -A 100000 -F '<headers>' | grep -B 100000 -F '</headers>' | sort > headers1.txt
cat descriptor2.xml | grep -A 100000 -F '<headers>' | grep -B 100000 -F '</headers>' | sort > headers2.txt
if test -n "%{?unstableheaders:}"; then
( cat headers1.txt | grep -v %{?unstableheaders} > stableheaders1.txt ) || true
( cat headers2.txt | grep -v %{?unstableheaders} > stableheaders2.txt ) || true
else
cat headers1.txt > stableheaders1.txt
cat headers2.txt > stableheaders2.txt
fi
removedheaders=`diff -u0 stableheaders1.txt stableheaders2.txt | grep '^-' | grep -v '^---' | sed 's/^-//'`
if test -n "$removedheaders"; then
echo Removed headers: $removedheaders
exit 1
fi
localfail=
abi-compliance-checker.pl -l %{pkgname} -d1 `rpm -ql %{pkgname}-abi-last | grep -F "/$dir/%{pkgname}.abi."` \
-d2 `rpm -ql %{pkgname}-abi-current | grep -F "/$dir/%{pkgname}.abi."` || localfail=1
if test -n "$localfail"; then
echo === SECTION: $dir === >report.html
echo === HTML REPORT BEGIN === >>report.html
cat compat_reports/%{pkgname}/%{oldversion}_to_%{newversion}/abi_compat_report.html >>report.html
echo >>report.html
echo === HTML REPORT END === >>report.html
cat report.html
echo Section $dir: INCOMPATIBLE >>../summary.txt
fail=1
else
echo Section $dir: COMPATIBLE >>../summary.txt
fi
else # unstable parts
localfail=
abi-compliance-checker.pl -l %{pkgname} -d1 `rpm -ql %{pkgname}-abi-last | grep -F "/$dir/%{pkgname}.abi."` \
-d2 `rpm -ql %{pkgname}-abi-current | grep -F "/$dir/%{pkgname}.abi."` || localfail=1
if test -n "$localfail"; then
lib1=`cat libs1.txt | sed "s/\(lib${part}\.so\.[0-9]*\)\.*/\1/"`
lib2=`cat libs2.txt | sed "s/\(lib${part}\.so\.[0-9]*\)\.*/\1/"`
echo X $lib1 $lib2
if test "$lib1" = "$lib2"; then
echo === SECTION: $dir === >report.html
echo === SONAME CHANGE NEEDED === >>report.html
echo === HTML REPORT BEGIN === >>report.html
cat compat_reports/%{pkgname}/%{oldversion}_to_%{newversion}/abi_compat_report.html >>report.html
echo >>report.html
echo === HTML REPORT END === >>report.html
cat report.html
fail=1
echo Section $dir: INCOMPATIBLE, SONAME CHANGE NEEDED >>../summary.txt
else
echo Section $dir: SONAME CHANGED >>../summary.txt
fi
else
echo Section $dir: COMPATIBLE >>../summary.txt
fi
fi
popd
done
echo =========================================================== >>summary.txt
cat summary.txt
test -n "$fail" && exit 1
%install
DESTDIR=%{?buildroot:%{buildroot}}
mkdir -p $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}
for dir in `ls -1F | grep '.*/$' | sed 's#/##'`; do
mkdir -p $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/${dir}
cp -p ${dir}/compat_reports/%{pkgname}/*/abi_compat_report.html $DESTDIR/%{_libdir}/abi-compliance-checker/%{pkgname}/${dir}/%{oldversion}-%{newversion}.xml
done
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{_libdir}/abi-compliance-checker/%{pkgname}
%changelog