fcitx/fcitx.spec

252 lines
6.7 KiB
RPMSpec

#
# spec file for package fcitx
#
# Copyright (c) 2012 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 libver -4_2_0
Name: fcitx
Version: 4.2.2
Release: 1
Summary: A Flexible Input Method Framework for CJK
Url: http://code.google.com/p/fcitx
Group: System/I18n/Chinese
License: GPL-2.0+
Source: http://fcitx.googlecode.com/files/%{name}-%{version}.tar.xz
Source1: xim.d-fcitx
Source2: fcitx-README.suse
Source3: xim.fcitx.suse.template
Source5: pinyin.tar.gz
Source6: table.tar.gz
Patch1: fix_fcitx_googlecode_resolv_error.patch
BuildRequires: xz
BuildRequires: cairo-devel
BuildRequires: pango-devel
BuildRequires: dbus-1-devel
BuildRequires: dbus-1-glib-devel
BuildRequires: update-desktop-files
BuildRequires: fdupes
BuildRequires: libqt4-devel
BuildRequires: opencc-devel
BuildRequires: intltool
BuildRequires: cmake
BuildRequires: gtk2-devel
BuildRequires: gtk3-devel
BuildRequires: gcc-c++
BuildRequires: libicu-devel
Requires: lib%{name}%{libver} = %{version}-%{release}
Requires: %{name}-gtk2 = %{version}-%{release}
Requires: %{name}-gtk3 = %{version}-%{release}
Requires: %{name}-qt4 = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
FCITX is a simplified Chinese input server. It supports Tables,
Pinyin and QuWei input method. It's small and fast.
Since version 4.1, FCITX itself can be use as an im-module. XIM
can still be used but not necessary.
%package -n lib%{name}%{libver}
Summary: Shared Libraries for %{name}
Group: System/I18n/Chinese
%description -n lib%{name}%{libver}
The libfcitx4_2_0 package includes the shared libraries for the fictx package.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}-%{release}
%description devel
The fcitx-devel package includes the header files for the fcitx package.
%package gtk2
Summary: Gtk2 IM Module for %{name}
Group: System/I18n/Chinese
Requires: %{name} = %{version}-%{release}
%gtk2_immodule_requires
%description gtk2
This package contains fcitx im module for gtk2
%package gtk3
Summary: Gtk3 IM Module for %{name}
Group: System/I18n/Chinese
Requires: %{name} = %{version}-%{release}
%gtk3_immodule_requires
%description gtk3
This package contains fcitx im module for gtk3
%package qt4
Summary: Qt4 IM Module for %{name}
Group: System/I18n/Chinese
Requires: %{name} = %{version}-%{release}
%description qt4
This package contains fcitx im module for qt4
%prep
%setup -q -n %{name}-%{version}
%patch1 -p1
%build
mkdir build
cd build
cmake .. -DENABLE_GTK2_IM_MODULE=On \
-DENABLE_GTK3_IM_MODULE=On \
-DENABLE_QT_IM_MODULE=On \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DLIB_INSTALL_DIR=%{_libdir} \
-DENABLE_DEBUG=On \
-DENABLE_OPENCC=On
#copy external data
pushd ../data
cp -r %{S:5} ./
popd
pushd ../data/table
cp -r %{S:6} ./
popd
make
%install
cd build
make DESTDIR=$RPM_BUILD_ROOT install
cd ..
#fix desktop file
sed -i "2d" %{buildroot}%{_datadir}/applications/fcitx-skin-installer.desktop
sed -i "2iMimeType=applicatio\/x-fskin;" %{buildroot}%{_datadir}/applications/fcitx-skin-installer.desktop
%suse_update_desktop_file fcitx Utility DesktopUtility
%suse_update_desktop_file fcitx-skin-installer Utility DesktopUtility
%suse_update_desktop_file fcitx-configtool System X-SuSE-SystemSetup
#fix doc
%{__rm} -rf %{buildroot}%{_datadir}/doc/%{name}/
#create autostart
mkdir -p %{buildroot}%{_sysconfdir}/X11/xim.d/
install -m 644 %{S:1} %{buildroot}%{_sysconfdir}/X11/xim.d/fcitx
pushd %{buildroot}%{_sysconfdir}/X11/xim.d/
for lang in en zh_CN ; do
mkdir $lang
pushd $lang
ln -s ../fcitx 30-fcitx
popd
done
popd
#remove *.la
%{__rm} -rf %{buildroot}%{_libdir}/lib%{name}-config.la
%find_lang %{name}
%fdupes %{buildroot}
#strip libraries
%{__strip} %{buildroot}%{_libdir}/%{name}/*.so
%{__strip} %{buildroot}%{_libdir}/libfcitx*.so.*
%{__strip} %{buildroot}%{_libdir}/gtk-2.0/*/immodules/im-%{name}.so
%{__strip} %{buildroot}%{_libdir}/gtk-3.0/*/immodules/im-%{name}.so
%{__strip} %{buildroot}%{_libdir}/qt4/plugins/inputmethods/qtim-%{name}.so
#Convenient define for the scriplets
%if %{_lib} == lib64
%define _gtk2_query_immodules %{_bindir}/gtk-query-immodules-2.0-64
%define _gtk2_query_immodules_update_cache %{_gtk2_query_immodules} > %{_sysconfdir}/gtk-2.0/gtk64.immodules
%else
%define _gtk2_query_immodules %{_bindir}/gtk-query-immodules-2.0
%define _gtk2_query_immodules_update_cache %{_gtk2_query_immodules} > %{_sysconfdir}/gtk-2.0/gtk.immodules
%endif
%if %{_lib} == lib64
%define _gtk3_query_immodules %{_bindir}/gtk-query-immodules-3.0-64
%else
%define _gtk3_query_immodules %{_bindir}/gtk-query-immodules-3.0
%endif
%define _gtk3_query_immodules_update_cache %{_gtk3_query_immodules} --update-cache
%post gtk2
%{_gtk2_query_immodules_update_cache}
%post gtk3
%{_gtk3_query_immodules_update_cache}
#Add fcitx icons to gnome3 panel
TARGET="/usr/share/gnome-shell/js/ui/statusIconDispatcher.js"
if [ -f $TARGET ] && [ ! -f $TARGET-fcitx ] ; then
mv $TARGET $TARGET-fcitx
sed "/^const STANDARD_TRAY_ICON_IMPLEMENTATIONS/a \ 'fcitx': 'input-method'," $TARGET-fcitx > $TARGET
fi
%postun gtk2
%{_gtk2_query_immodules_update_cache}
%postun gtk3
%{_gtk3_query_immodules_update_cache}
%post -p /sbin/ldconfig
%post -n lib%{name}%{libver} -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%postun -n lib%{name}%{libver} -p /sbin/ldconfig
%files -f %{name}.lang
%defattr(-,root,root)
%doc AUTHORS ChangeLog
%{_bindir}/*
%{_datadir}/%{name}/
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*
%{_datadir}/mime/packages/*
%{_mandir}/man1/*.gz
%{_libdir}/fcitx/
%config /etc/X11/xim.d/
%files -n lib%{name}%{libver}
%defattr(-,root,root)
%{_libdir}/libfcitx*.so.*
%{_libdir}/libfcitx*.so
%files gtk2
%defattr(-,root,root)
%{_libdir}/gtk-2.0/*
%files gtk3
%defattr(-,root,root)
%{_libdir}/gtk-3.0/*
%files devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/*.pc
%{_datadir}/cmake/
%{_includedir}/*
%files qt4
%defattr(-,root,root)
%{_libdir}/qt4/*
%changelog