File libpinyin.spec of Package libpinyin
#
# spec file for package libpinyin
#
# 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 lname libpinyin4
Name: libpinyin
Version: 1.0.0
Release: 0
Summary: Intelligent Pinyin IME
License: GPL-2.0+
Group: System/I18n/Chinese
Url: https://github.com/libpinyin/libpinyin
Source: %{name}-%{version}.tar.gz
Source1: model7.text.tar.gz
Source99: baselibs.conf
# PATCH-FIX-OPENSUSE marguerite@opensuse.org - avoid download at buildtime
Patch: libpinyin-1.0.0-avoid_download_at_buildtime.patch
BuildRequires: gcc-c++
BuildRequires: glib2-devel
BuildRequires: gnome-common
BuildRequires: intltool
%if 0%{?suse_version}
%if 0%{?suse_version} >= 1140
BuildRequires: libdb-4_8-devel
%else
BuildRequires: libdb-4_5-devel
%endif
%else
BuildRequires: libdb-devel
BuildRequires: libtool-ltdl-devel
%endif
BuildRequires: fdupes
BuildRequires: libtool
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Libpinyin is a staging joint effort of many Chinese Pinyin IME development teams.
It aims to be an Intelligent (and Universal) Sentence-based Pinyin IME Backend
supports many Language Models and Frontends.
%package -n %{lname}
Summary: Intelligent Pinyin IME
Group: System/Libraries
Requires: %{name}-data
Provides: %{name} = %{version}
Obsoletes: %{name} < %{version}
%description -n %{lname}
Libpinyin is a staging joint effort of many Chinese Pinyin IME development teams.
It aims to be an Intelligent (and Universal) Sentence-based Pinyin IME Backend
supports many Language Models and Frontends.
This package provides runtime library for libpinyin.
%package data
Summary: Data files for libpinyin
Group: System/I18n/Chinese
%description data
Libpinyin is a staging joint effort of many Chinese Pinyin IME development teams.
It aims to be an Intelligent (and Universal) Sentence-based Pinyin IME Backend
supports many Language Models and Frontends.
This package provides language model table data for libpinyin.
%package devel
Summary: Intelligent Pinyin IME
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}
Requires: %{name}-tools = %{version}
%description devel
Libpinyin is a staging joint effort of many Chinese Pinyin IME development teams.
It aims to be an Intelligent (and Universal) Sentence-based Pinyin IME Backend
supports many Language Models and Frontends.
%package tools
Summary: Tools for libpinyin
Group: System/I18n/Chinese
Requires(post): update-alternatives
Requires(postun): update-alternatives
%description tools
Libpinyin is a staging joint effort of many Chinese Pinyin IME development teams.
It aims to be an Intelligent (and Universal) Sentence-based Pinyin IME Backend
supports many Language Models and Frontends.
This package provides the tools used to make data files.
%prep
%setup -q
cp -r %{SOURCE1} data/
%patch -p1
./autogen.sh
%build
%configure --disable-static
make %{?_smp_mflags}
%install
%makeinstall
find %{buildroot}%{_libdir} -name "*.la" -type f -delete -print
# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for alt in gen_binary_files gen_unigram import_interpolation ; do
mv %{buildroot}%{_bindir}/${alt} %{buildroot}%{_bindir}/${alt}-pinyin
mv %{buildroot}%{_mandir}/man1/${alt}.1 %{buildroot}%{_mandir}/man1/${alt}-pinyin.1
touch %{buildroot}%{_sysconfdir}/alternatives/${alt}
touch %{buildroot}%{_sysconfdir}/alternatives/${alt}.1.gz
ln -sf %{_sysconfdir}/alternatives/${alt} %{buildroot}%{_bindir}/${alt}
ln -sf %{_sysconfdir}/alternatives/${alt}.1.gz %{buildroot}%{_mandir}/man1/
done
%if 0%{?suse_version}
%fdupes %{buildroot}
%else
fdupes -nqr %{buildroot}
%endif
%post -n %{lname} -p /sbin/ldconfig
%postun -n %{lname} -p /sbin/ldconfig
%post tools
update-alternatives \
--install %{_bindir}/gen_binary_files gen_binary_files %{_bindir}/gen_binary_files-pinyin 20 \
--slave %{_bindir}/gen_unigram gen_unigram %{_bindir}/gen_unigram-pinyin \
--slave %{_bindir}/import_interpolation import_interpolation %{_bindir}/import_interpolation-pinyin \
--slave %{_mandir}/man1/gen_binary_files.1.gz gen_binary_files.1.gz %{_mandir}/man1/gen_binary_files-pinyin.1.gz \
--slave %{_mandir}/man1/gen_unigram.1.gz gen_unigram.1.gz %{_mandir}/man1/gen_unigram-pinyin.1.gz \
--slave %{_mandir}/man1/import_interpolation.1.gz import_interpolation.1.gz %{_mandir}/man1/import_interpolation-pinyin.1.gz
%postun tools
if [ $1 -eq 0 ] ; then
update-alternatives --remove gen_binary_files %{_bindir}/gen_binary_files-pinyin
fi
%files -n %{lname}
%defattr(-,root,root)
%doc ChangeLog AUTHORS COPYING README
%{_libdir}/%{name}.so.*
%{_mandir}/man1/libpinyin.1.gz
%files tools
%defattr(-,root,root)
%{_bindir}/gen_binary_files
%{_bindir}/gen_unigram
%{_bindir}/import_interpolation
%{_bindir}/gen_binary_files-pinyin
%{_bindir}/gen_unigram-pinyin
%{_bindir}/import_interpolation-pinyin
%{_mandir}/man1/gen_binary_files.1.gz
%{_mandir}/man1/gen_unigram.1.gz
%{_mandir}/man1/import_interpolation.1.gz
%{_mandir}/man1/gen_binary_files-pinyin.1.gz
%{_mandir}/man1/gen_unigram-pinyin.1.gz
%{_mandir}/man1/import_interpolation-pinyin.1.gz
%ghost %{_sysconfdir}/alternatives/gen_binary_files
%ghost %{_sysconfdir}/alternatives/gen_unigram
%ghost %{_sysconfdir}/alternatives/import_interpolation
%ghost %{_sysconfdir}/alternatives/gen_binary_files.1.gz
%ghost %{_sysconfdir}/alternatives/gen_unigram.1.gz
%ghost %{_sysconfdir}/alternatives/import_interpolation.1.gz
%files data
%defattr(-,root,root)
%{_libdir}/%{name}
%files devel
%defattr(-,root,root)
%{_includedir}/%{name}-%{version}/
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%changelog