#!/usr/bin/env bash
pkgs='main-program dependency1 dependence2'
if ! dpkg -s $pkgs >/dev/null 2>&1; then
wget main-program.deb && apt -y install ./main-program.deb
wget dependency1.deb && apt -y install ./dependency1.deb
wget dependency2.deb && apt -y install ./dependency2.deb
fi
问题:我该如何修复我的脚本以安装主程序.deb
,并且当我需要它的依赖项时(如果未安装),在本地存储库中查找它们(对于 ubuntu 20.04)?
注意:大多数主要程序依赖项.deb
不再位于官方 ubuntu 20.04 存储库中,因此无法使用apt-get install package
(只能使用apt-get install ./package.deb
或dpkg -i package.deb
)安装
更新:
此解决方案据称解决了离线安装的问题。也就是说,主程序在/var/cache/apt/archives/
文件夹中而不是在互联网上寻找所需的依赖项
#!/usr/bin/env bash
pkgs='main-program'
path_deb="/var/cache/apt/archives/"
if ! dpkg -s $pkgs >/dev/null 2>&1; then
cat dependencies.txt | xargs -n 1 -P 2 wget -q -nc -P $path_deb
dpkg -i $path_deb/main-program.deb
apt-get install -f
fi
我也尝试过:
dpkg --force-depends -i /var/cache/apt/archives/main-program.deb
内容dependencies.txt
https://old-releases.ubuntu.com/ubuntu/pool/universe/example/dependency1.deb
https://old-releases.ubuntu.com/ubuntu/pool/universe/example/dependency2.deb
https://old-releases.ubuntu.com/ubuntu/pool/universe/example/main-program.deb
但失败了:
Unpacking main-program ...
dpkg: dependency issues prevent main-program configuration:
main-program depends on dependency1; However:
The `dependency1' package is not installed.
main-program depends on dependency2; However:
The `dependency2' package is not installed.
Errors were encountered while processing:
main-program
Reading package list ... Done
Creating dependency tree
Reading status information ... Done
Fixing dependencies ... done
The following packages WILL be REMOVED:
main-program
0 updated, 0 new will be installed, 1 to remove, and 0 not updated.
1 not fully installed or removed.
672 kB will be released after this operation.
do you wish to continue? [Y / n]