有了良好可靠的互聯網連接,安裝、更新或升級您的 Debian 系統就像在公園裡散步。 您所需要做的就是運行“apt-get update”或“apt-get upgrade”命令,瞧! 您的系統是最新的。 對於那些使用 GUI 系統的人來說,這要容易得多,因為更新管理器將允許您通過單擊按鈕輕鬆更新包。
但是讓我們假設您在一個沒有互聯網連接的偏遠地方,或者您的 ISP 遇到了一些技術挑戰,而您運行 Debian 或 Windows 系統的辦公室 PC 連接到了超快速的互聯網連接。 您如何更新或升級您的離線 Debian 系統?
使用 apt-offline 工具,您可以在工作場所或朋友家的在線 PC 上下載所需的軟件包,然後在家中將它們安裝到您的離線 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 文件的路徑。 Save 將 USB 驅動器中的 sig 文件連接到可以訪問互聯網的 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 https://security.ubuntu.com/ubuntu/dists/zesty-security/Release.gpg
https://security.ubuntu.com/ubuntu/dists/zesty-security/Release.gpg done
Downloading https://security.ubuntu.com/ubuntu/dists/zesty-security/Release
https://security.ubuntu.com/ubuntu/dists/zesty-security/Release done
Downloading https://security.ubuntu.com/ubuntu/dists/zesty-security/InRelease
https://security.ubuntu.com/ubuntu/dists/zesty-security/InRelease done
Downloading https://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-amd64/Packages.xz
https://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-amd64/Packages.xz done
Downloading https://security.ubuntu.com/ubuntu/dists/zesty-security/main/binary-i386/Packages.xz
https://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 上
最後,回到您的遠程機器並在 USB 驅動器中安裝已經下載的軟件包。
跑
apt-offline install /path/to/bundle.zip
這將更新 apt 數據庫而不會出現任何故障。 通過這 4 個步驟,您的 Debian 系統將更新並運行最新版本的軟件包。
如何在離線 Debian 機器上安裝軟件包
假設您想在離線 PC 上安裝 Debian 軟件包,前往運行 Windows 或 Debian 的在線 PC,然後在筆式驅動器或 U 盤中下載 Debian 軟件包。 Debian 軟件包後綴為 .deb 擴展名,例如 hello_2.1.1-4_i386.deb 返回離線 PC,插入 USB 驅動器,將 .deb 文件複製到您選擇的任何路徑並運行以下命令以安裝.deb 包:
dpkg -i /path/to/Debian/package.deb
在線更新、升級或安裝軟件包是最簡單的方法,也是最受青睞的軟件包管理方法。 但是,如果您無法訪問 Internet 連接,apt-offline 工具可以發揮作用,並且仍然可以讓您無縫更新和升級您的離線 PC。