CheneyC
2018-08-30 10:00:01 +08:00
为了回答这个问题,还专门注册了一个账号,也是佩服自己。另外新用户 7000s 后回复的设置佩服这个网站;
就题主的需求,基于几个源和二进制包名,得到这个二进制包的向上所有依赖包,架构 deb 系。
这里介绍两个相关命令:
1 ) apt-cache depends xx #获取 xx 的依赖关系
例如
-----------------------
root@cbs-06:/home/cc# apt-cache depends vim
vim
依赖: vim-common
依赖: vim-runtime
依赖: libacl1
依赖: libc6
依赖: libgpm2
依赖: libpython2.7
依赖: libselinux1
依赖: libtinfo5
建议: <ctags>
exuberant-ctags:i386
exuberant-ctags
建议: vim-doc
建议: vim-scripts
冲突: vim:i386
-----------------------
2 ) apt-rdepends vim #依次返回向上依赖的包
例如:
-----------------------
root@cbs-06:/home/cc# apt-rdepends vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
vim
Depends: libacl1 (>= 2.2.51-8)
Depends: libc6 (>= 2.15)
Depends: libgpm2 (>= 1.20.4)
Depends: libpython2.7 (>= 2.7)
Depends: libselinux1 (>= 1.32)
Depends: libtinfo5
Depends: vim-common (= 2:7.4.052-1ubuntu3)
Depends: vim-runtime (= 2:7.4.052-1ubuntu3)
libacl1
Depends: libattr1 (>= 1:2.4.46-8)
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libattr1
Depends: libc6 (>= 2.4)
PreDepends: multiarch-support
libc6
Depends: libgcc1
libgcc1
Depends: gcc-4.9-base (= 4.9-20140406-0ubuntu1)
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
.... 中间内容较多省略了....
debconf
PreDepends: perl-base (>= 5.6.1-4)
perl-base
PreDepends: dpkg (>= 1.14.20)
PreDepends: libc6 (>= 2.14)
debconf-2.0
mime-support
vim-common
Depends: libc6 (>= 2.3.4)
vim-runtime
-----------------------
综上:apt-rdepends 这个命令可以满足题主的要求,对结果进行正则匹配下再下载到本地即可。
eg:
j=0;for i in `apt-rdepends XX |grep "Depends:" |awk '{print $2}' |sort |uniq `;do echo "$j)---$i";apt-get download $i;j=$(($j+1));done