2019年10月28日月曜日

最近発見された3つの立方数の和が42になる数

掲題の件を CentOS8 の gawk で確認してみた。
-M オプション(MPFR / MP 拡張)が必要なので、CentOS7 以下では駄目でした。
[root@hoge ~]# uname -a
Linux hoge 4.18.0-80.el8.x86_64 #1 SMP Wed Mar 13 12:02:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@hoge ~]# gawk --version
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 3.1.6-p2, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
[root@hoge ~]# cat 42.gawk 
BEGIN {
 a = -80538738812075974
 b =  80435758145817515
 c =  12602123297335631

 printf("a = %18d    length=%d\n", a, length(-a))
 printf("b = %18d    length=%d\n", b, length(b))
 printf("c = %18d    length=%d\n", c, length(c))
 print ""

 x = a^3
 y = b^3
 z = c^3

 printf("a^3 = %52d    length=%d\n", x, length(-x))
 printf("b^3 = %52d    length=%d\n", y, length(y))
 printf("c^3 = %52d    length=%d\n", z, length(z))
 print ""

 printf("a^3 + b^3 + c^3 = %d\n", x + y + z)

 exit(0)
}
[root@hoge ~]# time gawk -M -f 42.gawk 
a = -80538738812075974    length=17
b =  80435758145817515    length=17
c =  12602123297335631    length=17

a^3 = -522413599036979150280966144853653247149764362110424    length=51
b^3 =  520412211582497361738652718463552780369306583065875    length=51
c^3 =    2001387454481788542313426390100466780457779044591    length=49

a^3 + b^3 + c^3 = 42

real 0m0.002s
user 0m0.000s
sys 0m0.001s
恐ろしい桁数ですが、このように計算は一瞬でした。

2019年10月22日火曜日

CentOS7 で mlterm をビルドする

~/.mlterm/msg.log に出力されるエラーを見ながら、トライアル&エラーでビルドしたので、備忘録です。

まず、ビルドに必要なもの、途中メモらなかったので、history から抜粋です。もしかしたら、不完全かもです。
[root@hoge ~]# history | grep -w "yum install" | grep 2019-10-22 | sort -k +3
14624   2019-10-22 04:42:31  yum install xcb-util-image.x86_64
14627   2019-10-22 04:44:31  yum install libX11-devel
14691   2019-10-22 08:13:48  yum install cairo-devel
14722   2019-10-22 08:29:17  yum install harfbuzz-devel
14729   2019-10-22 08:37:55  yum install fribidi-devel
14817   2019-10-22 08:48:07  yum install gtk3-devel
特に最後の gtk3-devel が入ってないと、Ctrl+マウス右ボタン(設定を呼び出す)が使えません。入ってなくても、それにまつわる機能が disable になってビルドされてしまうので、厄介でした。最後の最後に、見出しました。

ソース tar の中には、spec ファイルが含まれていますが、少し手直しする必要がありました。次は差分です。
[root@hoge ~]# diff -u mlterm-3.8.8/mlterm.spec.org mlterm-3.8.8/mlterm.spec
--- mlterm-3.8.8/mlterm.spec.org 2019-03-31 22:10:47.000000000 +0900
+++ mlterm-3.8.8/mlterm.spec 2019-10-22 08:57:24.925819688 +0900
@@ -19,7 +19,7 @@
 URL:         http://mlterm.sourceforge.net/
 Source0:     http://prdownloads.sourceforge.net/mlterm/mlterm-%{version}.tar.gz
 Packager:    The mlterm team
-Requires:    gtk+
+Requires:    gtk3
 BuildRoot:   /var/tmp/%{name}-%{version}-root
 
 %description
@@ -68,7 +68,7 @@
 %{bindir}/mlfc
 %{libdir}/libpobl.*
 %{libdir}/libmef.*
-%{libdir}/libmlterm_core.*
+#%{libdir}/libmlterm_core.*
 %{libdir}/libmlterm_coreotl.*
 %{libdir}/mef/
 %{libdir}/mlterm/
@@ -79,9 +79,10 @@
 %{mandir}/man1/mlcc.1*
 %{pixmapdir}/mlterm*
 %{datadir}/locale/*/LC_MESSAGES/mlconfig.mo
+%{datadir}/mlterm/scrollbars/sample3/
 
 %changelog
-* Sun Mar 31 2018 Araki Ken 
+* Sun Mar 31 2019 Araki Ken 
 - Source version 3.8.8
 
 * Sat Oct 27 2018 Araki Ken 
@@ -153,7 +154,7 @@
 * Tue Oct 28 2014 Araki Ken 
 - Source version 3.4.0
 
-* Sun Aug 16 2014 Araki Ken 
+* Sat Aug 16 2014 Araki Ken 
 - Source version 3.3.8
 
 * Sun Jul 06 2014 Araki Ken 
@@ -240,7 +241,7 @@
 * Sat Jun 04 2011 Araki Ken 
 - Source version 3.0.5
 
-* Sat May 29 2011 Araki Ken 
+* Sun May 29 2011 Araki Ken 
 - Source version 3.0.4
 
 * Sun Mar 20 2011 Araki Ken 
@@ -261,7 +262,7 @@
 * Sun May 07 2006 Seiichi SATO 
 - Source version 2.9.3
 
-* Sat Mar 04 2005 Seiichi SATO 
+* Fri Mar 04 2005 Seiichi SATO 
 - Source version 2.9.2
 
 * Sun Nov 28 2004 Seiichi SATO 
@@ -283,7 +284,7 @@
 * Sun Jan 12 2003 Araki Ken 
 - Source version 2.6.3
 
-* Thu Oct 1 2002 Araki Ken 
+* Tue Oct 1 2002 Araki Ken 
 - Source version 2.6.2
 
 * Thu Sep 12 2002 Araki Ken 
後半の changelog の年月日や曜日の間違いは、「あるある」だなあと思いました。それと、spec ファイル書いてくれた方、ありがとうございます。やはり、make install より、rpm のほうが取り回しが良いですよね。

あとは、ビルドです。
[root@hoge ~]# ls -l rpmbuild/SOURCES/mlterm-3.8.8.tar.gz  ※ここに tar ボール配置
-rw-r--r-- 1 root root 4035215 10月 22 04:35 rpmbuild/SOURCES/mlterm-3.8.8.tar.gz
[root@hoge ~]# rpmbuild -ba mlterm-3.8.8/mlterm.spec
...
[root@hoge ~]# ls -l --full-time rpmbuild/RPMS/x86_64/
合計 4777
-rw-r--r-- 1 root root 2392004 2019-10-22 08:58:58.737085241 +0900 mlterm-3.8.8-1.x86_64.rpm
-rw-r--r-- 1 root root 2535872 2019-10-22 08:58:59.713098408 +0900 mlterm-debuginfo-3.8.8-1.x86_64.rpm

[root@hoge ~]# dmidecode --type 1
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.

Handle 0x000C, DMI type 1, 27 bytes
System Information
 Manufacturer: LENOVO
 Product Name: 20K70003JP
 Version: ThinkPad 25
 Serial Number: PF0XJ53D
 UUID: 307f584c-2bae-11b2-a85c-c18b88313792
 Wake-up Type: Power Switch
 SKU Number: LENOVO_MT_20K7_BU_Think_FM_ThinkPad 25
 Family: ThinkPad 25

[root@hoge ~]# uversion 
CentOS Linux release 7.7.1908           20K70003JP

BIOS version  : N1QET85W (1.60 )  08/30/2019  1.60
Firmware rev. : 1.34
System serial : PF0XJ53D

CPU model  : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Processors : 4  (1 sockets, 2 cores per CPU, Hyperthreading: enabled)

Memory : 31772 MB

Linux : 3.10.0-1062.1.2.el7.x86_64  x86_64  (hoge)

[root@hoge ~]# rpm -qi mlterm
Name        : mlterm
Version     : 3.8.8
Release     : 1
Architecture: x86_64
Install Date: 2019年10月22日 08時59分37秒
Group       : User Interface/X
Size        : 17492735
License     : Modified BSD-style license
Signature   : (none)
Source RPM  : mlterm-3.8.8-1.src.rpm
Build Date  : 2019年10月22日 08時58分57秒
Build Host  : hoge
Relocations : (not relocatable)
Packager    : The mlterm team
URL         : http://mlterm.sourceforge.net/
Summary     : Multi Lingual TERMinal emulator on X
Description :
mlterm is a multi-lingual terminal emulator written from
scratch, which supports various character sets and encodings
in the world.  It also supports various unique feature such as
anti-alias using FreeType, multiple windows, scrollbar API,
scroll by mouse wheel, automatic selection of encoding,
and so on. Multiple xims are also supported.
You can dynamically change various xims.
格闘の記録。msg.log も貼っておきます。
[root@hoge ~]# cat .mlterm/msg.log 
Oct 22 04:58:27[16165] ERROR(No such file or directory): cairo: Could not load.
Oct 22 04:58:27[16165] Fall back to xcore.
Oct 22 04:58:27[16165] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 04:58:40[16165] Font(id 2d1) width(10) is not matched with standard width(20).
Oct 22 04:58:40[16165] Characters (cs d1) are drawn *one by one *to arrange column width.
Oct 22 04:59:32[16165] Font(id 6d1) width(10) is not matched with standard width(20).
Oct 22 04:59:32[16165] Characters (cs d1) are drawn *one by one *to arrange column width.
Oct 22 05:08:13[17324] ERROR(No such file or directory): cairo: Could not load.
Oct 22 05:08:13[17324] Fall back to xcore.
Oct 22 05:08:13[17324] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 05:08:24[17384] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 05:08:30[17391] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 05:08:32[17394] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 05:08:35[17399] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 05:13:28[17995] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 05:13:30[17998] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 05:13:33[18003] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 05:13:34[18006] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 05:14:59[18140] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 05:15:00[18142] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 05:19:24[17324] Font(id 2d1) width(10) is not matched with standard width(20).
Oct 22 05:19:24[17324] Characters (cs d1) are drawn *one by one *to arrange column width.
Oct 22 07:39:49[6408] ERROR(No such file or directory): cairo: Could not load.
Oct 22 07:39:49[6408] Fall back to xcore.
Oct 22 07:39:49[6408] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 07:39:53[6459] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 07:39:55[6462] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 07:39:56[6463] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 07:39:56[6465] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 07:40:45[6408] Fall back to xcore.
Oct 22 07:43:36[6408] Fall back to xcore.
Oct 22 07:43:38[6408] Fall back to xcore.
Oct 22 07:44:28[6408] Font(id 2d1) width(10) is not matched with standard width(20).
Oct 22 07:44:28[6408] Characters (cs d1) are drawn *one by one *to arrange column width.
Oct 22 08:10:51[10440] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:20:55[11806] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 08:21:05[11806] Font(id 2d1) width(21) is not matched with standard width(16).
Oct 22 08:23:07[12239] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 08:23:09[12278] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:23:10[12280] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:23:10[12281] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:23:13[12284] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:23:14[12286] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:23:14[12287] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:26:08[12644] ERROR(No such file or directory): BiDi: Could not load.
Oct 22 08:26:15[12692] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:26:15[12694] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:28:45[12644] Font(id 2d1) width(21) is not matched with standard width(16).
Oct 22 08:34:21[14473] ERROR(Resource temporarily unavailable): BiDi: Could not load.
Oct 22 08:34:26[14527] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:34:37[14581] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:35:08[14652] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:35:09[14653] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:35:57[14706] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:35:57[14708] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:35:58[14710] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:37:21[14473] Font(id 2d1) width(21) is not matched with standard width(16).
Oct 22 08:41:51[16532] Font(id 2d1) width(21) is not matched with standard width(16).
Oct 22 08:42:07[16743] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:42:08[16746] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:42:13[16764] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:42:14[16765] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:42:14[16767] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlconfig.
Oct 22 08:42:15[16768] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
Oct 22 08:42:15[16769] ERROR(No such file or directory): Failed to exec /usr/libexec/mlterm/mlterm/mlterm-menu.
[root@hoge ~]# 
それにしても、CentOS や Fedora で利用している人は、あまり居ないのでしょうかね。ググってもなかなか情報を見つけられず、時間かかりました。
mlterm の「良さ」などについては、ネット検索すると、いろいろと解説が出てくるので、そちらを参照ください。

わたしの目的は、これがしたかっただけです。別途 img2sixel を入れる必要がありますが、そちらは簡単でした。

ターミナルの中で png が見えるー。ひゃっほー。Windows なら Rlogin が Sixel 対応しているようです。

2019-10-22 17時 追記
CentOS8 が入ってる別マシンでも、同様の手順で rpm 作成できることを確かめました。


2019-10-22 21時 追記
背景画像設定して、カラーを調整(前景色を白に設定)したら、良い感じになりました。


2019-10-24追記
Mac の iTerm2 では、imgcat というツールがよく使われるらしいですが、mlterm でも使えました。
https://iterm2.com/utilities/imgcat

大きめの画像を表示する場合は、どういうわけか imgcat のほうが反応が良い(処理時間短い)ようです。それと imgcat のほうが名前を覚えやすいですね。名前重要。
imgls というツールもあり、これまた便利なようです。mlterm でも使えました。

2019年10月18日金曜日

懐かしの kbanner を CentOS8 でコンパイルしたら動いた!

1994年頃、仕事で NEC の UNIXワークステーション EWS4800 を日常的に使っていました。そのマシンの /usr/local/bin (職場の中央サーバを NFS マウントして利用していた) に、kbanner というツール (漢字に対応した banner ソフト) がインストールされていて、その -s オプションの表示の綺麗さに魅了され、よく利用していました。
当時は、誰が作ったものなのか?をググったりはできませんでしたし、ソースは入手できないものだと思っていました。

時は流れ、2003年ごろから Linux どっぷりな仕事 (使うマシンも Express5800 に変わった) になり、kbanner のソースも持っていませんでしたので、EWS4800 の衰退と共に記憶の彼方になっていきました。

そして今、ふと懐かしく思い出し、どこかにソースないのかなと、ググってみたら、ありました!
なんと kbanner の作者さんは、「キーボード配列 QWERTYの謎 NTT出版 (2008年3月), ISBN978-4-7571-4176-6.」の著者さんだったのかー、キーボード好き (特に ThinkPad と RealForce) が高じて手もとにあります。

さっそくダウンロードして、現在の自宅メインマシン (ThinkPad 25 + CentOS8) で make してみました。
コンパイルエラーでも起きるかなと思ったのですが、警告は出るものの、修正なしでビルドできました!
[root@hoge kbanner2]# make
cc -c -O kbanner.c
kbanner.c:5:14: 警告: 組み込み関数 ‘malloc’ と型が競合しています [-Wbuiltin-declaration-mismatch]
 extern char *malloc();
              ^~~~~~
kbanner.c:85:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
 main(argc,argv)
 ^~~~
kbanner.c: 関数 ‘main’ 内:
kbanner.c:115:14: 警告: 関数 ‘atoi’ の暗黙的な宣言です [-Wimplicit-function-declaration]
       column=atoi(&((*argv)[1]));
              ^~~~
kbanner.c:82:3: 警告: 関数 ‘exit’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   exit(1);\
   ^~~~
kbanner.c:120:7: 備考: in expansion of macro ‘USAGE’
       USAGE
       ^~~~~
kbanner.c:82:3: 警告: 組み込み関数 ‘exit’ の互換性がない暗黙的な宣言です
   exit(1);\
   ^~~~
kbanner.c:120:7: 備考: in expansion of macro ‘USAGE’
       USAGE
       ^~~~~
kbanner.c:82:3: 備考: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
kbanner.c:4:1:
+#include 
 
kbanner.c:82:3:
   exit(1);\
   ^~~~
kbanner.c:120:7: 備考: in expansion of macro ‘USAGE’
       USAGE
       ^~~~~
kbanner.c:126:5: 警告: 組み込み関数 ‘exit’ の互換性がない暗黙的な宣言です
     exit(1);
     ^~~~
kbanner.c:126:5: 備考: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
kbanner.c:129:5: 警告: 関数 ‘kbanner’ の暗黙的な宣言です [-Wimplicit-function-declaration]
     kbanner(stdin);
     ^~~~~~~
kbanner.c:130:5: 警告: 組み込み関数 ‘exit’ の互換性がない暗黙的な宣言です
     exit(0);
     ^~~~
kbanner.c:130:5: 備考: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
kbanner.c:142:3: 警告: 組み込み関数 ‘exit’ の互換性がない暗黙的な宣言です
   exit(0);
   ^~~~
kbanner.c:142:3: 備考: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
kbanner.c: トップレベル:
kbanner.c:145:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
 kbanner(fp)
 ^~~~~~~
kbanner.c: 関数 ‘kbanner’ 内:
kbanner.c:152:12: 警告: implicit declaration of function ‘kgetchar’; did you mean ‘getchar’? [-Wimplicit-function-declaration]
   while((i=kgetchar(fp))!=EOF){
            ^~~~~~~~
            getchar
kbanner.c:159:4: 警告: implicit declaration of function ‘kputchar’; did you mean ‘putchar’? [-Wimplicit-function-declaration]
    kputchar(i*256+(j&127));
    ^~~~~~~~
    putchar
kbanner.c: トップレベル:
kbanner.c:202:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
 kputchar(c)
 ^~~~~~~~
kbanner.c: 関数 ‘kputchar’ 内:
kbanner.c:267:7: 警告: 非 void を戻す関数内に値が無い ‘return’ があります
       return;
       ^~~~~~
kbanner.c:202:1: 備考: ここで宣言されています
 kputchar(c)
 ^~~~~~~~
kbanner.c: トップレベル:
kbanner.c:278:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
 kgetchar(fp)
 ^~~~~~~~
cc -c -O font1.c
cc -c -O font2.c
cc -c -O font3.c
cc kbanner.o font1.o font2.o font3.o -o kbanner
strip kbanner
[root@hoge kbanner2]# ls -l
合計 1356
-rw-r--r-- 1 1001 wheel    321  7月 13  2004 Makefile
-rw-r--r-- 1 1001 wheel    203  7月 13  2004 README
-rw-r--r-- 1 1001 wheel 289120 10月 15  1993 font1.c
-rw-r--r-- 1 root root   79952 10月 18 04:47 font1.o
-rw-r--r-- 1 1001 wheel 289120 10月 15  1993 font2.c
-rw-r--r-- 1 root root   79952 10月 18 04:47 font2.o
-rw-r--r-- 1 1001 wheel 278000 10月 15  1993 font3.c
-rw-r--r-- 1 root root   76912 10月 18 04:47 font3.o
-rwxr-xr-x 1 root root  245376 10月 18 04:47 kbanner
-rw-r--r-- 1 1001 wheel    692 10月 15  1993 kbanner.1
-rw-r--r-- 1 1001 wheel   8594 10月 15  1993 kbanner.c
-rw-r--r-- 1 root root   16208 10月 18 04:47 kbanner.o
[root@hoge kbanner2]# ./kbanner --help
Usage: ./kbanner [-l|-numofcol] [-s] [-m] [file]
早速動かしてみると文字化け、、、当時は EUC-JP でしたので、環境変数 LANG=ja_JP.eucJP を設定し、端末文字コードも EUC-JP にして、再実行。
[root@hoge kbanner2]# echo -n キーボード配列 QWERTYの謎 | ./kbanner -s -8
     ;                                 ,    ; ;                       ,     , , ,,,,,,,,, ,,,,,  ,,,,,,,,, ,  ;                 
     ';   ,,,                          ;                              ;     ' '    ; ;        ;     ;      ;  ;                 
    ,,;;'''                      '''''';'''''''                       ;          ;';';';      ;     ;,,,,  ;  ;                 
 ''''  ;   ,,,,  ',,,,,,,,,,,,,     ,  ;   ,     ',,,,,,,,,,,,,       ;'';,,     ; ; ; ;  ;''''    ;'   ;  ;  ;                 
     ,,;;'''                       ,;  ;   ';,                        ;    '''   ;'  '';  ;      ,;';, ;'  ;  ;                 
  ''''  ;,                        ,;   ;     ;,                       ;          ;,,,,,;  ;          ';'   '  ;                 
         ;                       ''    ;      '                       ;          ;     ;  ;,  ,;    ,;'       ;                 
         ';                          '''                              '          '''''''   '''' ,,;''       ,,;                 
      ,,,,      ,,,,,  ,,  ,,,,,  ,,,,,,,,,,,     ,,,,,,,,,      ,,,,,,,,,,,,,   ,,,,,   ,,,,,                   ,,,, ,  ,  ;  ,
   ,;'    ';,     ;    ;;    ;      ;       ',      ;      ',    ;     ;     ;     ;,     ,;        ,,;';';,,   ,,,,,,'; '; ; ;'
  ,;        ;,    ;,  ;'';  ,;      ;    ,          ;       ;          ;            ;,   ,;       ,;'   ;   ';   ,,,,    ,,,;,,,
  ;          ;     ; ,;  ;, ;       ;,,,,;          ;,,,,,,'           ;             ;, ,;       ,;    ;'    ';       ,,,  ,;,  
  ;,        ,;     ; ;    ; ;       ;    ;          ;     ;,           ;              ';'        ;    ;'      ;  ''''   ; ,';', 
   ;, ,'', ,;      ';;    ;;'       ;        ,      ;      ;,          ;               ;         ;  ,;'      ;'  ,,,,   ;,' ; ',
    '',,,,';  ,     ;      ;      ,,;,,,,,,,;     ,,;,,   ,,;,,      ,,;,,           ,,;,,        '''    ,,;''   ;  ;  ,;   ;   
            ''                                                                                                   ;,,; ;' ',,,,,,
[root@hoge kbanner2]# 
これだ、これだよ〜、懐かしいなあ。また利用させてもらおうと思います。作者さん、ありがとうございます m(_ _)m

2019年10月10日木曜日

CentOS8 で ZFS on Linux 0.8.2 をビルドする

RHEL8/CentOS8 で、ZFS on Linux 0.8.2 をビルドしてインストールする手順。備忘録。

現時点では、公式ページからビルド済みパッケージが提供されていないので、ソースから dkms 版をビルドします。
まず最初に、いつの間にか、EL8 向けの EPEL が出来ていたので、そちらから dkms パッケージをインストールしておきます。それから、次の手順 (bash history から抜粋) 。
[root@hoge zfs-0.8.2]# history
...
 3059   2019-10-10 06:39:21  cd zfs-0.8.2/
 3060   2019-10-10 06:39:28  ./autogen.sh 
 3061   2019-10-10 06:40:03  ./configure --with-config=srpm
 3062   2019-10-10 06:40:26  make -s -j$(nproc)
 3063   2019-10-10 06:41:15  make -j1 pkg-utils rpm-dkms
 3064   2019-10-10 06:44:39  rpm -Uvh $(ls -1 *.$(uname -p).rpm *.noarch.rpm | grep -v debug)
次は、インストールログです。
[root@hoge zfs-0.8.2]# rpm -Uvh $(ls -1 *.$(uname -p).rpm *.noarch.rpm | grep -v debug)
Verifying...                          ################################# [100%]
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:libnvpair1-0.8.2-1.el8           ################################# [  5%]
   2:libuutil1-0.8.2-1.el8            ################################# [ 10%]
   3:libzfs2-0.8.2-1.el8              ################################# [ 15%]
   4:libzpool2-0.8.2-1.el8            ################################# [ 20%]
   5:zfs-dkms-0.8.2-1.el8             ################################# [ 25%]
Loading new zfs-0.8.2 DKMS files...
Building for 4.18.0-80.el8.x86_64
Building initial module for 4.18.0-80.el8.x86_64
Done.

zavl.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

znvpair.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

zunicode.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

zcommon.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

zfs.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

icp.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

zlua.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/

spl.ko.xz:
Running module version sanity check.
 - Original module
   - This kernel never originally had a module by this name
 - Installation
   - Installing to /lib/modules/4.18.0-80.el8.x86_64/extra/
Adding any weak-modules

depmod.....

DKMS: install completed.
   6:zfs-0.8.2-1.el8                  ################################# [ 30%]
   7:zfs-dracut-0.8.2-1.el8           ################################# [ 35%]
   8:zfs-test-0.8.2-1.el8             ################################# [ 40%]
   9:libzfs2-devel-0.8.2-1.el8        ################################# [ 45%]
  10:python3-pyzfs-0.8.2-1.el8        ################################# [ 50%]
整理中 / 削除中...
  11:libzfs2-devel-0.8.0-rc4.el8      ################################# [ 55%]
  12:python3-pyzfs-0.8.0-rc4.el8      ################################# [ 60%]
  13:zfs-test-0.8.0-rc4.el8           ################################# [ 65%]
  14:zfs-dracut-0.8.0-rc4.el8         ################################# [ 70%]
  15:zfs-0.8.0-rc4.el8                ################################# [ 75%]
  16:zfs-dkms-0.8.0-rc4.el8           ################################# [ 80%]
  17:libzfs2-0.8.0-rc4.el8            ################################# [ 85%]
  18:libzpool2-0.8.0-rc4.el8          ################################# [ 90%]
  19:libnvpair1-0.8.0-rc4.el8         ################################# [ 95%]
  20:libuutil1-0.8.0-rc4.el8          ################################# [100%]
2019-10-11追記
ビルドする前に必要なパッケージは、
https://github.com/zfsonlinux/zfs/wiki/Custom-Packages
に書いてありますが、一部のパッケージ (device-mapper-develなど) が PowerTools というリポジトリに分類されているようなので、次のように有効化する必要がありました。
[root@hoge ~]# dnf install device-mapper-devel --enablerepo=PowerTools
それから、UEFI secureboot が有効になっていると、zfs モジュールをロードできないようです。
[root@hoge ~]# dmesg | grep secure
[    0.000000] secureboot: Secure boot enabled
[    0.000000] Kernel is locked down from EFI secure boot; see man kernel_lockdown.7
[root@hoge ~]# modprobe zfs
modprobe: ERROR: could not insert 'zfs': Required key not available
[root@hoge ~]# grep LOCK_DOWN /boot/config-4.18.0-80.7.1.el8_0.x86_64 
CONFIG_LOCK_DOWN_KERNEL=y
# CONFIG_LOCK_DOWN_MANDATORY is not set
CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT=y
[root@hoge ~]# grep CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ /boot/config-4.18.0-80.7.1.el8_0.x86_64 
[root@hoge ~]# 
SysRq x も使えない。BIOS で、secureboot を無効化するとロードできまます。

2019-10-19追記
EL8 向けのリポジトリは、作業中の模様。
https://github.com/zfsonlinux/zfs/issues/9287

2019-11-19追記
EL8 向けリポジトリが公開されたので、これからは kmod-zfs を使えば良さそうです。
早速、入れ替えました。
[root@hoge ~]# rpm -qi kmod-zfs
Name        : kmod-zfs
Version     : 0.8.2
Release     : 1.el8
Architecture: x86_64
Install Date: 2019年11月19日 21時34分52秒
Group       : System Environment/Kernel
Size        : 6812072
License     : CDDL
Signature   : RSA/SHA256, 2019年11月14日 02時48分47秒, Key ID a9d5a1c0f14ab620
Source RPM  : zfs-kmod-0.8.2-1.el8.src.rpm
Build Date  : 2019年11月13日 10時17分58秒
Build Host  : fedora-30-repo
Relocations : (not relocatable)
URL         : http://zfsonlinux.org/
Summary     : zfs kernel module(s)
Description :
This package provides the zfs kernel modules built for
the Linux kernel 4.18.0-80.11.2.el8_0.x86_64 for the x86_64
family of processors.
人気ブログランキングへ にほんブログ村 IT技術ブログへ