因某些原因,开发用的电脑不能联网,如果要离线在ubuntu上安装软件包,经常会因不清楚依赖关系而不知要下哪些包,但如果另有台可联网的电脑,用的ubuntu版本也和离线机一致,则可用如下方法解决:
比如离线ubuntu上报错:bison: Command not found
显然是没安装bison,在联网ubuntu上先:
$sudo apt-get autoremove bison
卸载掉之前已安装的bison,然后再:
$sudo apt-get install bison
自动安装bison,下载的deb包(bison_1%3a2.5.dfsg-2.1_i386.deb)存放在/var/cache/apt/archives下,将其copy到离线机,安装:
$sudo dpkg -i bison_1%3a2.5.dfsg-2.1_i386.deb
结果报错:
Selecting previously unselected package bison.
(Reading database ... 215538 files and directories currently installed.)
Unpacking bison (from bison_1%3a2.5.dfsg-2.1_i386.deb) ...
dpkg: dependency problems prevent configuration of bison:
bison depends on libbison-dev (= 1:2.5.dfsg-2.1); however:
Package libbison-dev is not installed.
dpkg: error processing bison (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:
bison
提示没有安装libbison-dev,再在联网机上:
$sudo apt-get autoremove libbison-dev
$sudo apt-get install libbison-dev
同样在/var/cache/apt/archives下获得libbison-dev_1%3a2.5.dfsg-2.1_i386.deb,将其copy到离线机,安装:
$sudo dpkg -i libbison-dev_1%3a2.5.dfsg-2.1_i386.deb
然后再安装bison_1%3a2.5.dfsg-2.1_i386.deb即能成功。