%find_lang %{name} --all-name这个没起作用?


#1

发现没有把zh_CN的.mo文件打包到软件里面
添加%find_lang %{name} --all-name 虽然不用写那么多的.mo文件了
然而本地编译出来rpm2cpio 看了一下 根本就没有zh_CN的.mo文件
%find_lang %{name} --all-name这个没起作用?

而且这个时候还不能在%files里面添加自定义语言包的具体位置了 加了就报错 冲突
怎么才能让%find_lang %{name}起作用在把zh_CN包含进去?

spec文件内容 本地编译通过(Tumbleweed版本)

#
# spec file for package claws-mail
#
# Copyright (c) 2018 SUSE LINUX 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/
#


Name:           claws-mail
Version:        3.17.0git188
Release:        0
Summary:        A configurable email client 
License:        GPL-3.0+ 
Group:          Productivity/Networking/Email/Clients
Source0:        claws-mail-3.17.0git188.tar.xz
BuildRequires:  NetworkManager-devel
BuildRequires:  compface-devel
BuildRequires:  db-devel
BuildRequires:  enchant-devel
BuildRequires:  lynx
BuildRequires:  gettext
BuildRequires:  gmp-devel
BuildRequires:  libetpan-devel
BuildRequires:  libgtkhotkey-devel
BuildRequires:  libgnutls-devel
BuildRequires:  libgpgme-devel 
BuildRequires:  libarchive-devel
%if 0%{?favor_gtk2}
BuildRequires:  gtk2-devel
BuildRequires:  libcanberra-gtk-devel >= 0.6
%else
BuildRequires:  gtk3-devel
BuildRequires:  libcanberra-gtk3-devel >= 0.6
%endif
BuildRequires:  libcanberra-devel >= 0.6
BuildRequires:  libcurl-devel
BuildRequires:  libexpat-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libgdata-devel >= 0.17.2
BuildRequires:  libpoppler-glib-devel
BuildRequires:  librsvg-devel >= 2.40.5
BuildRequires:  openldap2-devel
BuildRequires:  pilot-link-devel
BuildRequires:  pkgconfig
BuildRequires:  python-gtk-devel
BuildRequires:  startup-notification-devel
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(dbus-1) >= 0.60
BuildRequires:  pkgconfig(dbus-glib-1) >= 0.60
BuildRequires:  pkgconfig(gnutls) >= 2.2
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(libsoup-2.4)
BuildRequires:  pkgconfig(sm)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       pinentry-gtk2
%{?libperl_requires}
Provides:       sylpheed-claws = %{version}
Obsoletes:      sylpheed-claws < %{version}


%description
Claws Mail (previously known as Sylpheed-Claws) is a
configurable email client and news reader based on the GTK+ GUI
toolkit, and it runs on the X Window System.

%package devel
Summary:        Development files for claws-mail
License:        GPL-2.0-or-later
Group:          Development/Libraries/C and C++
Provides:       claws-mail:/usr/include/claws-mail/main.h

Obsoletes:      claws-mail-extra-plugins-devel < %{version}
Provides:       claws-mail-extra-plugins-devel = %{version}
Requires:       claws-mail = %{version}
Requires:       enchant-devel
Requires:       glib2-devel
Requires:       gnutls-devel
Requires:       gpgme-devel
Requires:       gtk2-devel
Requires:       libetpan-devel
Requires:       pinentry-gtk2
Requires:       libpoppler-glib-devel
Requires:       openldap2-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description devel
Claws Mail (previously known as Sylpheed-Claws) is a
configurable email client and news reader based on the GTK+ GUI
toolkit, and it runs on the X Window System.

This package contains header files for building plugins.

%lang_package
%prep
%setup -q
sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python/' tools/*.py
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/*.sh
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/kdeservicemenu/install.sh


%build
%configure \
        --disable-static \
%if !(0%{?favor_gtk2})
        --enable-gtk3 \
%endif
        --enable-ldap \
        --enable-ipv6 \
        --enable-jpilot \
        --enable-acpi_notifier-plugin \
        --enable-address_keeper-plugin \
        --enable-att_remover-plugin \
        --enable-attachwarner-plugin \
        --enable-bogofilter-plugin \
        --enable-bsfilter-plugin \
        --enable-clamd-plugin \
        --disable-fancy-plugin \
        --enable-fetchinfo-plugin \
        --enable-mailmbox-plugin \
        --enable-newmail-plugin \
        --enable-notification-plugin \
        --enable-pdf_viewer-plugin \
        --enable-perl-plugin \
        --enable-pgpcore-plugin \
        --enable-pgpmime-plugin \
        --enable-pgpinline-plugin \
        --enable-rssyl-plugin \
        --enable-smime-plugin \
        --enable-spamassassin-plugin \
        --enable-spam_report-plugin \
        --disable-tnef_parse-plugin \
        --disable-vcalendar-plugin \
        --disable-demo-plugin \
        --enable-crash-dialog \
        --enable-startup-notification \
        --enable-compface \
        --enable-libetpan
make %{?_smp_mflags}

%install
%makeinstall

# Clean up
rm %{buildroot}%{_libdir}/claws-mail/plugins/*.la

# install desktop file
%suse_update_desktop_file claws-mail

# we want to have the icon installed in /usr/share/pixmaps
mkdir -p %{buildroot}%{_datadir}/pixmaps/
cp claws-mail-64x64.png %{buildroot}%{_datadir}/pixmaps/

# Tools
cp -r tools %{buildroot}%{_datadir}/%{name}

install -d %{buildroot}%{_sysconfdir}/skel/.claws-mail/
cat <<EOF > %{buildroot}%{_sysconfdir}/skel/.claws-mail/clawsrc
[Plugins_GTK2]
%{_libdir}/claws-mail/plugins/pgpcore.so
%{_libdir}/claws-mail/plugins/pgpinline.so
%{_libdir}/claws-mail/plugins/pgpmime.so
%{_libdir}/claws-mail/plugins/smime.so
EOF

%find_lang %{name} --all-name


%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root)
%{_bindir}/claws-mail
%{_bindir}/sylpheed-claws

%dir %{_libdir}/claws-mail
%dir %{_libdir}/claws-mail/plugins
%{_libdir}/claws-mail/plugins/*.so
%{_libdir}/claws-mail/plugins/*.deps

%{_datadir}/applications/claws-mail.desktop
%{_datadir}/icons/hicolor/*/apps/claws-mail.png
%{_datadir}/pixmaps/claws-mail-64x64.png

%dir %{_datadir}/claws-mail/
%{_datadir}/claws-mail/*.sh
%{_datadir}/claws-mail/*.pl
%{_datadir}/claws-mail/*.py
%{_datadir}/claws-mail/*.conf
%{_datadir}/claws-mail/Makefile*
%{_datadir}/claws-mail/README
%{_datadir}/claws-mail/alternative-tlds.txt
%{_datadir}/claws-mail/ca-certificates.crt
%{_datadir}/claws-mail/make.themes.project
%{_datadir}/claws-mail/bash_completion/
%{_datadir}/claws-mail/bash_completion/*
%{_datadir}/claws-mail/jhbuild/
%{_datadir}/claws-mail/jhbuild/*
%{_datadir}/claws-mail/tb2claws-mail
%{_datadir}/claws-mail/u*
%{_datadir}/claws-mail/kdeservicemenu/

%dir %{_datadir}/doc/
%dir %{_datadir}/doc/claws-mail/
%{_datadir}/doc/claws-mail/RELEASE_NOTES

%{_mandir}/man1/claws-mail.1.gz
%config(noreplace) %{_sysconfdir}/skel/.claws-mail/

%files devel
%defattr(-,root,root)
%dir %{_prefix}/include/
%dir %{_prefix}/include/claws-mail/
%{_prefix}/include/claws-mail/*.h
%dir %{_prefix}/include/claws-mail/common/
%{_prefix}/include/claws-mail/common/*.h
%dir %{_prefix}/include/claws-mail/etpan/
%{_prefix}/include/claws-mail/etpan/*.h
%dir %{_prefix}/include/claws-mail/gtk/
%{_prefix}/include/claws-mail/gtk/*.h
%dir %{_prefix}/include/claws-mail/plugins/
%dir %{_prefix}/include/claws-mail/plugins/pgpcore/
%{_prefix}/include/claws-mail/plugins/pgpcore/*.h

%dir %{_libdir}/pkgconfig/
%{_libdir}/pkgconfig/claws-mail.pc

%files lang -f %{name}.lang

%changelog


openSUSE-Gossip-20180925-20181231
#2

第一,你的 .po -> .mo 的过程 %find_lang 是不管的,也就是说它不会为你编译,需要你自己编译或者控制 claws-mail 的编译参数
第二,你的 .mo 得 install 到 %{buildroot}。
第三,你的 %{name} 是 claws-mail,你的 .mo 的名字也得是 claw-mail.mo。

另外你的 specfile 还有很多问题,见注释:

%package devel
# 这行是没有用的。Provides 就是一个字符串。如果你不是
# 在别的包里 Requires: claws-mail:/usr/include/claws-mail/main.h
# 的话这行没有任何用处。autotools/cmake 也不是用 rpm 来找的。
Provides:       claws-mail:/usr/include/claws-mail/main.h
# 这以下的 Requires 全是多余的,因为 openSUSE 的 OBS 可以自动
# 识别 C/C++ 的 .so 依赖并绑定到对应的 -devel 包。
Requires:       claws-mail = %{version}
Requires:       enchant-devel
Requires:       glib2-devel
Requires:       gnutls-devel
Requires:       gpgme-devel
Requires:       gtk2-devel
Requires:       libetpan-devel
Requires:       pinentry-gtk2
Requires:       libpoppler-glib-devel
Requires:       openldap2-devel
# BuildRoot 不是包级别的,而是 specfile 级别的。你前面已经有了。
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%prep
%setup -q
# 这些 sed 画蛇添足,前后是一个意思
sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python/' tools/*.py
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/*.sh
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/kdeservicemenu/install.sh

%install
# /usr/share/pixmaps 和 /usr/share/applications/icons 两者有一个就行
# 没必要多此一举
mkdir -p %{buildroot}%{_datadir}/pixmaps/
cp claws-mail-64x64.png %{buildroot}%{_datadir}/pixmaps/

# RPM 没有往隐藏文件夹内装东西的先例。如果软件是这么装的,
# 你需要提 issue 或者自己做 patch 把它装到正确的地方。
install -d %{buildroot}%{_sysconfdir}/skel/.claws-mail/
cat <<EOF > %{buildroot}%{_sysconfdir}/skel/.claws-mail/clawsrc
[Plugins_GTK2]
%{_libdir}/claws-mail/plugins/pgpcore.so
%{_libdir}/claws-mail/plugins/pgpinline.so
%{_libdir}/claws-mail/plugins/pgpmime.so
%{_libdir}/claws-mail/plugins/smime.so
EOF

%files
# 这个 .deps 你可以打开看看,是编译的中间文件,不应该装到 rpm 里去。
%{_libdir}/claws-mail/plugins/*.deps
%{_datadir}/icons/hicolor/*/apps/claws-mail.png
%{_datadir}/pixmaps/claws-mail-64x64.png
# Makefile 同理
%{_datadir}/claws-mail/Makefile*
# README 应该装到 %{_docdir},它不这么装你就要改。
%{_datadir}/claws-mail/README
# 这个你打开看,要么没用,要么可能是 %license
%{_datadir}/claws-mail/alternative-tlds.txt
# 你确定上游的证书有用?所有用户都用这一个?
%{_datadir}/claws-mail/ca-certificates.crt
# 这个应该也是中间文件
%{_datadir}/claws-mail/make.themes.project
# bash_completion 应该单独拆包,因为 claws-mail 不依赖 bash
# 我用 zsh 就不能用它了?你 zypper 搜索一下 bash-completion
%{_datadir}/claws-mail/bash_completion/
%{_datadir}/claws-mail/bash_completion/*
# 这个 jhbuild 100% 是编译的中间文件。
%{_datadir}/claws-mail/jhbuild/
%{_datadir}/claws-mail/jhbuild/*
# 这里的 doc 文件夹不对,应该是 %{_docdir} 也就是
# %{_datadir}/doc/packages/, 上游不对你就要改
%{_datadir}/doc/claws-mail/RELEASE_NOTES
# 这里写死后缀也不对,如果有一天默认不用 gz 压缩了呢?
# 有一个 macro 叫 %{extman}
%{_mandir}/man1/claws-mail.1.gz
# 这里也不对,noreplace 的不能是文件夹。
%config(noreplace) %{_sysconfdir}/skel/.claws-mail/

#3

好的 回去看看 谢谢


#4

我的水平目前只能修到这里了 基础还是太薄弱了得多看才行
sed 部分去掉後編譯會報錯 `還不會做補丁…

[  315s] This script uses 'env' as an interpreter. For the rpm runtime dependency
[  315s] detection to work, the shebang #!/usr/bin/env python  needs to be patched into
[  315s] #!/usr/bin/python  otherwise the package dependency generator merely adds a
[  315s] dependency on /usr/bin/env rather than the actual interpreter /usr/bin/python.
[  315s] Alternatively, if the file should not be executed, then ensure that it is not
[  315s] marked as executable or don't install it in a path that is reserved for
[  315s] executables.

doc部分在源碼裏面沒看明白也就沒改 現在基本能用了 中文也編譯進去了

specfile

#
# spec file for package claws-mail
#
# Copyright (c) 2018 SUSE LINUX 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/
#


Name:           claws-mail
Version:        3.17.0git188
Release:        0
Summary:        A configurable email client 
License:        GPL-3.0+ 
Group:          Productivity/Networking/Email/Clients
Source0:        claws-mail-3.17.0git188.tar.xz
BuildRequires:  NetworkManager-devel
BuildRequires:  compface-devel
BuildRequires:  db-devel
BuildRequires:  enchant-devel
BuildRequires:  lynx
BuildRequires:  gettext
BuildRequires:  gmp-devel
BuildRequires:  libetpan-devel
BuildRequires:  libgtkhotkey-devel
BuildRequires:  libgnutls-devel
BuildRequires:  libgpgme-devel 
BuildRequires:  libarchive-devel
%if 0%{?favor_gtk2}
BuildRequires:  gtk2-devel
BuildRequires:  libcanberra-gtk-devel >= 0.6
%else
BuildRequires:  gtk3-devel
BuildRequires:  libcanberra-gtk3-devel >= 0.6
%endif
BuildRequires:  libcanberra-devel >= 0.6
BuildRequires:  libcurl-devel
BuildRequires:  libexpat-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libgdata-devel >= 0.17.2
BuildRequires:  libpoppler-glib-devel
BuildRequires:  librsvg-devel >= 2.40.5
BuildRequires:  openldap2-devel
BuildRequires:  pilot-link-devel
BuildRequires:  pkgconfig
BuildRequires:  python-gtk-devel
BuildRequires:  startup-notification-devel
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(dbus-1) >= 0.60
BuildRequires:  pkgconfig(dbus-glib-1) >= 0.60
BuildRequires:  pkgconfig(gnutls) >= 2.2
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(libsoup-2.4)
BuildRequires:  pkgconfig(sm)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{?libperl_requires}
Provides:       sylpheed-claws = %{version}
Obsoletes:      sylpheed-claws < %{version}


%description
Claws Mail (previously known as Sylpheed-Claws) is a
configurable email client and news reader based on the GTK+ GUI
toolkit, and it runs on the X Window System.

Summary:        Development files for claws-mail
License:        GPL-2.0-or-later
Group:          Development/Libraries/C and C++

Obsoletes:      claws-mail-extra-plugins < %{version}
Provides:       claws-mail-extra-plugins = %{version}

%lang_package
%prep
%setup -q
sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python/' tools/*.py
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/*.sh
sed -i 's/#!\/usr\/bin\/env bash/#!\/bin\/bash/' tools/kdeservicemenu/install.sh


%build
%configure \
        --disable-static \
%if !(0%{?favor_gtk2})
        --enable-gtk3 \
%endif
        --enable-ldap \
        --enable-ipv6 \
        --enable-jpilot \
        --enable-acpi_notifier-plugin \
        --enable-address_keeper-plugin \
        --enable-att_remover-plugin \
        --enable-attachwarner-plugin \
        --enable-bogofilter-plugin \
        --enable-bsfilter-plugin \
        --enable-clamd-plugin \
        --disable-fancy-plugin \
        --enable-fetchinfo-plugin \
        --enable-mailmbox-plugin \
        --enable-newmail-plugin \
        --enable-notification-plugin \
        --enable-pdf_viewer-plugin \
        --enable-perl-plugin \
        --enable-pgpcore-plugin \
        --enable-pgpmime-plugin \
        --enable-pgpinline-plugin \
        --enable-rssyl-plugin \
        --enable-smime-plugin \
        --enable-spamassassin-plugin \
        --enable-spam_report-plugin \
        --disable-tnef_parse-plugin \
        --disable-vcalendar-plugin \
        --disable-demo-plugin \
        --enable-crash-dialog \
        --enable-startup-notification \
        --enable-compface \
        --enable-libetpan
make %{?_smp_mflags}

%install
%makeinstall

# Clean up
rm -rf %{buildroot}%{_libdir}/claws-mail/plugins/*.la
rm -rf %{buildroot}%{_libdir}/claws-mail/plugins/*.deps
rm -rf %{buildroot}/usr/include/*

# Tools
mkdir -p %{buildroot}%{_datadir}/%{name}/tools/
mkdir -p %{buildroot}%{_datadir}/%{name}/tools/kdeservicemenu/
cp tools/*.sh %{buildroot}%{_datadir}/%{name}/tools/
cp tools/*.py %{buildroot}%{_datadir}/%{name}/tools/
cp tools/*.pl %{buildroot}%{_datadir}/%{name}/tools/
cp tools/update-po %{buildroot}%{_datadir}/%{name}/tools
cp tools/uudec %{buildroot}%{_datadir}/%{name}/tools/
cp tools/uuooffice %{buildroot}%{_datadir}/%{name}/tools/
cp tools/tb2claws-mail %{buildroot}%{_datadir}/%{name}/tools/
cp tools/*.conf %{buildroot}%{_datadir}/%{name}/tools/
cp tools/kdeservicemenu/claws-mail-attach-files.desktop.kde4template %{buildroot}%{_datadir}/%{name}/tools/kdeservicemenu/
cp tools/kdeservicemenu/claws-mail-kdeservicemenu.pl %{buildroot}%{_datadir}/%{name}/tools/kdeservicemenu/
cp tools/kdeservicemenu/install.sh %{buildroot}%{_datadir}/%{name}/tools/kdeservicemenu/

# we want to have the icon installed in /usr/share/pixmaps
mkdir -p %{buildroot}%{_datadir}/pixmaps/
cp claws-mail-64x64.png %{buildroot}%{_datadir}/pixmaps/

# install desktop file
%suse_update_desktop_file claws-mail


%find_lang %name --all-name
%files -f %name.lang 

%postun
%desktop_database_postun
%icon_theme_cache_postun

%files
%defattr(-,root,root)
%{_bindir}/claws-mail
%{_bindir}/sylpheed-claws

%dir %{_libdir}/claws-mail
%dir %{_libdir}/claws-mail/plugins
%{_libdir}/claws-mail/plugins/*.so

%{_datadir}/applications/claws-mail.desktop
%{_datadir}/icons/hicolor/*/apps/claws-mail.png
%{_datadir}/pixmaps/claws-mail-64x64.png

%dir %{_datadir}/claws-mail/
%dir %{_datadir}/claws-mail/tools/
%{_datadir}/claws-mail/tools/*.sh
%{_datadir}/claws-mail/tools/*.pl
%{_datadir}/claws-mail/tools/*.py
%{_datadir}/claws-mail/tools/*.conf
%{_datadir}/claws-mail/tools/tb2claws-mail
%{_datadir}/claws-mail/tools/u*
%dir %{_datadir}/claws-mail/tools/kdeservicemenu/
%{_datadir}/claws-mail/tools/kdeservicemenu/*

%dir %{_datadir}/doc/
%{_datadir}/doc/claws-mail/
%{_mandir}/man1/claws-mail.1.gz

%dir %{_libdir}/pkgconfig/
%{_libdir}/pkgconfig/claws-mail.pc

%changelog