序
Termux
上でgmailのための環境を整えるべくmbsyncをインストールしたので、次はmu(mu4e)をインストールします。丁度0.9.xから1.0にメジャーバージョンがアップされたので、mu-1.0
をインストールします。
ビルドツールのインストール
ソースをビルドするためのツールをインストールします。
$ pkg install autoconf automake bison bzip2 \
clang cmake coreutils diffutils \
flex gawk git grep gzip libtool \
make patch perl sed silversearcher-ag \
tar termux-exec wget
Hit:1 https://termux.net stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
.....
依存パッケージのインストール
termux-packages
リポジトリーからのインストール
依存パッケージをインストールします。ここには記しませんが、mu4e
を使用する場合はemacs
も事前にインストールしておかなければなりません。あと、わたしの環境で足りなかったパッケージだけしか記しませんが、自前ビルドで事前にインストールしてあるのはdictd
とisync
だけなので、他に足りないパッケージがあっても、これら以外ならpkg install
コマンドでインストールできるでしょう。
pkg-config
のインストール
$ pkg install pkg-config
Hit:1 https://termux.net stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
.....
glib-dev
のインストール
mu
はglib-2.x系列、いわゆるGNOME2系列を使用します。リポジトリーのglib
は2.54.3なので、これをインストールします。
$ pkg install glib-dev
Hit:1 https://termux.net stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
.....
libgpg-error-dev
のインストール
$ pkg install libgpg-error-dev
Hit:1 https://termux.net stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
.....
ソースからビルドしてインストール
gmime-2.6
のインストール
リポジトリーのgmime
は3.2.0、いわゆるGNOME3系列です。GNOME2からGNOME3ではライブラリー関数の仕様も激変しており、mu
が使用する関数も引数の数が違ったりするので、これはソースからインストールする必要があります。
ビルド環境の準備
ソースはここから入手しました。解凍したら解凍したフォルダーに移動して、configure
する前に以下のコマンドを実行します。
export PREFIX=/data/data/com.termux/files/usr
export LD_PRELOAD=${PREFIX}/lib/libtermux-exec.so
$ cp ${PREFIX}/share/libtool/build-aux/config.sub .
$ cp ${PREFIX}/share/libtool/build-aux/config.guess .
configure
、make
、make install
configure
します。
$ ./configure --prefix="${PREFIX}" CC=clang CXX=clang++
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
checking for a BSD-compatible install... /data/data/com.termux/files/usr/bin/install -c
.....
make
します。
$ make
make all-recursive
make[1]: Entering directory '/data/data/com.termux/files/home/src/gmime-2.6.23'
Making all in m4
make[2]: Entering directory '/data/data/com.termux/files/home/src/gmime-2.6.23/m4'
make[2]: Nothing to be done for 'all'.
.....
インストールします。
$ make install
Making install in m4
make[1]: Entering directory '/data/data/com.termux/files/home/src/gmime-2.6.23/m4'
make[2]: Entering directory '/data/data/com.termux/files/home/src/gmime-2.6.23/m4'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
.....
mu-1.0
のインストール
いよいよmu
をインストールします。
ビルド環境の準備
ソースはここから入手しました。解凍したら解凍したフォルダーに移動して、autogen.sh
の前に以下のコマンドを実行します。
export PREFIX=/data/data/com.termux/files/usr
export LD_PRELOAD=${PREFIX}/lib/libtermux-exec.so
$ cp ${PREFIX}/share/libtool/build-aux/config.sub .
$ cp ${PREFIX}/share/libtool/build-aux/config.guess .
ソースの修正。
lib/mu-util.c
の修正
以下のように修正しました。
--- mu-util.c.orig 2018-02-04 19:58:24.939994545 +0900
+++ mu-util.c 2018-02-04 20:11:43.899994423 +0900
@@ -44,8 +44,36 @@
#include <glib/gstdio.h>
#include <errno.h>
-#include <langinfo.h>
+#include <libandroid-support/langinfo.h>
+#include <termios.h>
+#include <readline/readline.h>
+#ifdef __ANDROID__
+static char* getpass(const char *prompt) {
+ struct termios term_old, term_new;
+ int nread;
+
+ /* Turn echoing off and fail if we can't. */
+ if (tcgetattr (0, &term_old) != 0) {
+ return NULL;
+ }
+
+ term_new = term_old;
+ term_new.c_lflag &= ~ECHO;
+
+ if (tcsetattr (0, TCSAFLUSH, &term_new) != 0) {
+ return NULL;
+ }
+
+ /* Read the password. */
+ char *password = readline(prompt);
+
+ /* Restore terminal. */
+ (void) tcsetattr (0, TCSAFLUSH, &term_old);
+
+ return password;
+}
+#endif
static char*
do_wordexp (const char *path)
lib/tests/test-mu-common.c
の修正
テスト用と思われますが、make
が失敗するので修正しました。
--- test-mu-common.c.orig 2018-02-04 20:02:40.369994506 +0900
+++ test-mu-common.c 2018-02-04 20:03:00.579994503 +0900
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <string.h>
-#include <langinfo.h>
+#include <libandroid-support/langinfo.h>
#include <locale.h>
#include "test-mu-common.h"
autogen.sh
(configure
)
autogen.sh
を実行します。指定した引数はconfigure
に渡されます。
$ ./autogen.sh --prefix="${PREFIX}" CC=clang CXX=clang++ LIBS=-lreadline
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
.....
mu configuration is complete.
------------------------------------------------
mu version : 1.0
Xapian version : 1.4.5
GLib version : 2.54.3
GMime version : 2.6.23
Emacs version : GNU Emacs 25.3
Have wordexp : no
Build mu4e emacs frontend : yes
Build 'mug' toy-ui (gtk+/webkit) : no
McCabe's Cyclomatic Complexity tool : no
Have direntry->d_ino : yes
Have direntry->d_type : yes
------------------------------------------------
* Your system does not seem to have the 'wordexp' function.
This means that you cannot use shell-like expansion in options and
some other places. So, for example, instead of
--maildir=~/Maildir
you should use the complete path, something like:
--maildir=/home/user/Maildir
Now, type 'make' (or 'gmake') to build mu
無事にconfigure
できましたが、wordexp
関数がないので使用するときは、シェルのパス展開は使えないから、絶対パスを指定しなさい、のようなメッセージが出力されます。ググったのですが回避策が見つからなかったので、とりあえずこのままいきます。
make && make install
make
します。
$ make
make all-recursive
make[1]: Entering directory '/data/data/com.termux/files/home/src/mu-1.0'
Making all in m4
make[2]: Entering directory '/data/data/com.termux/files/home/src/mu-1.0/m4'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/data/data/com.termux/files/home/src/mu-1.0/m4'
.....
無事にmake
が終了しましたが、このバイナリーを実行すると警告がでます。
$ ./mu/mu --help
WARNING: linker: /data/data/com.termux/files/home/src/mu-1.0/mu/mu: unused DT entry: type 0xf arg 0x37f8
これはELFエントリーに使用されていないエントリー0xf
があり、それはどーやらAndroid7.0ではサポートされていないDT_RPATH
ということのようです。このようなエントリーをストリップするツールがあるので、インストールして実行します。
$ pkg install termux-elf-cleaner
Hit:1 https://termux.net stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
.....
$ termux-elf-cleaner mu/mu
termux-elf-cleaner: Removing version section from 'mu/mu'
termux-elf-cleaner: Removing version section from 'mu/mu'
termux-elf-cleaner: Removing the DT_RPATH dynamic section entry from 'mu/mu'
termux-elf-cleaner: Removing the DT_VERNEEDED dynamic section entry from 'mu/mu'
termux-elf-cleaner: Removing the DT_VERSYM dynamic section entry from 'mu/mu'
termux-elf-cleaner: Removing the DT_VERNEEDNUM dynamic section entry from 'mu/mu'
インストールします。
$ make install
Making install in m4
make[1]: Entering directory '/data/data/com.termux/files/home/src/mu-1.0/m4'
make[2]: Entering directory '/data/data/com.termux/files/home/src/mu-1.0/m4'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
.....
コマンドラインで実行すると、こんな感じです。
$ mu index --maildir=$PREFIX/../home/.mail
indexing messages under /data/data/com.termux/files/home/.mail [/data/data/com.termux/files/home/.mu/xapian]
\ processing mail; processed: 116700; updated/new: 116700, cleaned-up: 0
cleaning up messages
[/data/data/com.termux/files/home/.mu/xapian]
| processing mail; processed: 116758; updated/new: 0, cleaned-up: 0
elapsed: 12 second(s), ~ 9729 msg/s
/ processing mail; processed: 116758; updated/new: 0, cleaned-up: 0
elapsed: 1507 second(s), ~ 77 msg/s
emacs
のmu4e
です。
結び
これから色々弄ってみます。とは言え、過去数年分のメールというのは、結局大半を見ることなく、メモリーを浪費することになりそうかも、(しかもこのgmail垢は個人用ではなく、ML購読用なので、ウェブ上で検索したほうが早い気がする)です。おわり