CentOS编译安装tree.1.8
安装相关依赖包
[root@centos8 ~]# yum install gcc make
查看当前版本信息
[root@centos8 ~]# yum info tree
Last metadata expiration check: 0:01:52 ago on Sun 20 Dec 2020 09:08:04 PM CST.
Installed Packages
Name : tree
Version : 1.7.0
Release : 15.el8
Architecture : x86_64
Size : 109 k
Source : tree-1.7.0-15.el8.src.rpm
Repository : @System
From repo : anaconda
Summary : File system tree viewer
URL : http://mama.indstate.edu/users/ice/tree/
License : GPLv2+
Description : The tree utility recursively displays the contents of directories in a
: tree-like format. Tree is basically a UNIX port of the DOS tree
: utility.
下载源码
[root@centos8 apps]# wget http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz
--2020-12-20 21:11:32-- http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz
Resolving mama.indstate.edu (mama.indstate.edu)... 139.102.70.201
Connecting to mama.indstate.edu (mama.indstate.edu)|139.102.70.201|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50286 (49K) [application/x-gzip]
Saving to: ‘tree-1.8.0.tgz’
tree-1.8.0.tgz 100%[============================================>] 49.11K 26.7KB/s in 1.8s
2020-12-20 21:11:34 (26.7 KB/s) - ‘tree-1.8.0.tgz’ saved [50286/50286]
解压缩
[root@centos8 apps]# tar -xf tree-1.8.0.tgz
查看安装帮助
[root@centos8 apps]# ls
tree-1.8.0 tree-1.8.0.tgz
[root@centos8 apps]# cd tree-1.8.0/
[root@centos8 tree-1.8.0]# ls
CHANGES doc hash.c INSTALL LICENSE README TODO tree.h xml.c
color.c file.c html.c json.c Makefile strverscmp.c tree.c unix.c
[root@centos8 tree-1.8.0]# cat INSTALL
Installation instructions:
1. Edit the Makefile for your OS. Comment out the Linux options and un-comment
the options for your OS.
2. Type: make
3. Type: make install
4. Enjoy colorful directory trees.
I cannot test on non-Linux machines, so please feel free to contribute
porting information, bug reports, compile options, patches, etc for porting to
other OS's to ice@mama.indstate.edu.
I would also welcome any localization efforts, particularly translating the
man page to other languages. And of course feel free to suggest options and
improvements you would like to see in tree.
修改配置文件
[root@centos8 tree-1.8.0]# vim Makefile
prefix = /apps/tree
编译
[root@centos8 tree-1.8.0]# make
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o unix.o unix.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o html.o html.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o xml.o xml.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o json.o json.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o hash.o hash.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o color.o color.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o file.o file.c
gcc -o tree tree.o unix.o html.o xml.o json.o hash.o color.o file.o
安装
[root@centos8 tree-1.8.0]# make install
install -d /apps/tree/bin
install -d /apps/tree/man/man1
if [ -e tree ]; then \
install tree /apps/tree/bin/tree; \
fi
install doc/tree.1 /apps/tree/man/man1/tree.1
修改PATH
#方法一:新增文件
[root@centos8 bin]# echo 'PATH=/apps/tree/bin:$PATH' > /etc/profile.d/tree.sh
#方法二:软连接
[root@centos8 bin]# ln -s /apps/tree/bin/tree /usr/local/bin
验证
[root@centos8 bin]# hash -d tree
[root@centos8 bin]# tree --version
tree v8.8.8 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
添加man帮助
[root@centos8 bin]# man tree
No manual entry for tree
[root@centos8 bin]# vim /etc/man_db.conf
MANDATORY_MANPATH /apps/tree/man
[root@centos8 bin]# man tree
运行命令
[root@centos8 bin]# tree /apps/tree/bin
/apps/tree/bin
└── tree
0 directories, 1 file