LoginSignup
2
1

More than 5 years have passed since last update.

Termuxにmu(mu4e)を導入

Last updated at Posted at 2018-02-04

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も事前にインストールしておかなければなりません。あと、わたしの環境で足りなかったパッケージだけしか記しませんが、自前ビルドで事前にインストールしてあるのはdictdisyncだけなので、他に足りないパッケージがあっても、これら以外なら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 .

configuremakemake 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.patch
--- 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.patch
--- 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

emacsmu4eです。

Screenshot_20180205-063135.png

Screenshot_20180205-063159.png

結び

これから色々弄ってみます。とは言え、過去数年分のメールというのは、結局大半を見ることなく、メモリーを浪費することになりそうかも、(しかもこのgmail垢は個人用ではなく、ML購読用なので、ウェブ上で検索したほうが早い気がする)です。おわり

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1