Blob Blame History Raw
%global __provides_exclude_from ^%{_libdir}/fcitx5/.*\\.so$

%global server_dir %{_libexecdir}/fcitx5-mozc

Name:           fcitx5-mozc
%global forgeurl
%global commit 242b4f703cba27d4ff4dc123c713a478f964e001
%global archivename %{name}-%{commit}

Version:        2.17.2102.102.1
# upstream don't tag release, build git snapshot here
# git snaoshot should have s snapshot date will be taken care
# of by forgemeta after importing to dist-git
Release:        %autorelease
Summary:        A wrapper of mozc for fcitx5
# fcitx5-mozc is a fork of mozc, difference can be seen at 
# src/third_party/abseil-cpp : Apache License
# src/third_party/breakpad : BSD License
# src/third_party/japanese_usage_dictionary: BSD license
# src/third_party/wtl: MS-PL
# src/unix/fcitx5: LGPLv2+
# ----
# data/unicode/: UCD
#  Copyright (c) 1991-2008 Unicode, Inc.
# data/test/stress_test/sentences.txt: Public Domain
# data/dictionary_oss/: mecab-ipadic and BSD
#   See
#   also data/installer/credits_en.html
# src/data/test/dictionary/: same as data/dictionary_oss
License:        BSD and ASL 2.0 and UCD and Public Domain and mecab-ipadic and LGPLv2+ and MS-PL
URL:            %{forgeurl}

# The source of this package was pulled from upstreams's vcs.
# Use the following command to generate the tar ball:
# with gtest gyp jsoncpp protobuf unbundled 
# abseil-cpp is left here due to hardcoded build scripts from
# upstream code.
# -----
# git clone --recursive --depth 1
# cd mozc
# git checkout %%{commit}
# for i in gtest gyp jsoncpp protobuf ; do rm -rf src/third_party/$i; done
# cd ..
# tar --exclude-vcs -czf %%{name}-%%{commit}.tar.gz mozc/
# -----
Source0:        %{name}-%{commit}.tar.gz
# Public Domain

# add -v to ninja command, to make verbose output during building
Patch0:         mozc-build-verbosely.patch
Patch1:         0001-use-system-absl.patch

BuildRequires:  python3-devel
BuildRequires:  gettext 
BuildRequires:  gtk2-devel
BuildRequires:  qt5-qtbase-devel
BuildRequires:  zinnia-devel
BuildRequires:  gcc-c++
BuildRequires:  ninja-build
BuildRequires:  gyp >= 0.1-0.4.840svn
BuildRequires:  fcitx5-devel
BuildRequires:  libappstream-glib
BuildRequires:  %{py3_dist six}
BuildRequires:  protobuf-devel 
BuildRequires:  protobuf-c
BuildRequires:  abseil-cpp-devel
BuildRequires:  gtest-devel
BuildRequires:  jsoncpp-devel
BuildRequires:  binutils

Requires:       hicolor-icon-theme
Requires:       fcitx5
Requires:       fcitx5-data

# we are using mostly exact mozc server, same problem
# may occur here, adding ExcludeArch like ibus-mozc
ExcludeArch:    ppc ppc64 sparcv9 sparc64 s390x

A wrapper of mozc for fcitx5.

%setup -q -n mozc -a 1 -a 2
%patch 0 -p1
%patch 1 -p1
(cd src/data/dictionary_oss;
PYTHONPATH="${PYTHONPATH}:../../" python3 ../../dictionary/ --zip_code=../../../KEN_ALL.CSV --jigyosyo=../../../JIGYOSYO.CSV >> dictionary09.txt;
# Don't build for fcitx4
rm src/unix/fcitx/fcitx.gyp
# building with gcc, change to add -lc++
sed "/stdlib=libc++/d;/-lc++/d" -i src/gyp/common.gypi
sed "s/clang++/c++/g" -i src/gyp/common.gypi
sed "s/clang/gcc/g" -i src/gyp/common.gypi
# preserve install time stamp
sed "s/ -m/ -pm/g" -i scripts/install_fcitx5 scripts/install_fcitx5_icons

pushd src
# specify an another path for those mozc server files
# to enable this to co-exist with ibus-mozc
QTDIR=%{_prefix} \
GYP_DEFINES="document_dir=%{_datadir}/licenses/%{name} use_libzinnia=1 use_system_abseil_cpp=1 use_libprotobuf=1 zinnia_model_file=%{_datadir}/zinnia/model/tomoe/handwriting-ja.model" \
python3 gyp --gypdir=%{_bindir} --server_dir=%{server_dir} --target_platform=Linux
python3 build -c Release server/server.gyp:mozc_server gui/gui.gyp:mozc_tool unix/fcitx5/fcitx5.gyp:fcitx5-mozc

pushd src
export _bldtype=Release
install -D -pm 755 "out_linux/${_bldtype}/mozc_server" "%{buildroot}%{server_dir}/mozc_server"
install -D -pm 755 "out_linux/${_bldtype}/mozc_tool"   "%{buildroot}%{server_dir}/mozc_tool"
# fix install dirs in script, don't use those hardcoded paths: 
# ${PREFIX}/share/metainfo -> _metainfodir
sed "s|\${PREFIX}/share/metainfo|%{buildroot}%{_metainfodir}|g" -i  ../scripts/install_fcitx5 ../scripts/install_fcitx5_data
# ${PREFIX}/share -> _datadir
sed "s|\${PREFIX}/share|%{buildroot}%{_datadir}|g"              -i  ../scripts/install_fcitx5 ../scripts/install_fcitx5_icons ../scripts/install_fcitx5_data
# ${PREFIX}/lib -> _libdir
sed "s|\${PREFIX}/lib|%{buildroot}%{_libdir}|g"                 -i  ../scripts/install_fcitx5

appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.metainfo.xml

%find_lang %{name}

%files -f %{name}.lang
%license LICENSE 
%doc src/data/installer/*.html