Files
linux-wiki/content/deepin折腾笔记/第五章/5.14.md
2021-10-21 14:57:58 +08:00

47 lines
1.6 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 5.14 离线安装软件
当没有网络连接的电脑上需要安装某个软件时,可以使用下面的脚本下载该软件以及依赖包,在脱机电脑上执行:
`sudo dpkg -i *.deb`
如果上述安装命令最后报错,则需要执行:`sudo apt install -f`
如果提示缺少软件包依赖则拷贝依赖包名例如XXX在有网络的电脑上执行`apt download XXX`下载,再拷贝到脱机电脑上双击安装即可。
批量下载脚本如下:
```bash
#! /bin/bash
pkg="$*"
function getDepends()
{
ret=`apt-cache depends $1 |grep -i 依赖 |sed 's/(.*)//' |cut -d: -f2`
if [[ -z $ret ]]; then
echo "$1 No depends"
echo -n
else
# echo $ret
# apt-cache depends $1 |grep -i 依赖
# echo ''
for i in $ret
do
if [[ `echo $pkg |grep -e "$i "` ]]; then
# echo "$i already in set"
echo -n
elif [[ $i =~ '<' ]]; then
echo "Drop $i"
elif [[ "$i" != "libc6" &&
"$i" != "libcairo2" &&
!("$i" =~ "glib") &&
!("$i" =~ "gtk") &&
!("$i" =~ "font")
]]; then
# echo "Download $i ing"
pkg="$pkg $i"
getDepends $i
fi
done
fi
}
for j in $@
do
getDepends $j
done
apt download $pkg -d -y
```