#!/bin/bash
logfile=./auto_deps_log
# 需要获取其所依赖包的包
# 或者用$1,从命令行输入库名字
libs="gdisk logrotate pciutils systemd lvm2 udev logrotate libfuse2 iptables libnetfilter-conntrack3 libnfnetlink0 libusb-1.0-0 cpio xfsprogs libprotobuf-c1 liblmdb0"
ret=""
function getDepends()
{
echo "fileName is" $1>>$logfile
# use tr to del < >
ret=`apt-cache depends $1|grep Depends |cut -d: -f2 |tr -d "<>"`
echo $ret|tee -a $logfile
}
if [ ! -n "$*" ] ;then
echo "you have not input a word! get list: $libs"
else
echo "the list you input is $*"
libs=$1
fi
echo "get $libs"
# download libs dependen. deep in 3
i=0
while [ $i -lt 3 ] ;
do
let i++
echo $i
# download libs
newlist=" "
for j in $libs
do
added="$(getDepends $j)"
newlist="$newlist $added"
apt-get download $added $j
done
libs=$newlist
done
注:本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。