递归下载ubuntu下的某包安装包及依赖包
1 #! /bin/bash 2 basepath=$(cd `dirname $0`; pwd) 3 pkg="$*" 4 5 function getDepends() 6 { 7 ret=`apt-cache depends $1 |grep -i Depends |cut -d: -f2 |tr -d "<>"` 8 if [[ -z $ret ]]; then 9 # echo '$1 No depends' 10 echo -n 11 else 12 for i in $ret 13 do 14 if [[ `echo $pkg |grep -e "$i "` ]]; then 15 # echo "$i already in set" 16 echo -n 17 else 18 pkg="$pkg $i" 19 echo "Download $i ing" 20 getDepends $i 21 fi 22 done 23 fi 24 } 25 26 for j in $@ 27 do 28 getDepends $j 29 done 30 31 echo $pkg 32 #apt install $pkg --reinstall -d -y 33 apt-get download $pkg -d -y
可以递归的把指定包及其依赖包下载回去安装 , (.deb后缀)
有时候会出现安装失败的情况,这时应注意出错信息,去除该包后继续尝试下载, 其实执行的命令如下
apt-get download python2.7 python2.7-minimal libc6 libgcc1 gcc-6-base libpython2.7-minimal zlib1g libpython2.7-stdlib mime-support libbz2-1.0 libdb5.3 libexpat1 libffi6 libncursesw5 libtinfo5 libreadline6 readline-common dpkg liblzma5 multiarch-support libselinux1 libpcre3 tar libacl1 libattr1 install-info libsqlite3-0 libssl1.0.0 debconf perl-base -d -y