# Chapter 10. Offline Package Management

The tool apt-offline is available to help keep your computer up to date even if it cannot be kept connected by using a second internet connected computer, this other computer can run Xubuntu, another flavor of Ubuntu, or Debian. A graphical interface is available via apt-offline-gui. This document deals with the command line variant.

Throughout this chapter directions to use a directory on a USB flashdrive are given, the naming and path to this directory is for you to decide beforehand.

A few specific packages are not built to handle the disconnected environment, due to them running download scripts during the installation or upgrade process. Some packages that routinely exhibit this behavior are flashplugin-installer, nautilus-dropbox, and ttf-mscorefonts-installer. There is no workaround for installation packages that themselves make downloads.

You will want to avoid the use of the `-y` flag when upgrading so that you get a last chance to look through your upgrades to see if any problems mentioned above show up.

During the use of apt-offline some errors in red text may show up about being unable to download files relative to translations, these can be safely ignored.

## Updating Repositories

After plugging in a USB flash drive and opening a terminal, you can use apt-offline to generate a request to update what your computer knows about software repositories. This allows your computer to see if there are bug fixes, security updates or new software available for your computer.

From your disconnected computer run: `apt-offline set --update apt-offline.sig`

Once done, copy `apt-offline.sig` to your USB flash drive and take it to another computer. With apt-offline on that computer, use that file to download what your disconnected computer needs to update itself. Navigate to the directory on the flash drive containing apt-offline.sig, enter `apt-offline get --bundle bundle.zip apt-offline.sig`. When complete remove the USB flash drive and take it back to the disconnected computer.

At the disconnected computer, re-insert the USB flash drive. Navigate to the directory on the flash drive containing the two files, then enter: `sudo apt-offline install bundle.zip`. Once the command completes your repositories will be updated.

## Installing a Package

You can use apt-offline to download a package to install. This action can also be combined with updating the software repositories. In a disconnected environment, using opportunities to connect efficiently is key.

In this example, we assume you want to install a new program package. Throughout this we'll refer to this as PACKAGENAME though in normal use you will want to enter just the package name. Fairly frequently, installing a package will require you to install dependencies. apt-offline handles the dependency resolution for you. To start this process open a terminal window, plug in a USB flash drive, and navigate to the directory. From that directory run `sudo apt-offline set --install-packages $PACKAGENAME --update apt-offline.sig`to start the process

When complete, copy `apt-offline.sig` to your USB flash drive and take it to another computer. With apt-offline on that computer, use that file to download what your disconnected computer needs to update and install PACKAGENAME. Navigate to the directory on the flash drive containing apt-offline.sig, run `sudo apt-offline get --bundle bundle.zip apt-offline.sig`. The output will show an attempt to download repository updates as well as PACKAGENAME and any dependencies your system requires. Remove the USB flash drive when complete and take it back to the disconnected computer.

At the disconnected computer, insert the USB flash drive. Navigate to the directory on the flash drive containing the two files then enter: `sudo apt-offline install bundle.zip`. Once it completes your repositories will be updated. Once that completes, you can then install PACKAGENAME by then entering: `sudo apt-get install PACKAGENAME`.

## Upgrading Your System

Upgrading packages requires 2 stages: updating repositories and then the download and upgrade as required.

First update your repositories following the instructions in Updating Repositories

Clear the directory on USB flash drive that you have used previously. In a fresh terminal window, navigate to the directory on the USB flash drive you intend to work from. Since we never want to lose the opportunity to refresh the disconnected machine's view of the repositories, we can build the command to not only look for upgrade packages but also to update repositories. Enter `apt-offline set --update --upgrade apt-offline.sig`

Once done, copy `apt-offline.sig` to your USB flash drive and take it to another computer. With apt-offline on that computer, you use that file to download what your disconnected computer needs to upgrade itself. Navigate to the directory on the flash drive containing apt-offline.sig, run `sudo apt-offline get --bundle bundle.zip apt-offline.sig`. The output will show an attempt to download repository updates as well as any upgrades and dependencies required by your system. Once done, remove the USB flash drive and take it back to the disconnected computer.

At the disconnected computer, insert the USB flash drive navigate to the directory on the flash drive containing the two files, enter `sudo apt-offline install bundle.zip`. Once it completes your repositories will be updated, you can then install the upgrades by entering: `sudo apt-get upgrade`.

Chapter 9. Managing installed applications |  | Chapter 11. Keeping your computer and personal information safe