1 #!/bin/bash
2 #
3 DIST=/mnt/text/sysroot
4 #复制命令的依赖库函数库
5 libcp ()
6 {
7
LIBDIST=${1%/*}
8
[ ! -d $DIST$LIBDIST ]
&& mkdir -p $DIST$LIBDIST
9
[ ! -e $DIST$1 ] &&
cp -p $1 $DIST$LIBDIST && echo "add $DIST$1 ok."
10
11 }
12 #复制命令
13 bincp ( )
14 {
15
BINPATH=${1%/*}
16
[ ! -e $DIST$BINPATH ]
&& mkdir -p $DIST$BINPATH
17
[ ! -e $DIST$1 ] &&
cp -p $1 $DIST$1 && echo "add $DIST$1
finished."
18
19
for I in `ldd
$1 | grep -o
"/.*lib(64){0,1}/[^[:space:]]{1,}"`; do
20
libcp
$I
21
done
22 }
23 #用户输入
24 read -p "Commond: " COMM
25 until [ $COMM == 'q' ];
do
26
! which $COMM
&>/dev/null && echo "Commend not found.." &&
read -p "Again command..." COMM && continue
27
COMMEND=`which $COMM | grep
-v "^alais" | grep -o "[^[:space:]]{1,}"`
28
echo $COMMEND
29
bincp $COMMEND
30
read -p "Again commend...."
COMM
31 done
32
33
以上为脚本,以下为功能
创建一个新的根文件系统/mnt/text/sysroot
复制命令到sysroot下