はじめに
まだまだ2021年5月現在サポートが切れていないSolaris10にPerlを入れていきます。
環境
# cat /etc/release
Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Assembled 17 January 2013
ダウンロード
# mkdir -p /usr/local/src
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
-bash: wget: command not found
wgetがないと怒られます
# pkginfo | grep wget
system SUNWwgetr GNU wget - utility to retrieve files from the World Wide Web (root)
system SUNWwgetu wget - GNU wget
wgetは入っていました。
# pkgchk -v SUNWwgetu
/usr
/usr/sfw
/usr/sfw/bin
/usr/sfw/bin/wget
/usr/sfw/bin/wgetにありましたのでフルパスで実行します。
# /usr/sfw/bin/wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz --no-check-certificate
# gzip -dc openssl-1.1.1k.tar.gz | tar xf -
# cd openssl-1.1.1k
# ./Configure --help
Perl v5.10.0 required--this is only v5.8.4, stopped at ./Configure line 12.
BEGIN failed--compilation aborted at ./Configure line 12.
Perl 5.10以降が必要とのこと。
Perlのインストール
# cd /usr/local/src
# /usr/sfw/bin/wget https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz --no-check-certificate
落ちてこず、古すぎてSSL接続がうまくいってない?
HTTPで接続したらダウンロードできたので次へ。
# gzip -dc perl-5.32.1.tar.gz | tar xf -
# cd perl-5.32.1
# ./Configure --help
ここのとおりにしていきます。
# pkginfo -l SUNWbtool SUNWsprot SUNWtoo SUNWhea SUNWarc SUNWlibm SUNWdfbh SUNWxwinc;echo $?
必要なパッケージは入っているようです。
PATHに/usr/ccs/binを入れる必要があるそうです。
# export PATH=$PATH:/usr/ccs/bin
# env | grep PATH
Sunのコンパイラは/opt/SUNWspro/binにあるそうなのでPATHに追加します。
# export PATH=$PATH:/opt/SUNWspro/bin
# env | grep PATH
ライブラリ関連を読み込む場合はLD_LIBRARY_PATHに/usr/local/libを含めるようにとのこと。
# export LD_LIBRARY_PATH=/usr/local/lib
# env | grep LIBRARY
ここまでで設定は
echo $PATH
/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/SUNWspro/bin
echo $LD_LIBRARY_PATH
/usr/local/lib
となっているはずです。
-Dprefix=でプレフィックスを設定するようです。
# ./Configure
(長いので割愛)
NFSサーバー上で実施したところ、ファイルのロックが失敗するようで、
Configureがfcntl()でハングします。
(略)
Checking how std your stdio is...
Checking to see what happens if we set the stdio ptr...
Increasing ptr in your stdio leaves cnt unchanged. Good.
You seem to have 'fast stdio' to directly manipulate the stdio buffers.
fchdir() found.
fchmod() found.
openat() found.
unlinkat() found.
renameat() found.
linkat() NOT found.
topfchmodat() NOT found.
fchown() found.
fcntl() found.
ファイルロックができるパスで実施したほうが無難です。
Makeしていきます。
# /usr/ccs/bin/make
# /usr/ccs/bin/make test
Make testでエラーがでます。
Failed 1 test out of 2451, 99.96% okay.
../ext/POSIX/t/math.t
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
### ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
### setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd t; ./perl harness
### export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
Elapsed: 1832 sec
u=14.87 s=7.27 cu=1107.49 cs=148.17 scripts=2451 tests=1202858
*** Error code 1
make: Fatal error: Command failed for target `test'
githubで似たようなエラーがありました。
https://github.com/Perl/perl5/issues/17033
例にならってテストを実施してみます。
# cd t;./perl harness -v ../ext/POSIX/t/math.t;cd -
(略)
not ok 87 - signbit 0
# Failed test 'signbit 0'
# at t/math.t line 132.
# got: '1'
# expected: '0'
(略)
not ok 99 - signbit lround -0.25 zero
# Failed test 'signbit lround -0.25 zero'
# at t/math.t line 144.
# got: '1'
# expected: '0'
(略)
math.tの132行目、144行目が失敗しているようです。
132 is(signbit(0), 0, "signbit 0"); # zero
144 is(signbit(lround(-0.25)), 0, "signbit lround -0.25 zero");
signbit(0)とlround(-0.25)がおかしいようです。
manによるとsignbitは重要そうなのでスルーしてとはいかなさそう。
https://linuxjm.osdn.jp/html/LDP_man-pages/man3/signbit.3.html
5 use POSIX ':math_h_c99';
-Duse64bitallをつけても同じでした。
バージョンを落として5.30.3に変えてみます。
(略)
Failed 1 test out of 2433, 99.96% okay.
../ext/POSIX/t/math.t
not ok 87 - signbit 0
# cd t;./perl harness -v ../ext/POSIX/t/math.t;cd -
(略)
# Failed test 'signbit 0'
# at t/math.t line 132.
# got: '1'
# expected: '0'
(略)
# Failed test 'signbit lround -0.25 zero'
# at t/math.t line 144.
# got: '1'
# expected: '0'
(略)
同じようです。
もう少し下げます。5.24.4でやってみます。
Failed 2 tests out of 2228, 99.91% okay.
../cpan/Time-Local/t/Local.t
../ext/POSIX/t/math.t
エラーが増えました。
先にmath.tを見てみます。
not ok 94 - lround -0.25 -> +0
# Failed test 'lround -0.25 -> +0'
# at t/math.t line 123.
# got: '1'
# expected: '0'
123 is(signbit(lround(-0.25)), 0, "lround -0.25 -> +0"); # unlike round()
同じようなところでエラーが出ていたようです。
新しく出たエラーを追ってみます。
cd t;./perl harness -v ../cpan/Time-Local/t/Local.t;cd -
(略)
not ok 6 - timelocal year for 1970 1 2 0 0 0
# Failed test 'timelocal year for 1970 1 2 0 0 0'
# at t/Local.t line 104.
# got: '170'
# expected: '70'
(略)
# Failed test 'timegm year for 1970 1 2 0 0 0'
not ok 12 - timegm year for 1970 1 2 0 0 0
# at t/Local.t line 120.
# got: '170'
# expected: '70'
(略)
新しいエラーは、下のドキュメントでのように2021年現在、失敗しても問題なさそうなテストでした。
Perl : [ timegm / timelocal ] で「年」引数の仕様の正しい理解と使い方について(addinbox.sakura.ne.jp)
math.tで引き続きエラーが出ているのでもう少し古いバージョン5.22.4でテストします。
Failed 1 test out of 2207, 99.95% okay.
../cpan/Time-Local/t/Local.t
math.tのエラーが消えました。
念の為、Time-Localのエラーを確認します。
# cd t;./perl harness -v ../cpan/Time-Local/t/Local.t;cd -
not ok 6 - timelocal year for 1970 1 2 0 0 0
# Failed test 'timelocal year for 1970 1 2 0 0 0'
# at t/Local.t line 104.
# got: '170'
# expected: '70'
(略)
not ok 12 - timegm year for 1970 1 2 0 0 0# Failed test 'timegm year for 1970 1 2 0 0 0'
# at t/Local.t line 120.
# got: '170'
# expected: '70'
同じような内容なので問題なさそうです。
これでインストールしていきます。
# make install
prefixは /usr/local/perl-5.24.4です。
OpenSSLのインストール
インストールしたPerlが先に読まれるようにします。
# export PATH=/usr/local/perl-5.24.4/bin:$PATH
Configureを実行します。
# ./Configure
Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]
pick os/compiler from:
(略)
NOTE: If in doubt, on Unix-ish systems use './config'.
# echo $?
1
in doubtですので、./configを使います。
# ./config --help
Operating system: sun4v-whatever-solaris2
WARNING! If you wish to build 64-bit library, then you have to
invoke './Configure solaris64-sparcv9-cc' *manually*.
You have about 5 seconds to press Ctrl-C to abort.
Configuring OpenSSL version 1.1.1k (0x101010bfL) for solaris-sparcv9-cc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
configuredしてしまったようです。
Prefixを使用してインストールしたいので調べます。
OpenSSLをソースからビルドしてNginxで使用する(qiita.com/noraworld)によると、INSTALLファイルを見てくださいとのこと。
# less ./INSTALL
(略)
On Unix:
$ ./config --prefix=/opt/openssl --openssldir=/usr/local/ssl
Configの仕方が書いてあります。
perl同様CC=gccを指定したいので、/usr/sfw/bin/gccが入るようにPATHを設定します。
# export PATH=$PATH:/usr/sfw/bin
# echo $PATH
/usr/local/perl-5.22.4/bin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/sfw/bin
# which gcc
/usr/sfw/bin/gcc
# CC=gcc; ./config \
--prefix=/usr/local/openssl-1.1.1k \
--openssldir==/usr/local/openssl-1.1.1k \
shared zlib
Operating system: sun4v-whatever-solaris2
WARNING! If you wish to build 64-bit library, then you have to
invoke './Configure solaris64-sparcv9-cc' *manually*.
You have about 5 seconds to press Ctrl-C to abort.
Configuring OpenSSL version 1.1.1k (0x101010bfL) for solaris-sparcv9-cc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
makeします。
# /usr/ccs/bin/make
(略)
cc: Warning: -xarch=v8plus is deprecated, use -m32 -xarch=sparc instead
ld.so.1: acomp: fatal: libsunir.so: open failed: No such file or directory
cc: Fatal error in /opt/SUNWspro/prod/bin/acomp : Killed
*** Error code 9
make: Fatal error: Command failed for target `apps/app_rand.o'
Current working directory /usr/local/src/openssl-1.1.1k
*** Error code 1
make: Fatal error: Command failed for target `all'
Perlもそうでしたが/opt/SUNWspro/prod/binが完全ではない気がします。
一旦パスから外します。
# export PATH=/usr/local/perl-5.22.4/bin:/usr/bin:/usr/sbin:/usr/ccs/bin:/usr/sfw/bin
# /usr/ccs/bin/make
(略)
ld: fatal: symbol referencing errors. No output written to apps/openssl
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `apps/openssl'
Current working directory /usr/local/src/openssl-1.1.1k
*** Error code 1
make: Fatal error: Command failed for target `all'
またエラー。
いたるところでgcc: unrecognized option `-pthread'
が出ています。
こんな記事がありました。
Problems building openssl-1.1.1-pre6 on Solaris 10 sparc #6333(github.com/openssl)
どうやらConfigureでもconfigできるようです。
makeを通すためにMakefileを修正する必要があるようです。
# ./Configure solaris64-sparcv9-gcc \
--prefix=/usr/local/openssl-1.1.1k \
--openssldir=/usr/local/openssl-1.1.1k \
shared zlib
githubに従いMakefileを修正します。
vi ./Makefile
"Makefile" 行が長すぎます。
viで開けないようです。Githubでは以下の様に修正するとあります。
CNF_CFLAGS=-m64 -mcpu=ultrasparc -pthreads
CNF_EX_LIBS=-lsocket -lnsl -ldl -pthreads -lrt
# cat -n ./Makefile | grep CNF_CFLAGS=
126 CNF_CFLAGS=-m64 -mcpu=ultrasparc -pthread
# cat -n ./Makefile | grep CNF_EX_LIBS=
129 CNF_EX_LIBS=-lz -lsocket -lnsl -ldl -pthread
この2箇所を対象に直せば良いようです。
書き換えていきます。
sedは-iオプションが使えないのでOriginalファイルをもとに書き換えます。
# cp Makefile Makefile.original
# sed -e 's/CNF_CFLAGS=-m64\ -mcpu=ultrasparc\ -pthread/CNF_CFLAGS=-m64\ -mcpu=ultrasparc\ -pthreads/g' ./Makefile.original > ./Makefile.tmp1
# sed -e 's/CNF_EX_LIBS=-lz\ -lsocket\ -lnsl\ -ldl\ -pthread/CNF_EX_LIBS=-lz\ -lsocket\ -lnsl\ -ldl\ -pthreads\ -lrt/g' ./Makefile.tmp1 > ./Makefile
# diff Makefile.original Makefile
126c126
< CNF_CFLAGS=-m64 -mcpu=ultrasparc -pthread
---
> CNF_CFLAGS=-m64 -mcpu=ultrasparc -pthreads
129c129
< CNF_EX_LIBS=-lz -lsocket -lnsl -ldl -pthread
---
> CNF_EX_LIBS=-lz -lsocket -lnsl -ldl -pthreads -lrt
うまくいきました。
再度コンパイルしてみます。
# /usr/ccs/bin/make
(略)
# echo $?
0
通ったようです。
テストしてみます。
# /usr/ccs/bin/make test
(略)
All tests successful.
Files=158, Tests=2632, 656 wallclock secs ( 3.09 usr 2.14 sys + 119.31 cusr 112.25 csys = 236.79 CPU)
Result: PASS
`test' is up to date.
テストも問題ないようです。
インストールします。
# /usr/ccs/bin/make install
確認します。
# /usr/local/openssl-1.1.1k/bin/openssl version
ld.so.1: openssl: 重大なエラー: libssl.so.1.1: open に失敗しました: ファイルもディレクトリもありません。
強制終了
失敗しました。
# ldd /usr/local/openssl-1.1.1k/bin/openssl
libssl.so.1.1 => (ファイルが見つかりません)
libcrypto.so.1.1 => (ファイルが見つかりません)
(略)
どうやら読み込まれていないようです。
# crle -64
デフォルト構成ファイル(/var/ld/64/ld.config) が見つかりません
Platform: 64-bit MSB SPARCV9
デフォルトライブラリパス (ELF): /lib/64:/usr/lib/64 (システムデフォルト)
トラステッドディレクトリ (ELF): /lib/secure/64:/usr/lib/secure/64 (システムデフォルト)
デフォルトライブラリパスにシンボリックリンクを貼れば動きそうです。
# cd /usr/lib/64
# ln -s /usr/local/openssl-1.1.1k/lib/libssl.so.1.1
# ln -s /usr/local/openssl-1.1.1k/lib/libcrypto.so.1.1
# ldd /usr/local/openssl-1.1.1k/bin/openssl
libssl.so.1.1 => /usr/lib/64/libssl.so.1.1
libcrypto.so.1.1 => /usr/lib/64/libcrypto.so.1.1
(略)
リンクされました。
改めて確認します。
# /usr/local/openssl-1.1.1k/bin/openssl version
OpenSSL 1.1.1k 25 Mar 2021
# /usr/local/openssl-1.1.1k/bin/openssl ciphers
TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:RSA-PSK-AES256-GCM-SHA384:DHE-PSK-AES256-GCM-SHA384:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:PSK-CHACHA20-POLY1305:RSA-PSK-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256:AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:ECDHE-PSK-AES256-CBC-SHA384:ECDHE-PSK-AES256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:SRP-AES-256-CBC-SHA:RSA-PSK-AES256-CBC-SHA384:DHE-PSK-AES256-CBC-SHA384:RSA-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA:AES256-SHA:PSK-AES256-CBC-SHA384:PSK-AES256-CBC-SHA:ECDHE-PSK-AES128-CBC-SHA256:ECDHE-PSK-AES128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:SRP-AES-128-CBC-SHA:RSA-PSK-AES128-CBC-SHA256:DHE-PSK-AES128-CBC-SHA256:RSA-PSK-AES128-CBC-SHA:DHE-PSK-AES128-CBC-SHA:AES128-SHA:PSK-AES128-CBC-SHA256:PSK-AES128-CBC-SHA
googleにTLS1.3で接続してみます。
# /usr/local/openssl-1.1.1k/bin/openssl s_client -connect www.google.co.jp:443 -tls1_3
(略)
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 256 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 20 (unable to get local issuer certificate)
---
read:errno=0
接続できているようです。
正常にインストールできたようです。
32bitコンパイルが必要なときはどうするか、というのは必要に迫られたら追記します。