変奏現実

パソコンやMMORPGのことなどを思いつくまま・・・記載されている会社名・製品名・システム名などは、各社の商標、または登録商標です。

この画面は、簡易表示です

NAS

gcc 9.2.0

Node.jsをコンパイルしたときにgccが古い!と指摘された。
wikiを見ると最新版は9.2なんだそうな。

ps. 今は、gcc-10.2.0 らしい。

インストしてみることにした。
参考:gccをソースからビルド/インストールする
ps.2019/11/26

1.ReadyRAS-212の/rootは容量が少ない(3.7GB)ので
エラーが出るから、/home/xxxxx(5.5TB:HDD容量に依る)で作成する。

/./mpfr/src/.libs -L/root/gcc-9.2.0/build/./mpc/src/.libs -lmpc -lmpfr -lgmp -rdynamic -ldl  -L./../zlib -lz libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
collect2: error: ld returned 1 exit status
../../gcc/lto/Make-lang.in:81: recipe for target 'lto1' failed

2.–prefix=/usr/localで、楽にシェルで使えるしようとすると
make install で失敗してしまった。
make uninstallが使えなくなっていたので、そのせいかもしれない。
–prefix=/usr/local/gcc-9.2.0にする。

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/plugin
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use :q, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[3]: Leaving directory '/home/****/gcc-9.2.0/build/libcc1'
make[2]: Leaving directory '/home/****/gcc-9.2.0/build/libcc1'
make[2]: Entering directory '/home/****/gcc-9.2.0/build/armv7l-unknown-linux-gnueabi/libgcc'
make[2]: *** No rule to make target 'install'.  Stop.
make[2]: Leaving directory '/home/****/gcc-9.2.0/build/armv7l-unknown-linux-gnueabi/libgcc'
Makefile:14301: recipe for target 'install-target-libgcc' failed
make[1]: *** [install-target-libgcc] Error 2
make[1]: Leaving directory '/home/****/gcc-9.2.0/build'
Makefile:2349: recipe for target 'install' failed
make: *** [install] Error 2

ついでなのでお行儀よくsudoを使うようにしてみた。
※CentOSならグループはwheel。
※Ubuntuは、usemod -G のパラメータの順序が逆だそうで非常に危険。

$ su -
# apt-get install sudo
# usermod -G sudo ${development-user}
# exit
$ exit

再構築直後のHDD(6TB×2)の状況をメモ

# df -H
Filesystem      Size  Used Avail Use% Mounted on
udev             11M  4.1k   11M   1% /dev
/dev/md0        4.0G  542M  3.2G  15% /
tmpfs           1.1G  8.2k  1.1G   1% /dev/shm
tmpfs           1.1G  377k  1.1G   1% /run
tmpfs           529M  1.1M  528M   1% /run/lock
tmpfs           1.1G     0  1.1G   0% /sys/fs/cgroup
/dev/md127      6.0T   20M  6.0T   1% /data
/dev/md127      6.0T   20M  6.0T   1% /apps
/dev/md127      6.0T   20M  6.0T   1% /home

※以下、開発用ユーザでログイン。
※usemodの指定は指定後にログインしないと無効。
gccのビルドに必要なパッケージをインストール
libnss-mdnsもあった方がいいような気はしている。

$ sudo apt-get install build-essential
$ sudo apt-get install libssl-dev
$ wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-9.2.0/gcc-9.2.0.tar.gz
$ tar xvzf gcc-9.2.0.tar.gz
$ cd gcc-9.2.0

gccのビルドに必要なパッケージやモジュールをダウンロード

$ ./contrib/download_prerequisites
2019-11-26 21:42:37 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]
2019-11-26 21:42:40 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1]
2019-11-26 21:42:43 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1]
2019-11-26 21:42:47 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291] -> "./isl-0.18.tar.bz2" [1]
gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.18.tar.bz2: OK
All prerequisites downloaded successfully.

ビルド用のディレクトリを作成し、移動して設定
※32bitなので–disable-multilibで失敗しないハズなので指定しない。

$ mkdir build
$ cd build
$ ../configure --enable-languages=c,c++ --prefix=/usr/local/gcc-9.2.0 --disable-bootstrap

コンパイル

$ date; make; date
前回:Sat Nov  9 23:25:55 JST 2019 ~ Sun Nov 10 01:58:37 JST 2019
今回:Tue Nov 26 21:44:02 JST 2019 ~ Wed Nov 27 00:16:30 JST 2019

2時間かな。今回はNASが同期中だったので3時間かかっている。

$ date; sudo make install; date
前回:Sun Nov 10 05:39:48 JST 2019 ~ Sun Nov 10 05:41:12 JST 2019
今回:Wed Nov 27 00:31:58 JST 2019 ~ Wed Nov 27 00:33:21 JST 2019

確認してみると

$ gcc --version
gcc (Debian 4.9.2-10+deb8u2) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

古いgccが呼び出される

$ /usr/local/gcc-9.2.0/bin/gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

パスが通っていないので、viで ~/.bash_profile を作って
export PATH=/usr/local/gcc-9.2.0/bin:$PATH
を追加。再ログインして確認

$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

しかし、このままではincludeやlibや共通ライブラリィが古いバージョンのものを使いそうだ。どの辺にあるのかな?

$ sudo find / -name stdio.h -print
/home/****/gcc-9.2.0/fixincludes/tests/base/stdio.h
/home/****/gcc-9.2.0/fixincludes/tests/base/rtldef/stdio.h
/home/****/gcc-9.2.0/libstdc++-v3/include/tr1/stdio.h
/home/****/gcc-9.2.0/libstdc++-v3/include/c_compatibility/stdio.h
/home/****/gcc-9.2.0/libssp/ssp/stdio.h
/home/****/gcc-9.2.0/build/armv7l-unknown-linux-gnueabi/libstdc++-v3/include/tr1/stdio.h
/run/nfs4/home/****/gcc-9.2.0/fixincludes/tests/base/stdio.h
/run/nfs4/home/****/gcc-9.2.0/fixincludes/tests/base/rtldef/stdio.h
/run/nfs4/home/****/gcc-9.2.0/libstdc++-v3/include/tr1/stdio.h
/run/nfs4/home/****/gcc-9.2.0/libstdc++-v3/include/c_compatibility/stdio.h
/run/nfs4/home/****/gcc-9.2.0/libssp/ssp/stdio.h
/run/nfs4/home/****/gcc-9.2.0/build/armv7l-unknown-linux-gnueabi/libstdc++-v3/include/tr1/stdio.h
/data/home/****/gcc-9.2.0/fixincludes/tests/base/stdio.h
/data/home/****/gcc-9.2.0/fixincludes/tests/base/rtldef/stdio.h
/data/home/****/gcc-9.2.0/libstdc++-v3/include/tr1/stdio.h
/data/home/****/gcc-9.2.0/libstdc++-v3/include/c_compatibility/stdio.h
/data/home/****/gcc-9.2.0/libssp/ssp/stdio.h
/data/home/****/gcc-9.2.0/build/armv7l-unknown-linux-gnueabi/libstdc++-v3/include/tr1/stdio.h
/usr/include/c++/4.9/tr1/stdio.h
/usr/include/arm-linux-gnueabi/bits/stdio.h
/usr/include/stdio.h
/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/include/ssp/stdio.h
/usr/local/gcc-9.2.0/include/c++/9.2.0/tr1/stdio.h

実際どうなんだろう。

$ gcc -v a.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/lto-wrapper
Target: armv7l-unknown-linux-gnueabi
Configured with: ../configure --enable-languages=c,c++ --prefix=/usr/local/gcc-9.2.0 --disable-bootstrap
Thread model: posix
gcc version 9.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'
 /usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi a.c -quiet -dumpbase a.c -mcpu=arm10tdmi -mtls-dialect=gnu -marm -march=armv5t -auxbase a -version -o /tmp/ccRJs92o.s
GNU C17 (GCC) version 9.2.0 (armv7l-unknown-linux-gnueabi)
        compiled by GNU C version 4.9.2, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/../../../../armv7l-unknown-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/include
 /usr/local/include
 /usr/local/gcc-9.2.0/include
 /usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/include-fixed
 /usr/include/arm-linux-gnueabi
 /usr/include
End of search list.
GNU C17 (GCC) version 9.2.0 (armv7l-unknown-linux-gnueabi)
        compiled by GNU C version 4.9.2, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 20ffebffab78fa72e422119a97fa84c2
COLLECT_GCC_OPTIONS='-v' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'
 as -v -march=armv5t -meabi=5 -o /tmp/ccmD4DyI.o /tmp/ccRJs92o.s
GNU assembler version 2.25 (arm-linux-gnueabi) using BFD version (GNU Binutils for Debian) 2.25
COMPILER_PATH=/usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/:/usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/:/usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/:/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/:/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/
LIBRARY_PATH=/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/:/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/../../../:/lib/arm-linux-gnueabi/:/lib/:/usr/lib/arm-linux-gnueabi/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'
 /usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/collect2 -plugin /usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/liblto_plugin.so -plugin-opt=/usr/local/gcc-9.2.0/libexec/gcc/armv7l-unknown-linux-gnueabi/9.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpu0ZV5.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi /usr/lib/arm-linux-gnueabi/crt1.o /usr/lib/arm-linux-gnueabi/crti.o /usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/crtbegin.o -L/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0 -L/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/../../.. -L/lib/arm-linux-gnueabi -L/usr/lib/arm-linux-gnueabi /tmp/ccmD4DyI.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/crtend.o /usr/lib/arm-linux-gnueabi/crtn.o
COLLECT_GCC_OPTIONS='-v' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'

/usr/local/gcc-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabi/9.2.0/includeに

aaa.hを作り、int aaa=123; と書いて、
#include <aaa.h>
printf(“aaa=%d\n”,aaa);
をコンパイルすれば通る。

但し、stdio.hはそこには無いので、/usr/includeのstdio.hが使われる。

ps.2019/11/28

sudo でgcc-9.2.0を使うために

/etc/sudoers を修正

Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
↓
Defaults	secure_path="/usr/local/gcc-9.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Node.jsの記事にもあるように
/etc/ld.so.conf.dにgcc-9.2.0用のファイルを作っておく。

# gcc-9.2.0 configuration
/usr/local/gcc-9.2.0/lib

そして
$ sudo ldconfig



nginx

参考 nginx の最新版を Ubuntu 18.04 に apt インストールする

公式nginxをRedayNAS-212のリポジトリにnginxの配布キーを追加して自動インストールする方法です。

sources.list の中がdebian jessieだらけなので debianにしてもubuntuにしても サポート外判定でした。

# (1) Ubuntu に nginx リポジトリを登録する
# wget https://nginx.org/keys/nginx_signing.key
# apt-key add nginx_signing.key
# (2) リポジトリを一覧に追加
# vi /etc/apt/sources.list で下の行を追加
deb http://nginx.org/packages/debian/ jessie nginx
または
deb http://nginx.org/packages/ubuntu/ jessie nginx
# (3) アップデートで、nginxをインストール
# apt update

# apt update
Hit:1 http://security.debian.org jessie/updates InRelease
Ign:2 http://mirrors.edge.kernel.org/debian jessie InRelease
Get:3 http://nginx.org/packages/debian jessie InRelease [2,856 B]
Hit:4 http://mirrors.edge.kernel.org/debian jessie Release
Hit:5 https://apt.readynas.com/packages/readynasos 6.10.2 InRelease
Fetched 2,856 B in 1s (2,356 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
22 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Skipping acquire of configured file 'nginx/binary-armel/Packages' as repository 'http://nginx.org/packages/debian jessie InRelease' doesn't support architecture 'armel'
N: Skipping acquire of configured file 'nginx/binary-armhf/Packages' as repository 'http://nginx.org/packages/debian jessie InRelease' doesn't support architecture 'armhf'

またコンパイルするのか・・・
その前にツールでOSのバージョンを確認。

# apt-get install lsb-release
lsb_release -a
 No LSB modules are available.
 Distributor ID: Debian
 Description:    Debian GNU/Linux 8.11 (jessie)
 Release:        8.11
 Codename:       jessie
# apt-get update
# apt-get build-dep nginx
# apt-get source nginx
# cd nginx-1.17.0
# sudo dpkg-buildpackage -uc -b
# cd
# sudo dpkg -i nginx_1.17.0-1~stretch_armhf.deb

apt-get install debian-keyring
でもダメ

# wget http://nginx.org/download/nginx-1.16.1.tar.gz
# tar xvzf nginx-1.16.1.tar.gz
# cd nginx-1.16.1
# ./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

正規表現ライブラリィが必須らしい。

# apt-get install libpcre3 libpcre3-dev
#./configure
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

zlibパッケージの取得

# apt-get install zlib1g-dev

openssh1.1.0のインストール

# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
# tar xvzf openssl-1.1.0f.tar.gz
# cd openssl-1.1.0f/
# ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
# make
# make install

必要そうなパッケージを入れたのでコンパイルしてみる。

# cd
# cd nginx-1.16.1
# ./configure
#  make
# make install

普通にコンパイルできた。
参考 ソースファイルからnginxのインストール

インストしたパッケージを使う様に
openSSLとスレッドプールを設定に追加してみる。

# cd
# cd nginx-1.16.1
# make clean
# ./configure  --with-openssl=/usr/local/src/openssl
-1.1.0f --with-threads
checking for OS
 + Linux 4.4.184.alpine.1 armv7l
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.9.2 (Debian 4.9.2-10+deb8u2)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... not found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... not found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile
Configuration summary
  + using threads
  + using system PCRE library
  + using OpenSSL library: /usr/local/src/openssl-1.1.0f
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
# make
# make install
# cd /usr/local/nginx/sbin
# nginx -V
built by gcc 4.9.2 (Debian 4.9.2-10+deb8u2)



Python-3.8.0 OpenSSLでハマる

ReadyNas のアプリにはPython ver.2.xがあるがver.3.xは無い。

メンドクサイのかなと思ったら

$ sudo apt install python3
Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following additional packages will be installed:
   dh-python libmpdec2 libpython3-stdlib libpython3.4-minimal
   libpython3.4-stdlib python3-minimal python3.4 python3.4-minimal
 Suggested packages:
   python3-doc python3-tk python3-venv python3.4-venv python3.4-doc binutils
   binfmt-support
 The following NEW packages will be installed:
   dh-python libmpdec2 libpython3-stdlib libpython3.4-minimal
   libpython3.4-stdlib python3 python3-minimal python3.4 python3.4-minimal
 0 upgraded, 9 newly installed, 0 to remove and 24 not upgraded.
 Need to get 4,276 kB of archives.
 After this operation, 17.5 MB of additional disk space will be used.
 Do you want to continue? [Y/n] y
・・・
$ python3  --version
Python 3.4.2

簡単だった。

元ネタ:Ubuntu18.04にPyhton3.7を導入や設定をしよう!

ps. 2019/11/27
ソースからコンパイルしてみる
ソースからPythonをインストール

ビルドに必要なパッケージが足りないらしいのでインストする。
元ネタは見つかっていない。
参考:Ubuntu環境のPython

sudo apt install build-essential libbz2-dev libdb-dev \
  libreadline-dev libffi-dev libgdbm-dev liblzma-dev \
  libncursesw5-dev libsqlite3-dev libssl-dev \
  zlib1g-dev uuid-dev tk-dev

では設定してコンパイル

$ sudo curl -O https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
$ sudo tar Jxf Python-3.8.0.tar.xz
$ cd Python-3.8.0
$ sudo ./configure --prefix=/usr/local/python380 --with-ensurepip --enable-optimizations
・・・
$ date; sudo make ; date
・・・
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_ssl
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd
time
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
・・・
Wed Nov 27 21:41:47 JST 2019 ~ Wed Nov 27 21:53:28 JST 2019

実は初回コンパイル時に

If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations

と出力されたのて、–enable-optimizations を付けた。

上の Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl は
$ sudo apt-get install libssl-dev 済みだけど中身が
libssl-dev is already the newest version (1.0.1t-1+deb8u12).
と少し古いだけなのに新しいVersionを探さないといけないらしい。
なんとかopensslの1.0.2や1.1.dをインストールしても
sudo make は1.0.2か1.1以上を求めてくるので、
configureに
LDFLAGS=”-L/usr/local/openssl-1.1.1d/lib” CFLAGS=”-I/usr/local/openssl-1.1.1d/include”
を付けたが
流れるログを見ると

/include が取れていた。

多分 /libも取れる

ダメです。

諦めつつもconfigureを読むと
–with-openssl というOpenSSLのパスを指定するオプションがあった。

$ sudo ./configure --prefix=/usr/local/python380 --with-ensurepip --enable-optimizations --with-openssl="/usr/local/openssl-1.1.1d"
$ grep OPENSSL  Makefile
OPENSSL_INCLUDES=-I/usr/local/openssl-1.1.1d/include
OPENSSL_LIBS=-lssl -lcrypto
OPENSSL_LDFLAGS=-L/usr/local/openssl-1.1.1d/lib
$ sudo make
$ sudo make install



Node.js ABC順でハマる

$ uname -a
 Linux ****** 4.4.184.alpine.1 #1 SMP Thu Sep 5 02:32:14 UTC 2019 armv7l GNU/Linux

armv71.CPUの分類が判ったので、
公式サイトからArmV71用をダウンロード。

インストール方法を見ながら、やってみたものの。結果は

# node -bash: /usr/local/lib/nodejs/node-v12.13.0-linux-armv7l/bin/node: No such file or directory

Ubuntu(for Armv7l)のリポジトリィを漁ってみると

# apt-get update
# apt-get install nodejs npm
# nodejs -v
v0.10.29

さすがにコレは古いが、開発キットをインストしてみると、

# apt-get install build-essential
# gcc --version
gcc (Debian 4.9.2-10+deb8u2) 4.9.2
# g++ --version
g++ (Debian 4.9.2-10+deb8u2) 4.9.2
# make --version
GNU Make 4.0
# apt-get install openjdk*
# java -version
java version "1.7.0_231"
# python --version ※これは管理画面からインスト
Python 2.7.9

32ビットCPUなんで全てが古いらしい。
Node.jsのソースからビルドする際に要求に
gcc and g++ >= 6.3 or newer, or
があるので致命的。
しかも、ie同様にarrow関数が使えないから全部function()で書かないといけないのは辛いので「パッケージマネージャを利用した Node.js のインストール」から「 Node.js 公式のバイナリディストリビューション 」の「Manual installation」を読んでみたが失敗。

armel で、引っかかってしまう。
Available architectures: を見ると未サポートで、
ラズパイの様にarmhf(ハードウェアFPU付)だったら良かったらしい。

キモは、
export でCCFLAGSとCXXFLAGSを指定することだった。
Rasbery-Pi/Zeroなら

# export CCFLAGS='-march=armv6'
# export CXXFLAGS='-march=armv6'

とするらしい。
gccが9.2.0でもコレは同じ。
しかし、ReadyNAS212のCPUは ARM Cortex A15。
Wikiによれば、
 ファミリー : Cortex-A
 アーキテクチャ: v7-A
 コア : Cortex A15
と云うことで、
こんぱいらの ターゲットアーキテクチャの指定 から
CCFLAGSは、 ‘-march=armv7-a’ なのだそうだ。
Node.jsのコミュニティを眺めてたら、
ん~な古いCPUの需要あるの?あるならやるかも。と、書いてあったので、
新しいVerで試してみた。
※wgetしたので、git-coreは要らない。
なお、コンパイルに要した時間は3時間を超えており、make install もログが長い。

最終的にはこれでOK。

$ sudo apt-get install git-core build-essential libssl-dev
$ # sudo wget https://nodejs.org/dist/v12.13.1/node-v12.13.1.tar.gz
$ # sudo tar xvzf node-v12.13.1.tar.gz
$ # cd node-v12.13.1
$ sudo wget https://nodejs.org/dist/v12.18.3/node-v12.18.3.tar.gz
$ sudo tar xvzf node-v12.18.3.tar.gz
$ cd node-v12.18.3
$ export CCFLAGS='-march=armv7-a'
$ export CXXFLAGS='-march=armv7-a'
$ sudo -E ./configure
$ sudo -E make -j8
$ sudo -E make install
$ node --version
v12.13.1
$ npm --version
6.12.1

-j8は8スレッド使用かな?付けない時よりはログの流れが速いし、topコマンドで見る限り、指定有:97%、無:24%。8コアじゃないから-j4で十分。
かかった時間も 指定有:1時間半、無:3時間だから -j2で良かったかも。

以下は、トラブル履歴。

トラブル 1.一般ユーザからsudoを使ってビルドすると古いgccが使われてしまう。
-Eを付けてもPATHだけは置き換えられてしまうので、
/etc/sudoers のパスに/usr/local/gcc-9.2.0/binを追加。

# cd node-v12.13.1
# ./configure    ※要python
WARNING: C++ compiler too old, need g++ 6.3.0 or clang++ 8.0.0 (CXX=g++)
INFO: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
INFO: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
WARNING: warnings were emitted in the configure phase
INFO: configure completed successfully
※gcc 9.2.0の場合
INFO: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
INFO: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
INFO: configure completed successfully

しかし、うまくいかない。

Error: selected processor does not support ARM mode `bkpt 0'

この直後にrootでログインしても

libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by

apt-get install libstdc++6
はインスト済みだが、リポジトリィのものはかなり古いようだ。
gcc-9.2.0のターゲットは /usr/local/gcc-9.2.0 だったので、
export LD_LIBRARY_PATH=/usr/local/gcc-9.2.0/lib:$LD_LIBRARY_PATH
でやり過ごそうとしたが
無駄。
やはり古いのを見てしまう。
というか仕様になっていた。
一般のユーザの~/.bash_profileなどに書くとうまくいく場合もあるらしいが

$ echo $LD_LIBRARY_PATH
/usr/local/gcc-9.2.0/lib:

トラブル2. LD_LIBRARY_PATH は効かない。

LD_LIBRARY_PATHが空っぽの時点で察する必要があった。
このNASのLinuxでは、LD_LIBRARY_PATH環境変数は一般の環境変数でしかないのだった。

どうやら、ldconfigの出番の様だ。gcc-9.2.0と心中するつもりで取り掛かるしかないのだ。

しかし、今は/etc/ld.so.confに直書きするのではなく、

/etc/ld.so.conf.dにgcc-9.2.9.confを追加するのが通らしい。

# gcc-9.2.0 configuration
/usr/local/gcc-9.2.0/lib

そして、共有ライブラリィのリンクを入れ替える

# ldconfig
/sbin/ldconfig.real: /usr/local/gcc-9.2.0/lib/libstdc++.so.6.0.27-gdb.py is not an ELF file - it has the wrong magic bytes at the start.
/sbin/ldconfig.real: /usr/lib/libreadycloud.so.1 is not a symbolic link

これでも、

$ sudo -E ldconfig -p | grep libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/lib/arm-linux-gnueabi/libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/local/gcc-9.2.0/lib/libstdc++.so.6

となって古いものを見てしまう。
/etc/ld.so.conf の中身が

include /etc/ld.so.conf.d/*.conf

なので、arm-linux-gnueabi.conf より文字コードが前になりそうな
__ gcc-9.2.9.conf に名を変えたが無駄足で、
結局  ls -l /etc/ld.so.conf.d/*.conf の結果 を見ながらファイル名を変えて、

arm-gcc-9.2.9.conf が正解!

奥が深いというより、
デフォのgccのファイル名が linux-gnueabi.conf ならOKだが、
arm- linux-gnueabi.conf なら誰もが失敗する。
こんな設定ファイルの読込み順で、共有ライブラリィのパスが決まるのって

間抜けとしか云いようがない

否、今は
include  *****/*.conf
が普通なのだから、昨今のlinuxのノウハウの半分を占めている可能性が高い。
※とっても低レベルだが、

決して、侮れないノウハウだ。

ファイル名を linux-arm-gnueabi.conf に変えるだけで誰もが幸せになれるのにね?でも、ダレもそんなことはしないのが世の常。

$ sudo -E ldconfig -p | grep libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/local/gcc-9.2.0/lib/libstdc++.so.6
        libstdc++.so.6 (libc6,soft-float) => /usr/lib/arm-linux-gnueabi/libstdc++.so.6

とりあえず、バイトコード生成をコメントアウトしなくて済むようになったので、リモートデバッグもできるようになるだろう。
※ソースをNFSの共有フォルダに配置しなければいけない問題はあるけど。

そして、長いコンパイルはまだまだ3時間くらい続くはずだ。

sudo make test
=== release test-perf-hooks ===
Path: sequential/test-perf-hooks
{
  name: 'node',
  entryType: 'node',
  startTime: 0,
  duration: { around: 144.90792298316956 },
  nodeStart: { around: 0 },
  v8Start: { around: 0 },
  bootstrapComplete: { around: 135.9222869873047, delay: 2500 },
  environment: { around: 0 },
  loopStart: -1,
  loopExit: -1
}
{
  name: 'node',
  entryType: 'node',
  startTime: 0,
  duration: { around: 1163.1746279895306 },
  nodeStart: { around: 0 },
  v8Start: { around: 0 },
  bootstrapComplete: { around: 135.9222869873047, delay: 2500 },
  environment: { around: 0 },
  loopStart: { around: 135.9222869873047, delay: 2500 },
  loopExit: -1
}
{
  name: 'node',
  entryType: 'node',
  startTime: 0,
  duration: { around: 1165.5776199996471 },
  nodeStart: { around: 0 },
  v8Start: { around: 0 },
  bootstrapComplete: { around: 135.9222869873047, delay: 2500 },
  environment: { around: 0 },
  loopStart: { around: 135.9222869873047, delay: 2500 },
  loopExit: { around: 1165.6191799938679 }
}
assert.js:374
    throw err;
    ^
AssertionError [ERR_ASSERTION]: duration: 389.13076999783516 >= 250
    at checkNodeTiming (/home/****/node-v12.13.1/test/sequential/test-perf-hooks.js:67:7)
    at process.<anonymous> (/home/****/node-v12.13.1/test/sequential/test-perf-hooks.js:108:3)
    at process.emit (events.js:215:7) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}
Command: out/Release/node /home/****/node-v12.13.1/test/sequential/test-perf-hooks.js
[09:26|% 100|+ 2776|-   1]: Done
Makefile:296: recipe for target 'jstest' failed
make[1]: *** [jstest] Error 1
Makefile:316: recipe for target 'test' failed
make: *** [test] Error 2

ダメっぽいが、何がダメなのか判らないので、インストして終了。

OpenSSLの指定方法が不明だったので、
apt-get でインストした libssl-dev(1.0.1t-1+deb8u12)を使うことになる。

$ openssl version
OpenSSL 1.0.1t 3 May 2016

/etc/sudoersにコンパイルしたOpenSSLのパスを追加すればいいかな
Defaults secure_path=”/usr/local/openssl-1.0.2t/bin:
にすると
$ sudo openssl version
OpenSSL 1.0.2t 10 Sep 2019

やっぱりもっと新しい方がいいような
Defaults secure_path=”/usr/local/openssl-1.1.1d/bin:
OpenSSL 1.1.1d 10 Sep 2019
にしておこう。

ldconfigで書き換えてるし、rootも設定しておくか

export PATH=/usr/local/openssl-1.1.1d/bin:/usr/local/gcc-9.2.0/bin:$PATH


MySql&PhpMyAdmin

今更Ver1.0.1って何?
実際はVer5.5らしい

待っていると、無事インストールが終わり管理画面が書き換わる。

では設定してみよう【設定】をポチ

そうそう、設定をしないと。

ナンテこったい

さて、どうしよう。このNASのrootのパスワードは判らないので、アプリにphpMyAdminをインスト。

MySQLユーザのrootはパスワードなしでログインできるから、データベースもテーブルも作れるから、これでいいかな。ポートは閉じているし。(笑



【NETGEAR】ReadyNAS 212

暫く20K円で停滞したままで忘れてたが、

Amazonのプライムデーで16Kだったのでポチってしまった。

10TBのHDDに対応らしいが・・・

ApacheやPHPやMySQLとか懐かしい パッケージをダウンロードして組み込める様だ。これにWEBメーラを組み込んでMySQLに ThunderBirdやOutlookとかに散らばってるメールを ダウンロードするような仕組みを作ってメールのサーバーにしてもいいだろう。詳しくはNASを立ち上げて、Appsからダウンロードできるアプリ・リスト次第かな?

だがもうPHPは触手気味だ。

Pythonはあるようだが、JDKは無いようだ。でもOpenJDK(ARM版)を勝手に入れればいいのかな?

node.jsも無いがソースからビルドできればいけるかもしれない。

ダメならDocker(当然x86_64のみのハズ)さえ使えれば自力でNode.jsのインスタンスを作ればいいのかもしれない。

とりあえずは放置してある1TBのUSB-HDDを分解してHDDを取り出し、このNASに放り込もうと思う。

こんな面倒なことをしなくても、中古PCにCentOS7.6を入れてしまえば開発環境はyumで済むハズだが、そこそこ使える性能が出るなら、HDDがクラッシュしても壊れた方のHDDを差し替えてX-RAIDのお手軽(でも長時間)な復元できそうなトコが魅力である。

ps.1

本体が届いてみると、勿体ないので、ドスパラでWD60EZAZ-RT WD Blue-6TB(FL)を1台買って取り付けた。

新品HDDだったせいか、OSのセットアップはYoutobeの動画を観れば簡単だ、すぐ完了。
※観なかったらいつまでもHDDを取り付けられなかった様な気がする
※ファームウェアを6.9.1から6.10.1にアップグレードするには再起動を挟んで30分づつ=1時間かと思ったが

再起動した後は一旦、readycloud.netgear.comのTOP画面から再ログインが必要なようだ。

さて今AMAZONを見ると ¥ 28,078 になっていた。

やっぱりNASは高いと思ったら、1ドライブな
BUFFALO NAS スマホ/タブレット/PC対応 ネットワークHDD 3TB LS210D0301G が安くていいかもしれない。しかし中のHDDがクラッシュしたらどうしようもない。

Ready NAS 212はX-RAID構成なので、HDD2台なら片方壊れても復旧する可能性がある。

しかし、 Ready NAS 212 自体が壊れた場合は修理できるもののデータは保証されませんので、やはりバックアップは必須ですが、気が向いた時に古いHDDにドドっとバックアップすればいいんじゃないかな?

管理者画面へ移動するには NASのIPアドレスのトップページに移動しないと開けない。
× http://192.168.*.***/
〇 http://192.168.*.***/index.html

※個人の主観的な感想です。

ps.2

NASはAmazonで、1つ目のHDDはドスパラで買ったので、2つ目はツクモで購入。型番もファームウェアのバージョンも全く同じだ。2台目を取り付けて電源を入れると、自動的に同期を取り始めてくれるのはありがたい。しかし容量(6TB)のせいか?24時間ぐらいかかりそう。同期中は反応も鈍いが、色々不都合がおきるらしい。ブラウザを閉じてから、ReadyCLOUDを見るとNASが見えなくなっているのでBackUPボタンを6秒押して再認識させないといけない。

PS.
電源スイッチから電源OFFできないと思ったら
とりあえず押す。
そしてランプが点滅中にもう一度押さなければいけない。
どうやらうっかり押してしまった時の備えなんだろう。




top