linux
在离线环境安装软件是个比较麻烦的事情,下面以docker.io
进行演示
获取依赖清单
apt-cache depends docker.io| grep Depends
效果如下
root@l ~ # apt-cache depends docker.io| grep Depends
Depends: adduser
Depends: containerd
Depends: iptables
|Depends: debconf
Depends: <debconf-2.0>
Depends: libc6
Depends: libdevmapper1.02.1
Depends: libsystemd0
下载依赖清单-1
从上面的结果可以看出,<debconf-2.0>
这个格式与其他的不太一样,这个格式的代表这个包是可选择版本的,所以第一步下载的依赖包先排除这种特殊的
打印本次下载清单
root@l ~ # apt-cache depends docker.io| grep Depends | grep -v \< | awk '{print $2}'
adduser
containerd
iptables
debconf
libc6
libdevmapper1.02.1
libsystemd0
root@l ~ #
开始下载
apt download `apt-cache depends docker.io| grep Depends | grep -v \< | awk '{print $2}'`
效果如下
root@l ~ # mkdir deb
root@l ~ # cd deb
root@l ~/deb # ls
root@l ~/deb # apt download `apt-cache depends docker.io| grep Depends | grep -v \< | awk '{print $2}'`
Get:1 http://mirrors.tencentyun.com/ubuntu jammy/main amd64 adduser all 3.118ubuntu5 [156 kB]
Get:2 http://mirrors.tencentyun.com/ubuntu jammy/main amd64 debconf all 1.5.79ubuntu1 [126 kB]
Get:3 http://mirrors.tencentyun.com/ubuntu jammy/main amd64 libdevmapper1.02.1 amd64 2:1.02.175-2.1ubuntu4 [139 kB]
Get:4 http://mirrors.tencentyun.com/ubuntu jammy-updates/main amd64 containerd amd64 1.7.2-0ubuntu1~22.04.1 [36.0 MB]
Get:5 http://mirrors.tencentyun.com/ubuntu jammy-updates/main amd64 iptables amd64 1.8.7-1ubuntu5.2 [455 kB]
Get:6 http://mirrors.tencentyun.com/ubuntu jammy-updates/main amd64 libc6 amd64 2.35-0ubuntu3.6 [3,236 kB]
Get:7 http://mirrors.tencentyun.com/ubuntu jammy-updates/main amd64 libsystemd0 amd64 249.11-0ubuntu3.12 [319 kB]
Fetched 40.5 MB in 5s (8,323 kB/s)
W: Download is performed unsandboxed as root as file '/root/deb/adduser_3.118ubuntu5_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
root@l ~/deb # ls
adduser_3.118ubuntu5_all.deb debconf_1.5.79ubuntu1_all.deb libc6_2.35-0ubuntu3.6_amd64.deb libsystemd0_249.11-0ubuntu3.12_amd64.deb
containerd_1.7.2-0ubuntu1~22.04.1_amd64.deb iptables_1.8.7-1ubuntu5.2_amd64.deb libdevmapper1.02.1_2%3a1.02.175-2.1ubuntu4_amd64.deb
root@l ~/deb #
下载依赖清单-2
在下载了通用的之后,还需要处理特殊的包
root@l ~/deb # i=`apt-cache depends docker.io| grep Depends | grep \< | awk '{print $2}' | sed 's/>//g'| sed 's/<//g' | awk -F '-' '{print $1}'`
root@l ~/deb # echo $i
debconf
下载
root@l ~/deb # apt download $i
Get:1 http://mirrors.tencentyun.com/ubuntu jammy/main amd64 debconf all 1.5.79ubuntu1 [126 kB]
Fetched 126 kB in 0s (657 kB/s)
W: Download is performed unsandboxed as root as file '/root/deb/debconf_1.5.79ubuntu1_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
root@l ~/deb #