Apt-offline: Difference between revisions

From miki
Jump to navigation Jump to search
(Redirected page to Package Management)
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''apt-offline''' is a tool to manage packages on a remote system that has no direct connection to the internet.
#REDIRECT [[Package Management]]

== References ==
* [https://www.maketecheasier.com/update-upgrade-ubuntu-without-internet-connection/], [https://blog.sleeplessbeastie.eu/2014/01/30/how-to-manage-packages-on-an-off-line-debian-system/]

== Install ==
First you need to install {{deb|apt-offline}} on the ''offline'' and ''proxy'' systems.
sudo apt-get install apt-offline python-lzma

This usually requires an internet connection, but another solution is to first install the package on the ''proxy'' system, then copy the package {{file|.deb}} file from {{file|/var/cache/apt/archives}} into same directory on the ''offline'' system. Now install the package on the ''offline'' system using <code>apt-get</code> as usual.

== Upprade offline system ==
* On ''offline'' system, check the source list has the online repo enabled (not DVD).
* On ''offline'' system, generate the reference signature file:
<source lang=bash>
sudo apt-offline set --update --upgrade /path/to/apt.sig # ... OR ...
sudo apt-offline set --update --upgrade --upgrade-type dist-upgrade /path/to/apt.sig
</source>
* On ''proxy'' system, download the necessary packages:
<source lang=bash>
apt-offline get -d /path/to/download/directory /path/to/apt.sig # ... OR ...
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig
</source>
Note that <code>apt-offline</code> will complain if {{file|bundle.zip}} exists already, so a better command to keep in shell history is:
<source lang="bash">
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig || rm /download/path/bundle.zip
</source>
* Back on ''offline'' system, install all the packages:
<source lang=bash>
sudo apt-offline install /path/to/bundle.zip
sudo apt-get upgrade # ... OR ...
sudo apt-get dist-upgrade
</source>

== Install a package on offline system ==
* On ''offline'' system, check the source list has the online repo enabled (not DVD).
* On ''offline'' system, generate the reference signature file and request installation of package (here {{deb|vlc}}):
<source lang=bash>
sudo apt-offline set --install-package vlc -- /path/to/apt.sig
</source>
* On ''proxy'' system, download the necessary packages:
<source lang=bash>
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig
# ... or better:
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig || rm /download/path/bundle.zip
</source>
* Back on ''offline'' system, install all the packages:
<source lang=bash>
sudo apt-offline install /path/to/bundle.zip
sudo apt-get install vlc
</source>

== Install build dependencies ==
This is equivalent of <code>apt-get build-dep neovim/stretch</code>:
<source lang="c">
sudo apt-offline set --install-src-packages neovim/stretch --src-build-dep -- /path/to/apt.sig
</source>

== Troubleshooting ==
=== Use --verbose ===
* Use <code>--verbose</code> to troubleshoot errors.

=== ERROR: FATAL: Something is wrong with the apt system. ===
* On <code>ERROR: FATAL: Something is wrong with the apt system.</code>
:* Check that given directory exists
* If getting many errors like <code>ERROR: Failed to unlink /var/lib/apt/lists/partial/...amd64_Packageapt-offline</code>, try installing package {{deb|python-lzma}} [https://github.com/rickysarraf/apt-offline/issues/37].
* When downloading source packages, the source package are downloaded in {{file|/tmp}} folder. See console output:
<source lang="bash">
sudo apt-offline install /smb/docs/minashare/MPeeters/apt/bundle.zip
# Proceeding with installation
# Installing src package file terminator_1.90+bzr-1705-1.dsc to /tmp/apt-offline-src-downloads-9342.
# Installing src package file terminator_1.90+bzr-1705.orig.tar.xz to /tmp/apt-offline-src-downloads-9342.
# Installing src package file terminator_1.90+bzr-1705-1.debian.tar.xz to /tmp/apt-offline-src-downloads-9342.
# ...

sudo cp /tmp/apt-offline-src-downloads-9342/* .
sudo apt source terminator
# Reading package lists... Done
# NOTICE: 'terminator' packaging is maintained in the 'Svn' version control system at:
# svn://anonscm.debian.org/python-apps/packages/terminator/trunk/
# Skipping already downloaded file 'terminator_1.90+bzr-1705-1.dsc'
# Skipping already downloaded file 'terminator_1.90+bzr-1705.orig.tar.xz'
# Skipping already downloaded file 'terminator_1.90+bzr-1705-1.debian.tar.xz'
</source>

=== E: Unable to correct problems, you have held broken packages===
* If getting error <code>ERROR: Unable to correct problems, you have held broken packages</code>, try first to install with <code>aptitude</code>. Doing so will indicate which packages have a conflict.

* Using <code>--verbose</code>, always gives which command failed:
Generating database of package ['clang-6.0'] and its dependencies.
VERBOSE: Command is ['/usr/bin/apt-get', '-qq', '--print-uris', 'install', 'clang-6.0']
E: Unable to correct problems, you have held broken packages
:Repeating the last command, <code>apt-get install clang-6.0</code> reproduces the same error, and gives additional information.

=== ERROR: Path for keyring is invalid: /etc/apt/trusted.gpg ===
* On <code>ERROR: Path for keyring is invalid: /etc/apt/trusted.gpg</code>. Must create the missing file [https://blog.sleeplessbeastie.eu/2014/01/30/how-to-manage-packages-on-an-off-line-debian-system/]:
<source lang="bash">
sudo apt-key exportall | sudo gpg --no-default-keyring --import --keyring /etc/apt/trusted.gp
</source>

=== ERROR: File /.../.../bundle.zip is not a valid zip file ===
* This error is likely due to offline system {{file|/etc/apt/sources.list}} not pointing to online repositories but to DVD instead [https://www.linuxquestions.org/questions/debian-26/apt-offline-trouble-getting-started-4175530701/#post5299262].

Latest revision as of 06:32, 6 January 2023

apt-offline is a tool to manage packages on a remote system that has no direct connection to the internet.

References

Install

First you need to install apt-offline on the offline and proxy systems.

sudo apt-get install apt-offline python-lzma

This usually requires an internet connection, but another solution is to first install the package on the proxy system, then copy the package .deb file from /var/cache/apt/archives into same directory on the offline system. Now install the package on the offline system using apt-get as usual.

Upprade offline system

  • On offline system, check the source list has the online repo enabled (not DVD).
  • On offline system, generate the reference signature file:
sudo apt-offline set --update --upgrade /path/to/apt.sig                                # ... OR ...
sudo apt-offline set --update --upgrade --upgrade-type dist-upgrade /path/to/apt.sig
  • On proxy system, download the necessary packages:
apt-offline get -d /path/to/download/directory /path/to/apt.sig                         # ... OR ...
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig

Note that apt-offline will complain if bundle.zip exists already, so a better command to keep in shell history is:

apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig || rm /download/path/bundle.zip
  • Back on offline system, install all the packages:
sudo apt-offline install /path/to/bundle.zip
sudo apt-get upgrade                                # ... OR ...
sudo apt-get dist-upgrade

Install a package on offline system

  • On offline system, check the source list has the online repo enabled (not DVD).
  • On offline system, generate the reference signature file and request installation of package (here vlc):
sudo apt-offline set --install-package vlc -- /path/to/apt.sig
  • On proxy system, download the necessary packages:
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig
# ... or better:
apt-offline get --bundle /download/path/bundle.zip /path/to/apt.sig || rm /download/path/bundle.zip
  • Back on offline system, install all the packages:
sudo apt-offline install /path/to/bundle.zip
sudo apt-get install vlc

Install build dependencies

This is equivalent of apt-get build-dep neovim/stretch:

sudo apt-offline set --install-src-packages neovim/stretch --src-build-dep -- /path/to/apt.sig

Troubleshooting

Use --verbose

  • Use --verbose to troubleshoot errors.

ERROR: FATAL: Something is wrong with the apt system.

  • On ERROR: FATAL: Something is wrong with the apt system.
  • Check that given directory exists
  • If getting many errors like ERROR: Failed to unlink /var/lib/apt/lists/partial/...amd64_Packageapt-offline, try installing package python-lzma [3].
  • When downloading source packages, the source package are downloaded in /tmp folder. See console output:
sudo apt-offline install /smb/docs/minashare/MPeeters/apt/bundle.zip
# Proceeding with installation
# Installing src package file terminator_1.90+bzr-1705-1.dsc to /tmp/apt-offline-src-downloads-9342.
# Installing src package file terminator_1.90+bzr-1705.orig.tar.xz to /tmp/apt-offline-src-downloads-9342.
# Installing src package file terminator_1.90+bzr-1705-1.debian.tar.xz to /tmp/apt-offline-src-downloads-9342.
# ...

sudo cp /tmp/apt-offline-src-downloads-9342/* .
sudo apt source terminator
# Reading package lists... Done
# NOTICE: 'terminator' packaging is maintained in the 'Svn' version control system at:
# svn://anonscm.debian.org/python-apps/packages/terminator/trunk/
# Skipping already downloaded file 'terminator_1.90+bzr-1705-1.dsc'
# Skipping already downloaded file 'terminator_1.90+bzr-1705.orig.tar.xz'
# Skipping already downloaded file 'terminator_1.90+bzr-1705-1.debian.tar.xz'

E: Unable to correct problems, you have held broken packages

  • If getting error ERROR: Unable to correct problems, you have held broken packages, try first to install with aptitude. Doing so will indicate which packages have a conflict.
  • Using --verbose, always gives which command failed:
Generating database of package ['clang-6.0'] and its dependencies.
VERBOSE: Command is ['/usr/bin/apt-get', '-qq', '--print-uris', 'install', 'clang-6.0']
E: Unable to correct problems, you have held broken packages
Repeating the last command, apt-get install clang-6.0 reproduces the same error, and gives additional information.

ERROR: Path for keyring is invalid: /etc/apt/trusted.gpg

  • On ERROR: Path for keyring is invalid: /etc/apt/trusted.gpg. Must create the missing file [4]:
sudo apt-key exportall | sudo gpg --no-default-keyring --import --keyring /etc/apt/trusted.gp

ERROR: File /.../.../bundle.zip is not a valid zip file

  • This error is likely due to offline system /etc/apt/sources.list not pointing to online repositories but to DVD instead [5].