查看当前的tree
[12:33:33 root@C8[ ~]#rpm -qi tree
Name : tree
Version : 1.7.0
Release : 15.el8
Architecture: x86_64
Install Date: Mon 16 Mar 2020 01:53:13 AM EDT
Group : Unspecified
Size : 111603
License : GPLv2+
Signature : RSA/SHA256, Mon 01 Jul 2019 09:53:45 PM EDT, Key ID 05b555b38483c65d
Source RPM : tree-1.7.0-15.el8.src.rpm
Build Date : Sat 11 May 2019 11:54:52 AM EDT
Build Host : x86-01.mbox.centos.org
Relocations : (not relocatable)
Packager : CentOS Buildsys <bugs@centos.org>
Vendor : CentOS
URL : http://mama.indstate.edu/users/ice/tree/
Summary : File system tree viewer
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.
发现版本是 Version : 1.7.0
通过官网找到最新版本为1.8
URL : http://mama.indstate.edu/users/ice/tree/
[12:33:45 root@C8[ ~]#wget http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz
--2020-04-08 12:34:46-- 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 6.86KB/s in 7.2s
2020-04-08 12:34:56 (6.86 KB/s) - ‘tree-1.8.0.tgz’ saved [50286/50286]
下载好以后原地解压文件
[12:34:58 root@C8[ ~]#tar -zxf tree-1.8.0.tgz
[12:35:24 root@C8[ ~]#ll
total 64
-rw-------. 1 root root 1184 Mar 16 01:56 anaconda-ks.cfg
-rw-r--r--. 1 root root 64 Mar 27 06:15 a.txt
-rw-r--r--. 1 root root 19 Mar 31 10:37 hello.o
drwxr-xr-x. 3 root root 250 Apr 8 12:35 tree-1.8.0
-rw-r--r--. 1 root root 50286 Nov 16 2018 tree-1.8.0.tgz
查看文件夹内容
[12:35:26 root@C8[ ~]#ll ./tree-1.8.0
total 184
-rw-r--r--. 1 4437 users 12024 Nov 16 2018 CHANGES
-rw-r--r--. 1 4437 users 16408 Nov 16 2018 color.c
drwxr-xr-x. 2 root root 52 Apr 8 12:35 doc
-rw-r--r--. 1 4437 users 7497 Jan 9 2018 file.c
-rw-r--r--. 1 4437 users 3151 Jan 10 2018 hash.c
-rw-r--r--. 1 4437 users 14404 Jan 10 2018 html.c
-rw-r--r--. 1 4437 users 597 Jan 3 2018 INSTALL
-rw-r--r--. 1 4437 users 9813 Jan 10 2018 json.c
-rw-r--r--. 1 4437 users 18009 Aug 12 2004 LICENSE
-rw-r--r--. 1 4437 users 2973 Jan 18 2018 Makefile
-rw-r--r--. 1 4437 users 5740 Jun 22 2015 README
-rw-r--r--. 1 4437 users 5322 Aug 27 2008 strverscmp.c
-rw-r--r--. 1 4437 users 2403 Feb 11 2015 TODO
-rw-r--r--. 1 4437 users 36839 Jan 10 2018 tree.c
-rw-r--r--. 1 4437 users 5593 Jan 10 2018 tree.h
-rw-r--r--. 1 4437 users 7651 Jan 10 2018 unix.c
-rw-r--r--. 1 4437 users 9029 Nov 16 2018 xml.c
查看README
[12:39:55 root@C8[ ~]#cat ./tree-1.8.0/README
Please read the INSTALL file for installation instructions, particularly if
you are installing on a non-Linux machine.
This is a handy little utility to display a tree view of directories that
I wrote some time ago and just added color support to. I've decided that
since no one else has done something similar I would go ahead and release
it, even though it's barely a 1st year CS student hack. I've found it damn
handy to peruse a directory tree though, especially when someone is trying to
hide something from you.
The main distribution site for tree is here:
http://mama.indstate.edu/users/ice/tree/
ftp://mama.indstate.edu/linux/tree/
If you don't like the way it looks let me know how you think it should be
formatted. Feel free to suggest modifications and additions.
Thanks go out so the following people who have helped bring tree to the
pinnacle of perfection that it is: ;)
Francesc Rocher
- Added HTML output (-H).
- Added options -o, -L and -R.
Gerald Scheidl
- Added -S option to print ASCII graphics lines for use under linux
console when an alternate console font has been selected (might also
work under DOS telnet).
Guido Socher (and others)
- Made tree more portable. Should compile under solaris.
Mitja Lacen
- Discovered bug where tree will segmentation fault on long pathnames.
- Discovered in -L argument processing.
Nathaniel Delage
- Discovered problem with recursive symlink detection
A. Karthik
- Suggested option to remove file and directory report at end of tree
listing.
Roger Luethi
- Spotted memory over-allocation bug in read_dir().
- Submitted several patches to fix various memory leaks.
Daniel Lee
- Reported that Tru64 defines TRUE/FALSE in sys/types.h (OSF1 standard?)
Paolo Violini
- Found bug in tree that caused it to seg-fault if 50 file arguments where
given and directory coloring was turned on.
Mitsuaki Masuhara
- Discovered tree crashed on missing arguments.
- Discovered that tree did not properly encode characters in filenames
when used as URLs when using the -H option.
- Fixed issue with --charset option processing.
Johan Fredrik
- Pointed out that tree did not list large files.
Ted Tiberio
- Submitted patch which fixed a compiler issue and cleaned up HTML and CSS
code, applied CSS to all output, and fixed up HTML to 4.01 strict
standards.
David MacMahon
- Added '|' support to the pattern matching routines.
Dan Jacobson
- Pointed out that -t did not sort properly for files with the same
timestamp.
- Suggested option to change HTML title and H1 string.
- Suggested -r option for reversed alphanumeric sort ala 'ls -r'.
Kyosuke Tokoro
- Provided patch to support OS/2, fix HTML encoding, provide charset
support. Added to authors list.
Florian Ernst
- Debian maintainer who pointed out problems and applied fire to feet to fix
stuff.
Jack Cuyler
- Suggested -h option for human readable output for -s, ala ls -lh.
Jonathon Cranford
- Supplied patch to make tree under cygwin.
Richard Houser
- Provided patch to fix a colorization bug when dealing with special
files and directories that seem to have an extension.
Zurd (?)
- Suggested removing trailing slash on user supplied directory names if -f
option is used.
John Nintendud
- Pointed out broken HTML output in 1.5.1.
Mark Braker
- Suggested --filelimit option.
Michael Vogt
- Suggested -v option (version sort).
Wang Quanhong
- Provided build options for Solaris.
Craig McDaniel
- Provided build options and source mods for HP NonStop support.
Christian Grigis
- Noted that setlocale() should come before MB_CUR_MAX check.
Kamaraju Kusumanchi
- Submitted patch to remove compiler warnings for Solaris.
Martin Nagy
- Provided patch which fixes issue where indent may output more than it
should when dirs[*] is not properly cleared before use.
William C. Lathan III
- Showed that tree was not properly quoting arguments to recursively called
tree instances when using -R.
Ulrich Eckhardt
- Submitted patch for --si option.
Tim Waugh (redhat)
- Pointed out a potential memory leak in listdir().
Markus Schnalke
- Tracked down bug where tree would print "argetm" before the filename of a
symbolic link when the "target" option was specified for LINK in dircolors.
Ujjwal Kumar
- Suggested that tree backslash spaces like ls does for script use. Made
output more like ls.
Ivan Shmakov
- Pointed out multiple CLI defenciencies (via Debian)
Mantas Mikulnas
- Provided patch to make tree more reliably detect the UTF-8 locale.
Tim Mooney
- Noticed S_ISDOOR/S_IFDOOR spelling mistake for under Solaris.
Han Hui
- Pointed out possible memory overflow in read_dir (path/lbuf not equal in size
to pathsize/lbufsize.)
Ryan Hollis
- Pointed out problems with the Makefile w/ respect to OSX.
Philipp M?ller
- Provided patch for filesize sorting.
Sascha Zorn
- Pointed out that the HTML output was broken when -L 1 option was used.
Alexandre Wendling
- Pointed out that modern systems may use 32 bit uid/gids which could lead
to a potential buffer overflow in the uid/gid to name mapping functions.
Florian Sesser
- Provided patch to add JSON support.
Brian Mattern & Jason A. Donenfeld
- Provided patch to add --matchdirs functionality.
Jason A. Donenfeld
- Added --caseinsentive, renamed --ignore-case option.
- Bugged me a lot.
Stephan Gabert
- Found a bug where the wrong inode (and device) information would be printed
for symbolic links.
And many others whom I've failed to keep track of. I should have started
this list years ago.
- Steve Baker
ice@mama.indstate.edu
查看INSTALL帮助文件
[12:46:38 root@C8[ ~]#cat ./tree-1.8.0/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.
查看Makefile
[12:45:11 root@C8[ ~]#cat ./tree-1.8.0/Makefile
# $Copyright: $
# Copyright (c) 1996 - 2018 by Steve Baker
# All Rights reserved
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
prefix = /usr
CC=gcc
VERSION=1.8.0
TREE_DEST=tree
BINDIR=${prefix}/bin
MAN=tree.1
MANDIR=${prefix}/man/man1
OBJS=tree.o unix.o html.o xml.o json.o hash.o color.o file.o
# Uncomment options below for your particular OS:
# Linux defaults:
CFLAGS=-ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
#CFLAGS=-O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
#LDFLAGS=-s
# Uncomment for FreeBSD:
#CFLAGS=-O2 -Wall -fomit-frame-pointer
#LDFLAGS=-s
#OBJS+=strverscmp.o
# Uncomment for OpenBSD:
#TREE_DEST=colortree
#MAN=colortree.1
#CFLAGS=-O2 -Wall -fomit-frame-pointer
#LDFLAGS=-s
#OBJS+=strverscmp.o
# Uncomment for Solaris:
#CC=cc
#CFLAGS=-xO0 -v
#LDFLAGS=
#OBJS+=strverscmp.o
#MANDIR=${prefix}/share/man/man1
# Uncomment for Cygwin:
#CFLAGS=-O2 -Wall -fomit-frame-pointer -DCYGWIN
#LDFLAGS=-s
#TREE_DEST=tree.exe
#OBJS+=strverscmp.o
# Uncomment for OS X:
# It is not allowed to install to /usr/bin on OS X any longer (SIP):
#prefix = /usr/local
#CC=cc
#CFLAGS=-O2 -Wall -fomit-frame-pointer -no-cpp-precomp
#LDFLAGS=
#MANDIR=/usr/share/man/man1
#OBJS+=strverscmp.o
# Uncomment for HP/UX:
#CC=cc
#CFLAGS=-O2 -DAportable -Wall
#LDFLAGS=
#OBJS+=strverscmp.o
# Uncomment for OS/2:
#CFLAGS=-02 -Wall -fomit-frame-pointer -Zomf -Zsmall-conv
#LDFLAGS=-s -Zomf -Zsmall-conv
#OBJS+=strverscmp.o
# Uncomment for HP NonStop:
#prefix = /opt
#CC=c89
#CFLAGS=-Wextensions -WIEEE_float -g -Wnowarn=1506 -D_XOPEN_SOURCE_EXTENDED=1
# -Wallow_cplusplus_comments
#LDFLAGS=
#OBJS+=strverscmp.o
# AIX
#CC=cc_r -q64
#LD=ld -d64
#LDFLAGS=-lc
#OBJS+=strverscmp.o
#------------------------------------------------------------
all: tree
tree: $(OBJS)
$(CC) $(LDFLAGS) -o $(TREE_DEST) $(OBJS)
$(OBJS): %.o: %.c tree.h
$(CC) $(CFLAGS) -c -o $@ $<
clean:
if [ -x $(TREE_DEST) ]; then rm $(TREE_DEST); fi
if [ -f tree.o ]; then rm *.o; fi
rm -f *~
install: tree
install -d $(BINDIR)
install -d $(MANDIR)
if [ -e $(TREE_DEST) ]; then
install $(TREE_DEST) $(BINDIR)/$(TREE_DEST);
fi
install doc/$(MAN) $(MANDIR)/$(MAN)
distclean:
if [ -f tree.o ]; then rm *.o; fi
rm -f *~
dist: distclean
tar zcf ../tree-$(VERSION).tgz -C .. `cat .tarball`
修改Makefile中的安装地址
[12:48:39 root@C8[ ~]#vim ./tree-1.8.0/Makefile
prefix = /Apps
确保gss和make已安装
[12:56:21 root@C8[ ~]#type gcc
-bash: type: gcc: not found
[12:56:57 root@C8[ ~]#type make
-bash: type: make: not found
[12:58:03 root@C8[ ~]#yum -y install gcc make
CentOS-8 - AppStream 2.7 kB/s | 4.3 kB 00:01
CentOS-8 - Base 122 B/s | 3.8 kB 00:31
CentOS-8 - Extras 2.7 kB/s | 1.5 kB 00:00
Dependencies resolved.
===================================================================================================
Package Architecture Version Repository Size
===================================================================================================
Installing:
gcc x86_64 8.3.1-4.5.el8 AppStream 23 M
make x86_64 1:4.2.1-9.el8 BaseOS 498 k
Installing dependencies:
cpp x86_64 8.3.1-4.5.el8 AppStream 10 M
isl x86_64 0.16.1-6.el8 AppStream 841 k
libmpc x86_64 1.0.2-9.el8 AppStream 59 k
glibc-devel x86_64 2.28-72.el8 BaseOS 1.0 M
glibc-headers x86_64 2.28-72.el8 BaseOS 469 k
kernel-headers x86_64 4.18.0-147.5.1.el8_1 BaseOS 2.7 M
libxcrypt-devel x86_64 4.1.1-4.el8 BaseOS 25 k
Transaction Summary
===================================================================================================
Install 9 Packages
Total download size: 39 M
Installed size: 100 M
Downloading Packages:
CentOS-8 - Base 193% [=======================================================-] 1.3 k(1/9): isl-0.16.1-6.el8.x86_64.rpm 1.4 MB/s | 841 kB 00:00
(2/9): libmpc-1.0.2-9.el8.x86_64.rpm 802 kB/s | 59 kB 00:00
(3/9): glibc-devel-2.28-72.el8.x86_64.rpm 941 kB/s | 1.0 MB 00:01
(4/9): glibc-headers-2.28-72.el8.x86_64.rpm 282 kB/s | 469 kB 00:01
(5/9): cpp-8.3.1-4.5.el8.x86_64.rpm 2.9 MB/s | 10 MB 00:03
(6/9): libxcrypt-devel-4.1.1-4.el8.x86_64.rpm 118 kB/s | 25 kB 00:00
(7/9): make-4.2.1-9.el8.x86_64.rpm 839 kB/s | 498 kB 00:00
(8/9): kernel-headers-4.18.0-147.5.1.el8_1.x86_64.rpm 1.1 MB/s | 2.7 MB 00:02
(9/9): gcc-8.3.1-4.5.el8.x86_64.rpm 629 kB/s | 23 MB 00:38
---------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 39 MB 00:39
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libmpc-1.0.2-9.el8.x86_64 1/9
Running scriptlet: libmpc-1.0.2-9.el8.x86_64 1/9
Installing : cpp-8.3.1-4.5.el8.x86_64 2/9
Running scriptlet: cpp-8.3.1-4.5.el8.x86_64 2/9
Installing : kernel-headers-4.18.0-147.5.1.el8_1.x86_64 3/9
Running scriptlet: glibc-headers-2.28-72.el8.x86_64 4/9
Installing : glibc-headers-2.28-72.el8.x86_64 4/9
Installing : libxcrypt-devel-4.1.1-4.el8.x86_64 5/9
Installing : glibc-devel-2.28-72.el8.x86_64 6/9
Running scriptlet: glibc-devel-2.28-72.el8.x86_64 6/9
Installing : isl-0.16.1-6.el8.x86_64 7/9
Running scriptlet: isl-0.16.1-6.el8.x86_64 7/9
Installing : gcc-8.3.1-4.5.el8.x86_64 8/9
Running scriptlet: gcc-8.3.1-4.5.el8.x86_64 8/9
Installing : make-1:4.2.1-9.el8.x86_64 9/9
Running scriptlet: make-1:4.2.1-9.el8.x86_64 9/9
Verifying : cpp-8.3.1-4.5.el8.x86_64 1/9
Verifying : gcc-8.3.1-4.5.el8.x86_64 2/9
Verifying : isl-0.16.1-6.el8.x86_64 3/9
Verifying : libmpc-1.0.2-9.el8.x86_64 4/9
Verifying : glibc-devel-2.28-72.el8.x86_64 5/9
Verifying : glibc-headers-2.28-72.el8.x86_64 6/9
Verifying : kernel-headers-4.18.0-147.5.1.el8_1.x86_64 7/9
Verifying : libxcrypt-devel-4.1.1-4.el8.x86_64 8/9
Verifying : make-1:4.2.1-9.el8.x86_64 9/9
Installed:
gcc-8.3.1-4.5.el8.x86_64 make-1:4.2.1-9.el8.x86_64
cpp-8.3.1-4.5.el8.x86_64 isl-0.16.1-6.el8.x86_64
libmpc-1.0.2-9.el8.x86_64 glibc-devel-2.28-72.el8.x86_64
glibc-headers-2.28-72.el8.x86_64 kernel-headers-4.18.0-147.5.1.el8_1.x86_64
libxcrypt-devel-4.1.1-4.el8.x86_64
进入源代码目录后make
[13:02:48 root@C8[ tree-1.8.0]#make -j 4
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
进行编译安装
[13:03:13 root@C8[ tree-1.8.0]#make install
install -d /Apps/bin
install -d /Apps/man/man1
if [ -e tree ]; then
install tree /Apps/bin/tree;
fi
install doc/tree.1 /Apps/man/man1/tree.1
编译安装完成,按路径执行程序
[13:04:22 root@C8[ tree-1.8.0]#/Apps/bin/tree
.
├── CHANGES
├── color.c
├── color.o
├── doc
│ ├── tree.1
│ ├── tree.1.fr
│ └── xml.dtd
├── file.c
├── file.o
├── hash.c
├── hash.o
至此,编译安装完成!
新旧tree同在!