過程:
原本找了一台小機器 Ubuntu 18.04 編譯,結果一直出錯,最後還是找個乾淨的機器,一下就搞定。這次用 libevent-2.1.12-stable 時,先略過 openssl 編譯 ,雖然編 openssl 也沒那麼難,但就是這麼懶 XD
Docker 流水帳:
% docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
10175de2f0c4: Pull complete
Digest: sha256:9dc05cf19a5745c33b9327dba850480dae80310972dea9b05052162e7c7f2763
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
% docker run -it --platform linux/amd64 -p 10022:22 -p 18000:8000 ubuntu:22.04
# apt update && apt upgrade -y && apt install -y lsb-release net-tools
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
# apt install -y gcc g++ make python3 tmux vim git wget xz-utils file
開工:
# cd ~/
# wget https://global.download.synology.com/download/ToolChain/toolchain/7.1-42661/AMD%20x86%20Linux%204.4.180%20%28r1000%29/r1000-gcc850_glibc226_x86_64-GPL.txz
# tar -xvf r1000-gcc850_glibc226_x86_64-GPL.txz
# cd ~/
# wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.4.tar.gz
# tar -xvf ncurses-6.4.tar.gz
# cd ncurses-6.4
~/ncurses-6.4# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-lix-gnu/include" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/
~/ncurses-6.4# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2 install
# cd ~/
# wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
# tar -xvf libevent-2.1.12-stable.tar.gz
# cd libevent-2.1.12-stable
~/libevent-2.1.12-stable# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-lix-gnu/include" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/ --disable-openssl
~/libevent-2.1.12-stable# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2 install
# cd ~/
# wget https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz
# tar -xvf tmux-3.3a.tar.gz
# cd tmux-3.3a
~/tmux-3.3a# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-linux-gnu/include -I$HOME/x86_64-pc-linux-gnu/include/ncurses" LDFLAGS="-L$HOME/x86_64-pc-linux-gnu/lib" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/ --enable-static
~/tmux-3.3a# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2
...
x86_64-pc-linux-gnu-gcc -std=gnu99 -O2 -I/root/x86_64-pc-linux-gnu/include -I/root/x86_64-pc-linux-gnu/include/ncurses -static -L/root/x86_64-pc-linux-gnu/lib -o tmux alerts.o arguments.o attributes.o cfg.o client.o cmd-attach-session.o cmd-bind-key.o cmd-break-pane.o cmd-capture-pane.o cmd-choose-tree.o cmd-command-prompt.o cmd-confirm-before.o cmd-copy-mode.o cmd-detach-client.o cmd-display-menu.o cmd-display-message.o cmd-display-panes.o cmd-find-window.o cmd-find.o cmd-if-shell.o cmd-join-pane.o cmd-kill-pane.o cmd-kill-server.o cmd-kill-session.o cmd-kill-window.o cmd-list-buffers.o cmd-list-clients.o cmd-list-keys.o cmd-list-panes.o cmd-list-sessions.o cmd-list-windows.o cmd-load-buffer.o cmd-lock-server.o cmd-move-window.o cmd-new-session.o cmd-new-window.o cmd-parse.o cmd-paste-buffer.o cmd-pipe-pane.o cmd-queue.o cmd-refresh-client.o cmd-rename-session.o cmd-rename-window.o cmd-resize-pane.o cmd-resize-window.o cmd-respawn-pane.o cmd-respawn-window.o cmd-rotate-window.o cmd-run-shell.o cmd-save-buffer.o cmd-select-layout.o cmd-select-pane.o cmd-select-window.o cmd-send-keys.o cmd-server-access.o cmd-set-buffer.o cmd-set-environment.o cmd-set-option.o cmd-show-environment.o cmd-show-messages.o cmd-show-options.o cmd-show-prompt-history.o cmd-source-file.o cmd-split-window.o cmd-swap-pane.o cmd-swap-window.o cmd-switch-client.o cmd-unbind-key.o cmd-wait-for.o cmd.o colour.o control-notify.o control.o environ.o file.o format.o format-draw.o grid-reader.o grid-view.o grid.o input-keys.o input.o job.o key-bindings.o key-string.o layout-custom.o layout-set.o layout.o log.o menu.o mode-tree.o names.o notify.o options-table.o options.o paste.o popup.o proc.o regsub.o resize.o screen-redraw.o screen-write.o screen.o server-acl.o server-client.o server-fn.o server.o session.o spawn.o status.o style.o tmux.o tty-acs.o tty-features.o tty-keys.o tty-term.o tty.o utf8.o window-buffer.o window-client.o window-clock.o window-copy.o window-customize.o window-tree.o window.o xmalloc.o osdep-linux.o compat/closefrom.o compat/fgetln.o compat/freezero.o compat/getdtablecount.o compat/getpeereid.o compat/getprogname.o compat/setproctitle.o compat/strlcat.o compat/strlcpy.o compat/strtonum.o compat/recallocarray.o compat/getopt.o compat/imsg.o compat/imsg-buffer.o compat/vis.o compat/unvis.o compat/fdforkpty.o -lutil -lncurses -levent_core -lm -lncurses -lresolv
cmd-parse.o: In function `yylex_token_tilde':
cmd-parse.c:(.text+0x61d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
cmd-parse.c:(.text+0x6a9): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `test_for_getaddrinfo_hacks':
evutil.c:(.text+0x1836): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `evutil_unparse_protoname':
evutil.c:(.text+0x1272): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `evutil_parse_servname':
evutil.c:(.text+0x11ee): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
~/tmux-3.3a# file tmux
tmux: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, with debug_info, not stripped
~/tmux-3.3a# python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
還記得當初跑 docker 時有把本機的 18000 port 對到裡頭的 8000 port ,這時就可以靠 http://localhost:18000/tmux 去下載 tmux 來用。
實際運行:
$ uname -a
Linux NAS 4.4.180+ #42962 SMP Thu Dec 8 21:34:11 CST 2022 x86_64 GNU/Linux synology_r1000_723+
$ ~/bin/tmux -V
tmux-tool 3.3a
另外,在 NAS 內運行時,可以多設定 shell 環境資訊:
$ cat ~/.profile
export PATH=$HOME/bin:$PATH
export TERM=xterm
收工!