如何脱机安装Debian Packages

时间:2020-03-05 15:25:09  来源:igfitidea点击:

通过良好可靠的互联网连接,安装,更新或者升级Debian系统是散步。
我们所需要的只是运行'apt-get更新'或者apt-get升级'命令和voila!系统是最新的。
对于使用GUI系统的人,由于更新管理器将允许我们轻松更新按钮的软件包更容易。

但是,让我们想象一下,我们在没有互联网连接的远程位置,或者ISP正在遇到一些技术挑战,Office PC运行Debian或者Windows系统连接到超快速的Internet连接。
我们如何了解更新或者升级离线Debian系统?

使用Apt-Offline工具,我们可以在工作或者朋友的位置杠杆在线电脑,以下载所需的软件包,并在家中的离线Debian系统中安装并安装它们。
Apt-offline是在Python中构建的一个免费和开源工具。

1.使用Apt-Offline在家中安装Debian系统

这需要互联网连接。
我们必须在家庭Debian PC上安装Apt-Offline。
打开终端并运行

apt-get install apt-offline
root@jamie-VirtualBox:/home/jamie/Downloads# apt-get install apt-offline
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-offline
0 upgraded, 1 newly installed, 0 to remove and 280 not upgraded.
Need to get 0 B/61.0 kB of archives.
After this operation, 318 kB of additional disk space will be used.
Selecting previously unselected package apt-offline.
(Reading database ... 169004 files and directories currently installed.)
Preparing to unpack .../apt-offline_1.7.2_all.deb ...
Unpacking apt-offline (1.7.2) ...
Setting up apt-offline (1.7.2) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.7.6.1-2) ...

2.生成APT签名

APT-Signature文件包含有关在Debian系统中安装和下载的软件包的信息,并有助于验证需要下载哪些文件。
要生成SIG文件,请在终端类型上

apt-offline set ~/geek.sig
root@jamie-VirtualBox:/home/jamie# apt-offline set ~/geek.sig
Generating database of files that are needed for an update.
Generating database of file that are needed for operation upgrade

这在Root的主文件夹中生成SIG文件。
随时更改SIG文件的路径。
将SIG文件保存在U盘中,并将其连接到具有Internet访问权限的PC。

对于连接到互联网的PC

前往办公室Debian PC连接到互联网并运行

apt-offline get -d /path/to download/directory /path/to/geek.sig

或者,我们可以使用Get -bundle选项

apt-offline get --bundle /path/to download/directory/bundle.zip /path/to/geek.sig

-bundle选项使我们可以生成包含所有数据的存档,或者将所有包捆绑到一个zip文件中。
下载后,将所有下载的文件复制在USB中。
如果我们有良好的互联网连接,此过程大约需要10分钟。

root@jamie-VirtualBox:/home/jamie# apt-offline get --bundle /home/jamie/Downloads/bundle.zip ~/geek.sig 
Fetching APT Data
Downloading http://security.ubuntu.com/ubuntu/dists/zesty-security/Release.gpg                                                             
http://security.ubuntu.com/ubuntu/dists/zesty-security/Release.gpg done                                                             
Downloading http://security.ubuntu.com/ubuntu/dists/zesty-security/Release                                                             
http://security.ubuntu.com/ubuntu/dists/zesty-security/Release done                                                             
Downloading http://security.ubuntu.com/ubuntu/dists/zesty-security/InRelease                                                             
http://security.ubuntu.com/ubuntu/dists/zesty-security/InRelease done                                                             
Downloading http://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-amd64/Packages.xz                                                             
http://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-amd64/Packages.xz done                                                             
Downloading http://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-i386/Packages.xz                                                             
http://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-i386/Packages.xz done
Downloaded data to /home/jamie/Downloads/bundle.zip
root@jamie-VirtualBox:/home/jamie# cd /home/jamie/Downloads/
root@jamie-VirtualBox:/home/jamie/Downloads# ls
bundle.zip
root@jamie-VirtualBox:/home/jamie/Downloads#

如果我们正在运行Windows计算机,则需要安装Python,然后安装Apt-Offline包。
触发命令提示符工具并导航到APT-OFFLINE的目录并执行上面的命令。

在家里的离线Debian PC上

最后,返回远程计算机并在U盘中安装已下载的软件包。

运行步

apt-offline install /path/to/bundle.zip

这将更新APT数据库而无需任何毛刺。
使用这4个步骤,Debian系统将使用最新版本的软件包更新和运行。

如何在离线Debian机器上安装包

让我们假设我们要在离线电脑上安装Debian软件包,请将Debian软件包安装在线PC,运行Windows或者Debian,并在笔驱动器或者U盘中下载Debian软件包。
Debian套餐以.deb扩展为后缀。
Hello_2.1.1-4_I386.DEB返回OFFLINE PC,请将.deb文件复制到我们选择的任何路径,并运行以下命令以安装.deb软件包:

dpkg -i   /path/to/Debian/package.deb

在线更新,升级或者安装包是最容易做的以及最优选的包管理方法。
但是,如果我们没有访问Internet连接的位置,则APT-OFFLINE Tool执行魔术,仍将允许我们无缝更新和升级离线PC。