# 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. There are multiple steps involved in the process of doing this. With a USB flash drive available to you, this can be managed.

## 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 and/or security updates available to apply to your computer. This also allows you to know if new software is available.

From your disconnected computer you enter this at the command line: `apt-offline set --update apt-offline.sig`

After that command is done and the `apt-offline.sig` is created, copy that 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 update itself. Assuming you are in the terminal and in the directory on the flash drive containing `apt-offline.sig`, you enter `apt-offline get --bundle bundle.zip apt-offline.sig`. Once that command is done, you can remove the USB flash drive and take it back to the disconnected computer. Some errors in red text may show up about being unable to download files relative to translations but these can be safely ignored.

Back at the disconnected computer, insert the USB flash drive. Assuming you have opened a terminal and have navigated to the directory on the flash drive containing the two files you then enter: `sudo apt-offline install bundle.zip`. You will see some program output scroll by and once it completes your repositories will be updated.

## Installing a Package

After plugging in a USB flash drive and opening a terminal, you can use apt-offline to grab a package to install. This action can also be combined with updating your computer's understanding of the contents of the software repositories. In a disconnected environment, using what connection opportunities you have to the max is key

In this example, 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 you want without the dollar sign. Fairly frequently installing `$PACKAGENAME` will result in the need to also grab dependencies instead of just a single package file. apt-offline handles the dependencies resolution for you. To start this process you need to open a terminal window, plug in a USB flash drive, and navigate to a directory on the flash drive. From that directory you then enter at the command line to start the process: `sudo apt-offline set --install-packages $PACKAGENAME --update apt-offline.sig`

After that command is done and the `apt-offline.sig` is created, copy that 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 update itself. Assuming you are in the terminal and in the directory on the flash drive containing `apt-offline.sig`, you enter `sudo apt-offline get --bundle bundle.zip apt-offline.sig`. The command's output will show an attempt to download updates as to what the repositories look like as well as $PACKAGENAME and the dependencies your system requires. Once that command is done, you can remove the USB flash drive and take it back to the disconnected computer. Some errors in red text may show up about being unable to download files relative to translations but these can be safely ignored.

Back at the disconnected computer, insert the USB flash drive. Assuming you have opened a terminal and have navigated to the directory on the flash drive containing the two files you then enter: `sudo apt-offline install bundle.zip`. You will see some program output scroll by and 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

A few specific packages are not built to handle the disconnected environment. This is 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 work-around for installation packages that themselves make downloads.

An upgrade of packages is a two-round process for those using a disconnected computer. During the first round you need to update your computer's view of the repositories to know that something has an update available. Only during the second round can you download the upgrade packages.

First plug in a USB flash drive and open a terminal. From your disconnected computer you enter this at the command line: `apt-offline set --update apt-offline.sig`

After that command is done and the `apt-offline.sig` is created, copy that 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 update itself. Assuming you are in the terminal and in the directory on the flash drive containing `apt-offline.sig`, you enter `apt-offline get --bundle bundle.zip apt-offline.sig`. Once that command is done, you can remove the USB flash drive and take it back to the disconnected computer. Some errors in red text may show up about being unable to download files relative to translations but these can be safely ignored.

Back at the disconnected computer, insert the USB flash drive. Assuming you have opened a terminal and have navigated to the directory on the flash drive containing the two files you then enter: `sudo apt-offline install bundle.zip`. You will see some program output scroll by and once it completes your repositories will be updated.

This completes the first part to the process. You'll know now whether or not there are packages to upgrade. If there are packages to upgrade you can continue onward otherwise it is okay to stop.

Clear the 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 build the command to not only look for upgrade packages but also to update repositories. You will want to enter: `apt-offline set --update --upgrade apt-offline.sig`

After that command is done and the `apt-offline.sig` is created, copy that 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 update itself. Assuming you are in the terminal and in the directory on the flash drive containing `apt-offline.sig`, you enter `sudo apt-offline get --bundle bundle.zip apt-offline.sig`. The command's output will show an attempt to download updates as to what the repositories look like as well as the upgrades as well as their dependencies that may be required by your system. Once that command is done, you can remove the USB flash drive and take it back to the disconnected computer. Some errors in red text may show up about being unable to download files relative to translations but these can be safely ignored.

Back at the disconnected computer, insert the USB flash drive. Assuming you have opened a terminal and have navigated to the directory on the flash drive containing the two files you then enter: `sudo apt-offline install bundle.zip`. You will see some program output scroll by and once it completes your repositories will be updated. Once that completes, you can then install the upgrades by entering: `sudo apt-get upgrade`.

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 earlier like flashplugin-installer or nautilus-dropbox show up. It takes just a moment but prevents some possible moments of grief later on.

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