File openclipart.spec of Package openclipart

#
# spec file for package openclipart
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define _tarver 2.0
Name:           openclipart
Version:        0.20
Release:        0
Summary:        Open Clip Art Library
License:        SUSE-Public-Domain
Group:          Productivity/Graphics/Other
Url:            http://www.openclipart.org/
Source0:        ftp://ftp.osuosl.org/pub/openclipart/downloads/%{_tarver}/%{name}-%{_tarver}.tar.bz2
BuildRequires:  fdupes
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
An extensive set of clip art graphics that can be used for free.

%package svg
Summary:        Open Clip Art Library in the SVG File Format
License:        SUSE-Public-Domain
Group:          Productivity/Graphics/Other

%description svg
An extensive set of clip art graphics that can be used for free.

This package includes the pictures in the original SVG graphics file
format.

%package png
Summary:        Open Clip Art Library in the PNG File Format
License:        SUSE-Public-Domain
Group:          Productivity/Graphics/Other
Provides:       openclipart = %{version}
Obsoletes:      openclipart < %{version}

%description png
An extensive set of clip art graphics that can be used for free.

This package includes the pictures converted to the PNG graphics file
format.

%prep
%setup -q -c
# tarball is packed really poorly
find ./ -type d |xargs -i chmod +x {}
mv %{name}-%{version}/* ./
rm -rf %{name}-%{version}/

%build
# Compress all the svg images as it is possible and eats up less space
echo "Compressing SVG files..."
find -name "*.svg" -print0 | xargs -L 1 -0 \
    bash -c 'gzip -9c "${1}" > "${1}z"; rm -f "${1}"' --
# Remove pngz as they are not actually that smaller anyway
find -name "*.pngz" | xargs -i rm {}

%install
mkdir -p %{buildroot}%{_datadir}/clipart/%{name}/
cp -r . %{buildroot}%{_datadir}/clipart/%{name}/
# file lists
for suffix in png svgz; do
    find %{buildroot}%{_datadir}/clipart -type d | sed "s|^%{buildroot}\(.*\)$|%dir \"\1\"|" >files.$suffix
    find %{buildroot}%{_datadir}/clipart -name "*.$suffix" | sed "s|^%{buildroot}\(.*\)$|\"\1\"|" >>files.$suffix
done
%fdupes -s %{buildroot}%{_datadir}/clipart

%files -f files.svgz svg
%defattr(-, root,root)

%files -f files.png png
%defattr(-, root,root)

%changelog