Offline Package Manager - apt-offline

 

A copy of this article is also available at: 

http://www.debian-administration.org/article/648/Offline_Package_Management_for_APT 

This article is about Offline Package Management in Debian. Debian is a pretty well known project. One of the things that makes Debian very popular is APT (a.k.a Advanced Packaging Tool) which allows remote package downloads, upgrades and dependency resolution. Unfortunately it does require a network connection - unless you use apt-offline.

In Debian, when you need to install a package, you usually would fire up the apt-get command and the software would just install without any hand holding.

While APT is really very cool one of the main reasons for its success is the Debian Policy. The Debian Policy is like the brain of the project that controls the entire project ensuring that all the bits and pieces fit well together upto the Debian Standards. APT is just a result of the fantastic Debian Policy work.

In Debian, every package is very well self-contained and is tightly related to each other using APT. APT does a very good job of integrating and resolving dependencies for Package Management and takes off all the Dependency Hell problems from the user.

This is where the problem starts - for a machine which has network access it works very well because APT generates the list of packages and their dependencies and is able to download and install them successfully.

But when it comes to downloading a package individually on a different machine, along wih resolving any dependencies this can be a big problem.

Consider this real world example: I have a Debian box at home. At home, I have no (or very slow/expensive dial-up) internet connection. At work, I (or my friend) do have a very fast connection but (as part of IT policy) am required to use Windows.

I would still like to be able to painlessly update/upgrade my Debian box at home, with all the power and flexibility of APT.

This is where apt-offline is useful. apt-offline is an offline APT Package Manager.

Using apt-offline:

  • You generate a signature on your Debian box at home and carry the signature file on a removable medium (Probably a USB Stick).(e.g. "apt-offline set /tmp/apt-offline.txt")
  • Now you take the USB Stick (with the apt-offline.txt signature file) to the office machine which could be running any linux version, or as I mentioned above, even Windows.
  • There, you could run apt-offline giving it the signature file. (e.g. "apt-offline get C:\apt-offline.txt")
  • apt-offline would generate you an archive file or a folder with all the data. That data can be copied on a removable media. The removable media can be attached back to the disconnected Debian box at home and installed. (e.g. "apt-offline install /tmp/apt-offline.zip")

Let's start with a 3 step example

Step 1

Generate a signature file on the Disconnected Debian box at home

apt-offline set /tmp/apt-offline.sig

The above command will generate all information required from apt about updating its database.

By default, with no additional arguments passed, apt-offline will extract information about APT Package Database Update i.e. the --update option as well as the list of Packages to be upgraded i.e. the --upgrade option.

These options can also be individually passed if you want only one of those.

Step 2

Download data based on the signature file generated earlier

apt-offline get C:\apt-offline.sig --threads 5

The above command will download data as mentioned in the signature file. To speed up downloads (that can be from multiple apt repositories), in this example we spawn 5 download threads.

Note: It would be good to also download the bug reports for the packages that you are downloading. So that example now becomes:

apt-offline get C:\apt-offline.sig --bug-reports --threads 5

There are many more options that you can pass to apt-offline, like the --bundle option which would generate for you, an archive file with all the data.

Once completed, you could just copy the data (an archive file, if you used the --bundle option) back to the removable medium and copy it back onto your offline host.

Step 3

Once you're back upon the home Debian machine, you feed the data from the removable medium to apt-offline:

apt-offline install /media/USB/apt-offline.zip

This will update the APT database on your disconnected machine seamlessly.

If there were packages that needed to be upgraded, now they would all be available (with dependencies) in the APT database. So if you do an apt-get upgrade now, APT won't prompt you mentioning even a single bye download. APT would find that all required packages are already present in the APT cache.

If you had used the --bug-reports switch that I mentioned earlier, during install apt-offline would prompt you with the list of bug reports related to the packages on your machine that need be upgraded/installed - not just the list but the full bug report will be available for you to look at and evaluate the severity involved.

As you can see from the article above, apt-offline helps you achieve the power of APT, in just 3 steps. apt-offline is part of Debian and is developed at Alioth and Github.

 

Keywords: 

Categories: 

Comments

Ritesh Raj Sarraf's picture

An introduction to Apt-offline

Author: http://toggwu.blogspot.in/2015/04/an-introduction-to-apt-offline-amazing...

 

An introduction to Apt-offline, the amazing sneakernet repo-link for web-access-impaired Debian Linux installations

 
Figure – Suggested organization-scheme for flash drive used with Apt-offline
 
 

A Debian "package" is a group of files which is required to make a change to a Debian installation, such as to add an app. The primary sources of these files are online repositories contained on a large selection of servers around the world. Obtaining a package via apt-offline requires three items specific to the package: a) a signature-file, which is a type of download-script (a list of the URLs of the files to be downloaded); b) a package-folder (a folder reserved for the package); and c) a get-command which points apt-offline's download-manager to items a) and b). For details on creating these items, see section V, subsection >Performing the set-process.

I. Introduction

I tried to use apt-offline years before writing this, but gave up quickly due to a lack of a tutorial and because I had had some frustrating experiences with unofficial supposed Ubuntu programs which turned out to be practical jokes designed to cause frustration, and apt-offline seemed to fit this profile at the time. Consequently, I made do without it for years, but eventually decided to get serious about finding something with apt-offline's supposed capabilities. As a result, I found that apt-offline works as advertised, and for the benefit of newbies lost in the wilderness of vague descriptions, lists of commands, and forums which provide no answers or non-answers and send them on wild goose chases, I decided to create this tutorial to bring together most if not all of the information which they would need in order to use it, and to assure them that it's worth the effort. If I knew how difficult it would be, I would have never started. It's easy to learn in an interactive setting (I suppose it's taught in classes in regions where Linux is popular due to its low cost, and internet access is generally slow, unreliable, or unavailable), but it's extremely difficult to explain in detail in writing, which might be why I was unable to find a tutorial when I first became interested in it.

Hopefully, this will help to popularize Ubuntu, Linux Mint, and other varieties of Debian Linux by assuring people that they will be able to make changes to their installations even if they ever find themselves without a high-speed internet connection. These are great OS's with powerful apps and a potential for the highest levels of security at minimal cost. They're getting better all the time with gradual refinements, and some major changes, too. For example, Ubuntu will eventually get a new software system named Snappy, which will help to make Ubuntu more popular and make apt-offline obsolete as far as Ubuntu and its offshoots are concerned. But as of this writing (August 2015), that could be a few years off, and the Debian system will still be around after that.

II. What apt-offline is/does

apt-offline is a software module written in the Python language, and it can be adapted to any major OS by using a Python adapter ("interpreter") specific to that OS. (The interpreter would be installed first, and then apt-offline. This is very easy to do - details later.)

apt-offline's purpose is to provide web-access-impaired Debian Linux installations with complete access to their associated online software repositories, which are the primary source of software for making changes to such installations. I doubt that there will ever be anything else that does this with the same combination of high performance, low cost, convenience, and lack of significant inconvenience to anyone else. To appreciate the achievement represented by apt-offline, and to know how to use apt-offline effectively, it's necessary to understand a little about how the Debian system functions, so I explain the basics later.

To use apt-offline, it is installed on a web-access-impaired Debian Linux installation, and on any device with a Python interpreter and a high-speed internet connection. These two apt-offline installations are used alternately (Debian PC/download-device/Debian PC) to perform three complementary processes ("set," "get," and "install" - details below). The data produced by each of the first two processes is transferred to the other apt-offline installation via flash drive or SD card to be used as an input for the subsequent process.

Using apt-offline requires some learning and introduces lengthy delays into the change-process compared to using a direct high-speed internet connection, but this is a small price to pay, considering the benefits (access to the installation's corresponding repository without a high-speed internet connection, or the bills for it). If you don't have high-speed internet access at home, chances are that you already periodically visit a high-speed-internet-access point. So, using apt-offline to download data would require very little additional time or effort over the long term.

On the Debian installation, apt-offline acts as a pair of convenient interfaces (a GUI and 2 text commands) to the Debian software manager (Advanced Packaging Tool, or APT) and to the OS, for performing the following functions:

A) Specifying/entering the desired high-level changes, such as to install apps or upgrade the installed software.

B) Translating the desired changes into the possibly-extensive list of modules/files required to implement the changes (explained below).

C) Giving this list a name (preferably one which reflects the desired high-level changes specified in step A) and saving it to a flash drive or SD card.

A, B, and C are all part of the "set" operation, which begins by specifying the changes to be made and the name and location for the aforementioned list, which is done by entering this information into the GUI, or putting it in a set-command. (In my experience, the GUI is sufficient for this purpose, but set-commands provide additional options which some people might want to use in some situations.) Then, the GUI's Create button is clicked or the Enter key is pressed, respectively, and apt-offline converts the GUI-inputs or the set-command into commands for APT and any required OS-functions, which then perform the aforementioned translation, generate the aforementioned list, and store it with the designated name in the designated location (preferably on the flash drive used for transferring data between the two installations, since it will have to be placed there eventually anyways).

(Then, the flash drive containing the list is transferred to the download-device, where apt-offline is used in its "get" mode to read the list and download the listed files to a folder on the flash drive, which is then transferred back to the PC running the Debian installation of interest.)

D) Copying the downloaded files to certain directories in the Debian installation where they must be placed for actual installation. This copying-process is the apt-offline "install" operation, which would require considerable knowledge and effort to perform manually. Actual installation is a separate step which can be performed in various ways. I use Synaptic Package Manager or Ubuntu Software Center, which are general-purpose GUI's for APT. Details are provided later. 

On the download-device, apt-offline acts as a download-manager with special APT-derived functions. It is controlled by "get" commands (essentially "download the files listed in file XYZ at this location on this flash drive and put them in folder XYZ in this location on the same flash drive"). I create these commands at home and store them (along with other commands covered later) in a batch file on the flash drive so that the get-process can be initiated by simply clicking on the batch file. The key to a successful get-operation is organization, and my system makes this easy. After using it a couple of times, the "hardest" part of the overall process is deciding what to name the lists of files to download. Everything else is routine.

apt-offline is available in various revisions and forms. The latest revision at any given time would be the best one to use, and the form I prefer is the .zip file. If you want to install apt-offline in an Ubuntu installation, for example, it might seem convenient to install it in the form of a .deb-file through the Ubuntu Software Center, but the revision might not be the latest, and unless the download-device is also running a Debian installation, you'd still need to get the .zip file and learn how to install it (which is easy). So, you might as well get the latest version in the form of a .zip file, and use it for both the Debian installation and the download-device. Details on downloading the .zip file and installing it are provided below.

A Python interpreter is included in Ubuntu and Linux Mint installations, and I assume that this is also the case with other major varieties of Debian. (Some varieties are designed to be as small as possible, so they might make Python optional.) To see if Python is installed, just enter "python" (w/o quotes) into the command-line. If it's not installed on a particular device, you'll have to install it before installing apt-offline, but this is easy (details below).

III. Why apt-offline was created

Making changes to a Debian installation is a complex process which is fortunately automated by APT. This complexity is due in part to the fact that Debian programs are modular. Individual modules/files can be used by multiple programs, so only one copy of a module is required in an installation in order to install multiple programs which use that module.

When someone tells APT to add an app to an installation (either via text command or a GUI such as Ubuntu Software Center or Synaptic Package Manager), APT refers to a) the "local package index" (an installed copy of selected sections of the online package index, which lists all of the files required by each app contained in the repository, and is revised nightly to reflect changes to the repository); and b) a list of all of the files already installed, to determine which files must be downloaded and installed in order to add the app. This group of files is sometimes referred to as the "package," which is loosely defined as any group of files required to make a change to an installation at a given time. The package required to install a particular app on particular installation at a particular time might be different than the package required after other changes have been made to the installation. The packages listed in the package index include all files which could possibly have to be installed in order to add the corresponding apps.

After determining which files need to be downloaded, they are downloaded and installed, assuming that the installation has an internet connection which is fast enough to download the required data in a reasonable amount of time. If the installation's internet connection is slow or nonexistent, APT can generate a "download-script" (a text file which lists the URL's of the files which need to be downloaded), instead of downloading the files. The script would be fed into a download-manager such as Wassail by Cortman, or FlashGot, running on a PC with a fast internet connection. The downloaded files would then be transferred back to the Debian PC and copied to the Computer/var/cache/apt/archives directory (this requires "superuser privileges," obtained as described elsewhere in this tutorial) and installed via Synaptic, the Software Center, certain text-commands, or some other interface to the fundamental Debian software-installation program known as dpkg.

One option for generating a download-script is to use Synaptic Package Manager, a general-purpose APT-GUI which is standard in Linux Mint but optional in Ubuntu. To install Synaptic itself on an access-impaired Ubuntu installation, you could generate a download-script using a special command [1], which is what Synaptic would generate and send to APT if it could be used for generating a download-script for itself.

To generate a download-script for a particular app, the local package index must include the package-index-section pertaining to the app, and it must be more recent than the desired version of the app. Obtaining a current copy of the required section or sections of the package index is the purpose of the package-index-update ("update") operation, which includes a step to specify the desired sections of the online package index (known as 'editing the sources-list'). The package index is downloaded in a compressed form, but even so, the download can range from 10-20MB, depending on which sections are selected. You might wonder why it's not possible to access the online listings directly. I don't understand it myself, but the system designers obviously had good reasons for doing it the way they did, and you'll just have to deal with it (with apt-offline), although Ubuntu will eventually adopt the Snappy system which doesn't use a package index. 

If the Debian installation of interest has a fast internet connection, updating the package index is easy. If it doesn't have a fast connection, the package index can be downloaded by creating a download-script, and feeding it into a download-manager running on a device with a fast internet connection. However, properly downloading the package index requires a special download-script known as a signature file (which contains names generated by APT to be assigned to the files listed in the download-script as they are being downloaded), and a download-manager with special functions derived from APT, including the ability to authenticate the source, and the ability to assign the aforementioned new names to the files as it downloads them. (I've used a regular download-script and a regular download-manager to download package-index files, but I was unable to verify the source, and the files all ended up with the same name but different copy-numbers, which would have made it impossible to use them even if I knew how to install them.)

apt-offline was created to provide the special capabilities required for downloading the package index, but it ended up with the ability to facilitate every type of change which an installation could possibly need. However, to make apt-offline feasible, the complex process of translating the desired high-level changes into lists of files is not transferred to the download-device. This isn't much of a problem unless you're in a hurry to get something such as a new release which isn't listed the local package index (i.e. the installed copy of selected sections of the online index), because this would require two trips to your high-speed access-point: one trip to download a copy of the package index which lists the item of interest (after which the copy would be installed in the Debian installation and used for generating a download-script for the the item of interest), and another trip to download the item itself. (The trip to download the package index can be eliminated in some cases by periodically downloading a copy of the package index to a flash drive to have a relatively recent copy on hand in case it would help.) But without apt-offline or something like it, it would be less convenient and/or more expensive to update the package index in web-access-impaired Debian installations. So the minor inconveniences of using apt-offline are a small price for its benefits.

If apt-offline is installed, you won't need Synaptic to generate download-scripts, but I'd still get Synaptic because for one thing it provides more complete access to the contents of the package index than does the Software Center. For example, if both are used to search for GIMP, the Software Center lists GIMP, but Synaptic lists GIMP and its many accessories. Each listing includes a special name (lower case, no spaces) for the item of interest, and this name is required in order to install the item with apt-offline. There might be another way to obtain this information, but I'm sure I could always find a reason to install Synaptic.

IV. What apt-offline does, more specifically

Debian is a category of Linux which includes Linux Mint and Ubuntu, which are among the most popular varieties of Linux. Debian software consists of groups or "packages" of modules. (In general, a package is any group of files required to make a change to an installation at a given time. The package required to install X at one time can be different than the one required to install X after the installation has been changed.) An individual module can be used by multiple programs, and only one copy of the module is installed even if it's used by several programs. The primary software source for each type of Debian (Ubuntu, Mint, etc.) is its corresponding repository ("repo"). Each repository contains tens of GB of data and is "mirrored" (copied) to a large selection of servers around the world. The repository includes a "package index" which keeps track of all of the files used by each program in the repository.

There is always something in the repository which is being revised, and more software is being added all the time. Each night, revisions are posted to the repository, and the package index is revised to reflect these revisions.

Each Debian installation has a "local" copy of selected sections of the online package index, and a list of installed files. To install a particular piece of software, the software which performs the installation, known as the "package manager," refers to the local copy of the package index and to the list of installed files to determine what files have to be downloaded in order to install the software. It then creates a list of the required files and either downloads them directly, or creates a "download-script" (a file with the list in it) so that the files can be downloaded with a download-manager on another PC. (The package manager does a lot more, but that's the basic idea.) If you want to install something such as a newly-released app-revision which isn't listed in the local copy of the package index, you'd have to download and install a new copy of the package index before generating a download-script for the new app-revision.

The package index is divided into sections, because it's usually downloaded to get the latest information on a single piece of software, and it would be wasteful to download the entire index every time. (The system designers evidently good reason for not allowing the online index to be accessed directly.) Selecting the sections to be downloaded is a matter of editing the "sources-list" with a package-manager GUI or via commands entered into the terminal. To edit the sources-list with Ubuntu Software Center, select Edit, then Software Sources.

In summary, the normal process of making some change to an installation (when there's a direct high-speed internet connection between the installation and the repository) starts by changing the sources-list if required, and updating the package index if required. Then the package manager uses the local copy of the package index and a list of already-installed files to translate the desired changes into a list of files (potentially hundreds), and then the files themselves are downloaded and installed.

This approach is obviously out of the question for installations with no internet connection, or for installations with slow connections when the desired changes require massive downloads. (Just updating the package index can require downloads on the order of 10-20MB, and some apps can require downloads between 50 and 100MB.)

This is where apt-offline comes in handy. It basically splits off the download-phases of the normal installation process  so that they can be transferred to any device with a Python 2.x interpreter and a fast internet connection. The catch is that apt-offline doesn't transfer the aforementioned translation process to the download-device, presumably due to its complexity. So, if the package index is downloaded, it's not used for anything until after being installed on the Debian installation, and any apps downloaded at the same time would be based on the local package index which existed when the download-script was generated. This isn't a problem unless you're in a hurry to get something which isn't listed in the currently-installed copy of the package-index (meaning that you'd have to download the required section of the package index, install it and use it to generate a signature file for the app, and then download the app), and you don't get an opportunity to gain high-speed internet access very often. You might be able to eliminate the trip for the package index by using apt-offline to download a copy of the package index to a flash drive whenever you do have high-speed internet access, and thus increase your chances of always having a sufficiently-recent index-copy on hand. You wouldn't install the copy unless you need to generate a download-script, so minimal effort would be required to potentially save a lot of time.

apt-offline splits off the download-phases by facilitating the creation and use of download-scripts for apps (which was nothing new - Synaptic package manager provided this capability years earlier) and for the package index (which is apt-offline's main advantage, obtained by creating a Python-based download-manager with special APT functions, otherwise known as apt-offline's get-mode). The creation-phase ("set" phase) is naturally performed on the installation which is being modified, and it can be done by entering potentially complex apt-offline "set" commands into a terminal-window, or by launching the apt-offline GUI, selecting its Generate Signature (set) mode, etc. The GUI has always been sufficient in my experience, but entering commands directly allows more options to be used.

The result of the set-process is a "signature" file, which is essentially a download-script which includes new names (generated by the package manager) to be assigned to the files as they are downloaded (perhaps these new names are the "signature"). Package-index files would be useless without their new names. The new names for some files are the same as the original names, but it makes apt-offline's job easier to just assign the  names provided by the package manager than to decide whether to rename a particular file.

Each app has a special lower-case name without spaces for use in certain situations, such to include in set-commands or to be entered into apt-offline's GUI. For example, the special name for GIMP's English help-file is gimp-help-en. These names are included in the package index, and can be found by opening a package-manager GUI and performing a search for the app of interest. (Synaptic is better than the Software Center for this purpose, since it provides more complete access to the listings in the package index. For example, if both are used to search for GIMP, the Software Center lists GIMP, but Synaptic lists GIMP and all of its accessories. This assumes that the section of the package index pertaining to GIMP is installed.)

To perform the set-process, apt-offline's GUI is typically launched with the command "sudo apt-offline-gui" (without quotes) and its "generate signature" mode (a more descriptive name for the "set" mode) is selected. In the resulting window, the desired changes are entered. The desired name and location for the signature file are entered Into the Save Signature As box, or into a sub-window which is opened by pressing the Browse button to the right of the box. After all of the selections are made and any required data is entered, the Create button is pressed, which causes the sig-file to be generated and stored in the designated location with the designated name. I also at the same time create the other items which will be required to perform the get-process: a package-folder (a folder reserved for the files to be downloaded), and a get-command. (It might help you to remember these items by thinking of the get-command as a link between the sig-file and the package-folder, since it is what tells apt-offline to read the sig-file, download the listed files, and put them in the package-folder.) 

===========

Note

The flash drive used as the link between the Debian installation and the PC, tablet, etc. used for the get-phase should have a Windows/FAT format so that it's compatible with all operating systems.

All flash-drive references in this article refer to this flash drive.

==========

The signature file is then transferred via flash drive (or SD card) to some device with a Python 2.x interpreter, an installation of apt-offline, and high-speed internet access, and the files listed in the signature file are downloaded to the flash drive by issuing an apt-offline "get" command (preferably via batch file, a.k.a. shell-script, because in this case, it's more convenient than using the GUI) which points apt-offline to the signature file and optionally tells it where to put the downloaded files. apt-offline validates the source to protect against malware, and performs a lot of error-checking on the data as it is downloaded. It also renames the files as they are downloaded, using the names which the package manager placed in the signature file. The files are saved in a deeply-buried temporary directory unless the -d [path\folder] option is used in the get-command, in which case the downloaded files would be saved in the specified folder. For convenience and to avoid the possibility of forgetting to transfer the downloaded files to your flash drive, I recommend creating a package-folder as described previously, and using the -d option to save the downloaded files to the package folder.

Next comes the install-phase. The results of the get-process - potentially hundreds of files on a flash drive in a folder by themselves - are transferred to the PC on which the Debian installation of interest is running. Then apt-offline GUI is launched with superuser privileges ("sudo apt-offline-gui") and the Install mode is selected. In the Install Packages window which then appears, the location of the downloaded files is identified, and the Install process is started. apt-offline then copies each type of file in the selected folder to the directory in the Debian installation where that type of file must be located for actual installation (a separate process which is performed with the package manager). So, the Install process is a complex copy-operation which would require considerable knowledge and effort to perform manually.

Actually installing package index files after performing the apt-offline Install operation amounts to opening Synaptic or the Software Center for a few minutes (see section below on rebuilding the search index). Actually installing app-packages (after performing the apt-offline Install operation) can be accomplished in a variety of ways, but I prefer to use Synaptic to install them as if I were installing them over a high-speed internet connection. If I'm limited to the Software Center, I would go to Computer/var/cache/apt/archives (which is where apt-offline puts app-packages) and double-click on the top-level file in the package to be installed.

> Rebuilding the search index

As mentioned previously, apt-offline's "install' operation is actually a complex copy-operation which copies downloaded packages from the flash drive to the directories in the installation where they must be placed in order to actually install them. For package-index files, actual installation is a matter of being incorporated into the search index (known as rebuilding the search index), which the package manager does automatically if necessary when it is opened. The search index can be rebuilt, for example, by opening Ubuntu Software Center for a few minutes after performing an apt-offline Install operation which transfers some new package index files. Before installation can begin, however, all of the settings in the Edit/Software Sources window must be consistent with the new package-index files, including the server selected in the "Download from" menu. Then the package manager will rebuild the search index based on the new package index files. The process can be monitored with the System Monitor by pressing the button in the upper-left corner of the screen, entering "sys" in the search-box which appears, clicking on the System Monitor icon, and then selecting the Resources tab in the System Monitor window. The CPU activity remains high for a couple of minutes while the rebuild-process is performed, and it drops suddenly and remains low when it's done. Then it would be OK to generate a sig-file to install an app.

V. How to use apt-offline, in general terms

To make it feasible to provide a clear explanation of the nuts-and-bolts of using apt-offline, I decided to assume that a typical library-PC (a Windows 7 PC with a fast internet connection) will be used for performing the get-process. It should be fairly easy to adapt it to other devices.

For efficiency, you'll need a procedure for creating sig-files, package-folders, and get-commands, and a folder with a fixed location on the flash drive for sig-files and package-folders so that their paths (which are included in get-commands) will always remain the same, so that in order to create a get-command for a new package, just the sig-file name and the package-folder name have to be changed. Keeping them in a separate folder in a fixed location also makes it easier to find them. You can use my system (described later, in the context of performing the set-process), or create one of your own, keeping in mind that you'll probably want to use a batch-file (introduced below) to automate the get-process, that you might want to put more than one get-command in the batch file (such as to get packages for more than one installation), and that you might want to save the downloaded packages even after installing them, such as for re-creating an installation if something happens to it. 

A Windows batch file is just a text file with an extension of .BAT. By putting commands in a batch file, they can be executed by simply clicking on it, assuming that they could be executed by manually entering them on the command line in the order in which they are listed in the batch file. Since in this case the batch file will be executed on a Windows PC, the commands must conform to the syntax for Windows commands, and since some of them invoke Python, the Python interpreter will have to be installed before running the batch file. The Android/Linux equivalent to a Windows batch file is known as a shell-script (the "shell" is the text-interface to the OS). The first line in Linux shell-scripts must be #!/bin/bash, which declares what follows to be a shell script. Furthermore, their extensions must be .sh, and they must be assigned a special permission to allow them to be run as programs. To set permissions, right-click on the file, then click on Properties in the menu which appears, and the rest should be obvious.

Another consideration when designing a procedure is that if, during the set-process, you use a directory in the Debian installation as the destination for the sig-file, you'll have to have superuser privileges to do anything to the sig-file besides copy it, because apt-offline uses superuser privileges to perform the set-process. (apt-offline's GUI must be opened with "sudo apt-offline-gui" in order to generate a sig-file. If "sudo" is excluded from the command, the GUI will open, but if you try to generate a sig-file, you'll be told that superuser privileges are required.) It's best to avoid manually using superuser privileges if possible, because they include the power to inadvertently destroy the installation, such as by accidentally deleting a system-file. (But in case you're curious, you can obtain these privileges by opening the file manager with superuser privileges by entering the command "sudo nautilus" in Ubuntu, and "sudo caja" in Linux Mint. To exit this mode, close the file manager and the terminal-window.) If you want to have apt-offline save sig-files to the Debian installation, you can use the same name and location each time, so that each new sig-file would overwrite the previous one. You would copy each new one to the flash drive, and rename it if you so desire. So, there would be no need to use superuser privileges to prevent sig-files from accumulating in the Debian installation. But as far as I know, there's no good reason to save sig-files in the Debian installation.

====================

Note: If you try to execute an apt-offline command and the OS can't find apt-offline

It is sometimes necessary to set the default directory to the extracted apt-offline folder before executing an apt-offline command, but it would be an exercise in futility for me to try to cover every possibility. For example, to open apt-offline's GUI in Ubuntu or Linux Mint, you would enter "sudo apt-offline gui" without having to set the default directory to the extracted apt-offline folder, but in order to execute an apt-offline get-command in Windows, it is necessary for the extracted apt-offline folder to be the default directory. So, if you try to execute some apt-offline command and the OS tells you that it can't find apt-offline, change the default directory to the extracted apt-offline folder and try it again.

====================

> Installing apt-offline on the Debian installation

Assuming that you've already downloaded the apt-offline .zip file (details below), extracted it, and put the extracted file in the apt-offline folder on your flash drive, you would plug the flash drive into the Debian PC, open a terminal-window (press Ctrl-Alt-t in Ubuntu), and change the default directory to the extracted apt-offline folder by entering "cd [path to extracted apt-offline folder]" (w/o quotes). To get the path, right-click on anything in the extracted apt-offline folder, then click on Properties in the menu which appears, and highlight and copy the path displayed in the window which then appears. (The path might not be displayed in its entirety, so you would copy what you could and type the remainder, which is usually obvious. The beginning is what can be difficult to determine.) Once you get the path, save it somewhere convenient for future use. To paste this path into the command, click on the terminal-window and press Ctrl-Shift-v. Then press Enter, and the prompt in the terminal-window should should display the path just entered. This sets the default directory to the extracted apt-offline folder, as required to install apt-offline. Then you'd enter "python setup.py build" (w/o quotes) and then "sudo python setup.py install" (also w/o quotes). (If you're using an installation on an hdd/ssd, and you have a password, you will be prompted for the password to gain superuser privileges.) This installs both apt-offline and its GUI on the Debian installation.

> Performing the set-process

The actual set-process produces only the signature file, but it's the best point in the overall process to create a couple of other key elements used in the get-process: a) a folder reserved for the package to receive it as it is downloaded, and to keep it organized as a package for the install-process and in case you ever have to re-create the installation, and b) a get-command containing the paths and names of the sig-file and the package-folder. (It might help to think of the get-command as a link between the sig-file and package-folder, since it causes apt-offline to convert the list contained in the sig-file to a package of files in the package-folder.) The get-command must specify the sig-file, and although specifying a destination-folder (-d [folder]) is optional, it's the logical thing to do because otherwise the downloaded files are saved in some inconvenient location, requiring them to be found and copied to the package-folder. 

The system I chose for creating and organizing the various items involved in the get-process includes a method for naming the packages to be downloaded (i.e. an abbreviation for the intended installation and the intended purposes, and the approximate date). The sig-file name is the package-name followed by ".sig," and the package-folder name is the same as the package-name. Both are always placed in folder inout located in the top-level apt-offline folder, so their paths are always the same. The sig-file and package-folder paths and names are then inserted into a get-command in the batch file (located in the top-level apt-offline folder), which contains a get-command for every package to be downloaded in the corresponding download-session. The same batch file is used in each download-session, with perhaps a different number of get-commands, and with a new sig-file name and package-folder name in each get-command. 

So, with my system, preparing to get a new package would be a simple matter of doing the following:

A) Creating a suitable new package-name, as described above

B) Launching apt-offline's GUI with the command "sudo apt-offline-gui," selecting the Generate Signature (set) mode, and entering the desired high-level changes, the path to inout*, and the new sig-file name (i.e. the new package-name with ".sig" appended to it) into the Generate Signature window, and then pressing the Create button to create the new sig-file

================

* The folder inout would supposedly be the destination for the sig-file created by the set-process. The path to inout in this context would initially be obtained by clicking on Browse next to the "Save Signature As" box in the Generate Signature window, and in the window which then appears, navigating to inout, entering the desired sig-file name in the "File name" box, and clicking on Save. The path and filename would then appear in the "Save Signature As" box, and the path would be copy/pasted to a convenient location for future use. From then on, it could be copy/pasted into the "Save Signature As" box, followed by a slash and the new sig-file name, which is considerably quicker and easier than clicking on Browse and navigating to the inout folder. This approach could also be used during the install-process, although in this case, a slash and the package-folder name would be added to the path, since the files to be installed would be in the package-folder in inout. (Note that different operating systems have different paths to the same items on the flash drive used for apt-offline, so for example this Debian path wouldn't work in a get-command intended for a Windows PC, where the proper path would be _:\apt-offline\inout, where the underscore would be replaced by the letter assigned to the flash drive when it's plugged into the Windows PC.)

================

C) Creating a new package-folder (a folder reserved for the new package, with the same name as the package) and placing the new package-folder in folder inout 

D) Inserting the new sig-file name and the new package-folder name into their respective slots in a get-command, with the required or preferred options, in the batch file. (The get-command would presumably already contain the path to inout in each of these two slots. Assuming that the get-command will be executed on a Windows PC, the path to inout in the get-command will take the form of _:\apt-offline\inout (note that back-slashes are used in Windows, as opposed to forward-slashes used in Linux), where the underscore represents the letter - typically E - assigned to the flash drive when it's plugged into the Windows PC.) I use the -d option only, and include the Python path for those times when it's not possible to put Python on the Windows path (details below), and the path to the sig-file and the package-folder (in folder inout), resulting in "C:\Python27\python apt-offline get _:\apt-offline\inout\[package name].sig -d _:\apt-offline\inout\[package-folder name]," w/o quotes, where the underscore would be replaced by the letter assigned to the flash drive when it is plugged into the Windows PC. This creates a get-command specific to the sig-file/package-folder pair of interest. The sig-file's name is also used in the actual set-process, as described below.

The reason for including the path to the sig-file and the package-folder in the get-command is that in Windows, the default directory evidently has to be set to the extracted apt-offline folder when executing get-commands, meaning that the path to the sig-file and package-folder must be included in the get-command so that Windows can find these items (which are in folder inout) when it executes the command. If sig-files and package-folders were placed in the extracted apt-offline folder, it wouldn't be necessary to put their path in the get-command, but pasting a path into a slot in a get-command is nothing, and keeping these items in a separate folder makes things a lot easier in the long run. 

The get-command is put in a batch file in the apt-offline folder along with cd- and setup-commands so that apt-offline can be installed and the get-process initiated by just clicking on the batch file. (A library-PC will presumably be used as the download-device, meaning that Python and apt-offline will have to be installed at the beginning of each download-session. Python is installed by clicking on the interpreter-installer file (which should be stored on the flash drive) and then with a few more clicks, and then apt-offline is installed by the cd- and setup-commands in the batch file. The setup-process happens so quickly that it seems like the get-process begins as soon as the batch file is started.)

The batch file I use for the get-process (the only one I use with apt-offline - I use the GUI for the set and install phases) includes the following:

A) a "cd" command to change the default directory to the extracted apt-offline folder (cd /D _:\apt-offline\apt-offline, where the "/D" is required because the command will change the drive, and the underscore would have to be replaced by the letter assigned to the flash drive when it's plugged in)

B) the commands to install apt-offline ("python setup.py build" and "python setup.py install" - there is no "sudo" in Windows)

C) any required get-commands (one per package to be downloaded, written as described previously )

I suggest naming the batch file something like GoGet.BAT, and assuming that it's created in Linux, it should be saved with a Windows line-ending, which is an option in the bottom of the save-window. Otherwise, there won't be any line-breaks when you open it with Notepad in Windows, and it might not work as a batch file. It might be a good idea to make it read-only after entering the commands, to ensure that it can't be inadvertently changed. 

Before you can generate a sig-file for installing a new app-revision, the new app-rev must be listed in the local package index. If it's not listed in the local package index, you would first have to update the package index, i.e. replace the local package index with a fresh copy of the desired sections of the online package index. (The desired sections would naturally include the one which lists the desired app, plus any sections which you might need in the near future.) The first step in the update process would be to check the sources-list to determine whether it includes the desired sections, and to revise the list if necessary. In Ubuntu, this can be done by opening the Software Center and selecting Edit/Software Sources, etc. (If you use the Ubuntu Software Center to search for an app, and the local package index doesn't contain the required section, the Software Center will indicate which section is required.) The next step would be to generate a signature file for a package-index update, and then use apt-offline to get/download the package-index files and to "install" them (i.e. copy them to the Debian installation for actual installation). Then you would ACTUALLY install them by simply opening a package-manager GUI such as the Software Center and waiting for the installation-process to end, as described in the section above entitled Rebuilding the Search Index. Then you could generate a sig-file for the desired app-rev. As mentioned previously, apps are designated in the set-phase by using their special lower-case names without spaces, which can be found via package-manager GUIs. For example, the special term for GIMP's English help-file is gimp-help-en, and this is how the file would be designated in set-commands or in apt-offline GUI's Generate Signature (set) window.

If you don't get many opportunities to gain high-speed internet access, you could download a copy of your favorite sections of the package index each time you do have high-speed internet access, so that when you decide to install something, there would be a better chance that you'd have the required listing on hand. The downloaded copy wouldn't have to be installed unless you actually needed to use it. So, minimal effort would be required to potentially save a lot of time.

> The get-process

> Using apt-offline in get-mode on a Windows PC

Assuming that you will be performing the get-process on a library PC (typically a PC with Windows 7 and a fast internet connection), that neither Python nor apt-offline is installed on the PC by the system administrator, and that users are allowed to install them, you will have to install them every time you want to perform the get-operation, which very easy. The Python interpreter would be installed first as described below, and then apt-offline would be installed as described in the subsequent section. 

> Installing the Python interpreter

Installing Python wasn't mentioned in the previous section because it's installed by default in Linux (the version can be checked by entering "python" on the command line). But since I'm using a Windows PC as an example of the how to perform the get-process, and Python isn't included by default with Windows, the installation process is mentioned here.

Python for Windows takes the form of interpreter-installer (.msi) files. (For details on obtaining this file, see the section below entitled "Download required software." When you get it, save a copy on your apt-offline flash drive and back it up to avoid having to get it again.) Installation is a matter of clicking on the file's icon wherever it is on the PC (including on a flash drive plugged into the PC), and then clicking on some buttons in the resulting windows. However, it is not possible for users to install Python or other software on some library-PCs, due to the library's policies. You might be able to persuade a PC-administrator to add it to the list of programs which are installed during the booting-process, although I wouldn't bet on it. Another option would be to use some portable device with wifi, although wifi isn't always very fast.

Since apt-offline is written for Python 2.x (as opposed to 3.x, which is incompatible with apt-offline), 2.x has to be installed, and the latest version of 2.x as of this writing is 2.7.9. Even if it's installed, it can't hurt to install it again, and it might help (such as if there are problems with the existing installation). I've even had to install it twice to get it to work.

During installation, you are given the option of adding the Python path to the "Windows path," so that when you enter a Python command, Windows knows where to find Python without including its path in the command. But some library PCs don't allow the Windows path to be changed, so you would install Python without adding it to the Windows path, and include the Python path (which is C:\Python27 for Python 2.7.x, unless you specify a different path during installation) in any commands which invoke Python. (Windows has to be told where to find Python, one way or another.) So for example "python setup.py build" would become "C:\Python27\python setup.py build." Another option is to always include the Python path in Python commands, and the commands would work whether or not Python is in the Windows path.

> Installing apt-offline

In practice, I install apt-offline and start the get-process by simply clicking on a batch file which contains cd-, setup- and get-commands. The details of this batch file are covered in > Performing the set-process, above.

> Actually performing the get-process

Assuming that all of the sig-files, package-folders, get-commands, and the batch file have been prepared as described in the section on performing the set-process, you should be ready to go down to the library and perform the get-process. But before going, read the detailed instructions below in case I've forgotten something (which has been known to happen).

===============

Note

Some of the commands in the batch file will include a reference to the flash drive in the form of a letter which will presumably be assigned to the flash drive when it's plugged into the Windows PC. If a different letter is assigned when the flash drive is plugged in, the corresponding letters in the batch file must be changed accordingly, or the corresponding commands in the batch file won't work. To edit a batch file in Windows, right-click on it and select Edit in the menu which appears.

===============

If you're properly prepared when you go to the library, all you'd have to do is go through a simple process: a) plug in your flash drive; b) install the Python interpreter with a few clicks as described previously; c) correct references to the flash-drive-letter in the batch file (for example, if you assumed that the drive-letter would be E when you created the commands, and it turns out to be D when the flash drive is plugged in, you'd have to change the E's in the batch file to D's); and d) run the batch file. If it works, indications that the download-process is occurring will appear in a terminal-window, and when it's done, files should have appeared in the relevant package-folders.

> Proposed get-mode .exe version

Although these instructions should make it easier to use the Python version of apt-offline, and it should become easier after using it a couple of times, a get-mode-only .exe version would make it very easy to perform the get-process in the potentially stressful, distracting library-PC setting, and it might consequently boost the popularity of apt-offline and Debian Linux. Another reason for having an .exe version is that it isn't always possible to install Python on library PCs. A copy of the get-mode .exe version would be placed on a flash drive in a folder along with the signature file. The flash drive would be plugged into a Windows PC with a fast internet connection, and the get-process would be started by clicking on the .exe file's icon. The results would end up in the same folder, perhaps along with an error-log. I understand that there are programs to convert Python programs into .exe programs, but it's still a job for a programmer who knows apt-offline inside and out.

> Android devices can perform the get-process

If you have an Android device, you could probably use it for the get-phase. There are Python interpreters for Android (the default version is 2.x, and there's a 3.x version, which apt-offline can't use). The terminal, according to what I've read, is very similar to a Linux terminal (Android is a scaled-down variety of Linux written for ARM CPUs). I assume that Android can run shell-scripts, but if not, you could just copy prefabbed commands from a text file and paste them into the terminal.

> Install-phase

The install-process starts by transferring the flash drive which contains the results of the get-process to the PC on which the Debian installation of interest is running. Then the apt-offline GUI is opened with superuser/root privileges ("sudo apt-offline-gui") on that installation, the Install mode is selected, the GUI is pointed at the downloaded files (as in the set-process, you could save the path to the folder inout to a convenient location and paste it into the Install Packages window, but in this case, you'd have to add a slash and the name of the relevant package-folder to the path, since the files to be installed would be in the package-folder in inout, not directly in inout), and then the Install process is started. This causes the files in the selected directory to be copied to the folders where they must be placed in order to actually install them. In the section entitled Rebuilding the Search Index, I provide instructions on how to use the package manager to actually install package index files after performing the apt-offline Install operation.

Actually installing app-packages (after performing the apt-offline Install operation) can be accomplished in a variety of ways, but I prefer to use Synaptic to install them as if I were installing them over a high-speed internet connection. If I'm limited to the Software Center, I would go to Computer/var/cache/apt/archives (which is where apt-offline puts app-packages) and double-click on the top-level file in the package to be installed.

VI. Detailed procedures for using apt-offline

> Create a scratchpad

I recommend creating a text file named something like Miscellaneous in the aforementioned apt-offline folder on your flash drive, and using it for saving any information which might come in handy for performing apt-offline-related tasks, such as information required for downloading Python and apt-offline, or the path to folder inout, which you might want to enter into apt-offline's GUI during the set- and install-phase. Presumably, this file will be created with Gedit or some variant, so if you want the text to have line-breaks when the file is opened with Notepad in Windows, save it with a Windows line-ending when saving it for the first time. (For this option, see the bottom of the window which appears after clicking Save.) Or, you could open it with WordPad in Windows.

When you get to the library, you should know exactly what you'll have to do (assuming that the PC is working correctly), and have everything which will be required stored on your flash drive, including the sig-files, a package-folder corresponding to each sig-file, and a batch file which contains a) a "cd" command to change the default directory to the extracted apt-offline folder; b) all of the commands required to install apt-offline; and c) a get-command for every sig-file.

> Download required software

The best approach to install apt-offline on the Debian installation of interest or on Windows is to use the .zip-file version, which is available from the official apt-offline site (go to "files" page at http://apt-offline.alioth.debian.org/). It's small enough to be downloaded over a slow connection, and before you can download it, you have to register with the site and log in, which can involve quite a few steps. So, if you have any internet connection at all, you should do this at home.

If you have no internet connection and have to register with the site and download the apt-offline .zip file at the library, copy the above URL for the download-site into the Misc file mentioned above, along with any information required to register with the site. Registration requires a nickname, a password, and an email account which you can access with a library-PC. (Note that your log-in name is the nickname which you provide, with "-guest" added to the end.) So, to download the apt-offline .zip file at the library, you'll need an web-based email account, and if you have to create one, you'll need a user-ID and password and perhaps an address to an existing email account.

When you finally get the apt-offline .zip file, extract it and put the extracted file in the apt-offline folder on your flash drive, and make a backup copy of the .zip file on another drive when you get a chance. (Any references in this article to an extracted apt-offline file are references to the folder extracted from the apt-offline .zip file.)

Before performing the get-process on a Windows PC, you'll also need a Python .msi file from the Python-for-Windows download-page (https:// www.python.org/downloads/windows/). Its about an 18MB download, so copy the download-page URL to the Misc file and get the .msi file at the first opportunity to download it over a high-speed connection. I recommend the 32-bit (i386) version of 2.7.9 (which is evidently the last revision of 2.x), because apt-offline doesn't work with Python 3.x, and the 32-bit version should run on all PCs. You can try the 64-bit version, but even when it runs on a particular PC, it probably won't provide any noticeable performance advantage. Keep a copy of the .msi file on your apt-offline flash drive to have it handy whenever you want to perform a get-operation.

> Installing apt-offline on Debian installations

After getting the latest .zip-file version of apt-offline, extracting it, and putting it in the apt-offline folder on your flash drive, you would boot up the Debian PC, plug the flash drive into it, and change the default directory to the extracted apt-offline folder so that the OS can find the files required for performing the installation-process. To change the default directory to the extracted folder, right-click on any file inside the folder, click on Properties in the menu which appears, and highlight and copy the path contained in the window which then appears. (The path might not be displayed in its entirety, so you'd have to complete it manually, but this should be obvious - it's the beginning which can be difficult to get.) Then open a terminal-window (Ctrl-Alt-t in Ubuntu) and enter "cd" (without the quotes) followed by a space and the path which you just copied, which can be pasted into into the command with Ctrl-Shift-v. (If the path contains spaces, it has to be enclosed in quotes to use it in a command in Linux.) Then press Enter, and the prompt on the command  line should indicate that the extracted folder is the default directory.

The next step is to perform the actual installation. To do this, enter "python setup.py build" (w/o quotes), and then enter "sudo python setup.py install" (w/o quotes). That should install both apt-offline and apt-offline-gui. If you neglect to include "sudo" in the last command, installation will fail due to lack of permission.

> Performing the set-process

Before generating a signature file for something which isn't listed in the local package index, you have to generate a signature file for a package-index update, get the new package index, install it, and allow the package manager to rebuild the search index, as described in the above section on rebuilding the search index. As mentioned previously, you might want to get a copy of your favorite sections of the package index each time you have high-speed internet access (assuming you don't have the opportunity very often) to reduce the chances of having to get a new copy of the package index before generating a sig-file for a recent version of a desired app.

If you want to upgrade a particular app without performing a general upgrade (which requires an enormous amount of data), use Ubuntu Software Center or Synaptic Package Manager to remove the app, so that you can then generate a sig-file for the new version of the app. If you need the app in the meantime, you could re-install it and remove it just before installing the new version.

Before generating a signature file which includes a package-index update, you must edit the sources-list (explained previously) so that the correct sections of the package index will be listed in the signature file. For example, if you're using Ubuntu and you want your local package index to include the Universe section of the package index, you'd have to add the Universe section to the sources-list before generating a sig-file for an update. (I'd always include the Universe section, since it includes a lot of potentially useful software, and it doesn't take much extra time to download it over a fast connection.)

The set-process begins by opening a terminal-window and entering "sudo apt-offline-gui." When the apt-offline GUI appears, you would click on Generate Signature, and in the Generate Signature window which then appears, you would enter the desired changes.

> Entering data into the Generate Signature window

When entering app-names into the Generate Signature window, special names (all lower-case, no spaces, sometimes hyphenated) are used. For example, Synaptic Package Manager is designated as synaptic, and the English GIMP help-option is designated as gimp-help-en. If you enter a term which doesn't qualify as an app-name, you'll get an error message. These names are listed in the package index and can be found by using package-manager GUIs such as the Software Center or Synaptic Package Manager to perform a search for the item of interest. (Synaptic is better than the Software Center for this purpose, because for example if both are used to search for GIMP, the Software Center displays only GIMP, whereas Synaptic lists GIMP and its many accessories.) Before the package manager can access this information, the section of the package index pertaining to the item of interest must be installed.

The desired name and location for the signature file are entered Into the Save Signature As box, or into a sub-window which is opened by pressing the Browse button to the right of the box. My recommended system for naming sig-files and package-folders, and my recommended locations for them, are described in detail in the section on performing the set process in section V. This section also covers my system for creating and storing get-commands and batch files. Other commands placed in the batch file are mentioned there and below.

If there's an old signature file with the same name and location, apt-offline will ask whether to overwrite it with the new one, and unless you need the old sig-file and don't already have a copy, you'd tell apt-offline to overwrite it. 

> Creating the signature-file

After all of the data is entered into the Generate Signature window, the Create button would be pressed, and this would cause the signature file to be created. It's usually very quick, but if there are any problems, there would be some indication in the Console Output display-area. Go to the folder inout and open the file to verify that it was successfully created. It might be a good idea to make it read-only to prevent inadvertent changes.

> Using apt-offline in get-mode on a Windows PC

> Required items

You'll need the following items to perform the get-process on the typical library-PC, all of which would be stored in the apt-offline folder on your "apt-offline" flash. (However, since the Python file isn't specific to apt-offline, I would put it elsewhere.)

1) Python interpreter-installer (.msi file - details above in "Download required software" section)

2) apt-offline .zip file, extracted (details above in "Download required software" section)

3) The signature-file(s) created during the set-phase, stored in a folder for get-process inputs and outputs (which I named "inout")

4) The package-folder(s) (A package-folder is simply a folder reserved for a package to be downloaded, named after the package, and placed in folder inout.)

5) The following commands (created during the set-phase, in a batch file, and in the listed order - keep in mind that they are for a Windows PC and that b and c aren't required if apt-offline is already installed):

  a) cd /D E:\apt-offline\apt-offline 

  b) python setup.py build 

  c) python setup.py install 

  d) any required get-commands (see section V, >Performing the set-process)

> Detailed get-process

1) Plug your flash drive with all the apt-offline-related files (listed above) into the Windows PC. If Python 2.7.9 isn't installed, I recommend installing it even if a previous revision is installed (assuming you're allowed to install it on the particular PC), partly because the existing installation might have a problem, and installing it again is easy and will repair any problems with the previous installation. Installation is a matter of clicking on the file's icon to open it, and then clicking a few buttons in the resulting window.

================

Note: Windows must be told where to find Python, one way or another

When installing Python, you have the option of adding Python to the "Windows path" so that you don't have to include the Python path in commands which invoke Python. However, there are library PCs which don't allow Python to be added to the Windows path. In those cases, you would install Python without adding it to the Windows path, and begin all apt-offline-related commands which include "python" with "C:\Python27\python" assuming that the Python directory is C:\Python27, which is the case when Python 2.7.x is installed and the default location is used. (For example, "python setup.py build" would become "C:\Python27\python setup.py build.") Or, you could just always include the path, and the commands would work whether or not Python is on the Windows path.

=====================

2) Compare the letter assigned to the flash drive to the corresponding letters in the batch file, and edit the batch file if necessary so that they all match. To edit the batch file, right-click on it and select Edit in the menu which appears.

3) Click on the batch file to install apt-offline and initiate the get-process.

If all goes well, download-progress indicators would appear in the terminal window. If you asked for a general upgrade when you created the signature file, be prepared to wait while it downloads potentially hundreds of megabytes of data.

> In case you need the Windows terminal and it isn't on the menu

In case you need to use the Windows terminal (known as Command Prompt, abbreviated cmd), and the terminal isn't included in the program-menu, use the program-search box in the Start menu to search for cmd. If that doesn't work, you might be able to find a copy in the C:\Windows\System32 folder. Then there's always the Windows Explorer search function. Look for icons which resemble the standard terminal-window (black with a white border and "C:\>_" inside). You could just click on one of the icons to open a terminal, or right-click on it for a list of options which you might prefer (such as pinning it to the taskbar or the menu).

> Detailed install-process

The install-process is almost too simple to bother describing. Naturally, it's assumed that apt-offline is installed, since it was installed when it generated the signature file. So, the steps are as follows:

A) open terminal-window, enter "sudo apt-offline-gui" (w/o quotes) and use the GUI to do the following:

B) click on Install Packages or Updates

C) check-off Is Directory

D) click on Browse

E) Navigate to folder containing downloaded files

F) Click on Choose

G) Click on Install

H) Wait for installation to complete, then close the gui-windows in proper order, then the terminal.

This causes the files in the selected directory to be copied to the appropriate directory in the Debian installation, but it doesn't actually install them. In the section on rebuilding the search index, I provide instructions on how to use the package manager to actually install package index files after the Install process. To install app-packages at this point, I use Synaptic Package Manager as if I were installing the apps over a high-speed internet connection. If Ubuntu Software Center were the only choice, I would go to Computer/var/cache/apt/archives (which is where apt-offline puts app-files) and double-click on the app's top-level file. If all the required files are present in the "archives" folder, the Software Center would install the package.

VII. Conclusion

I'm not sure I'll ever get over my amazement at how well apt-offline works. Even if I created it, I think I'd still be amazed. It's a masterpiece of ingenuity and a software-gem. The only thing I would do would be to add the aforementioned get-mode-only .exe version, which would probably make apt-offline more popular, and make Debian Linux more popular to boot.

=====================

Notes

[1] Command to generate download-script for Synaptic Package Manager: "sudo apt-get install synaptic --print-uris | grep ^\' | cut -d\' -f2 > SynapticDnldSc.txt" (w/o quotes). (You can copy commands as usual and paste them into a terminal-window with Ctrl-Shift-v.) The result is a text file named SynapticDnldSc.txt and located in the Home folder. The file contains a list of URLs of the required program-modules. If you select a different server (in Ubuntu Software Center, select Edit/Software Source, etc.) and run the command again, you will get a different list (same files - different URLs). The "Universe" section of the package index must be installed before executing the command.

Ritesh Raj Sarraf's picture

Author: http://toggwu

A brief introduction to apt-offline
 
Rev B (see Notes)
(For details on the following, see this blog's previous entry.)

apt-offline is a Python program which allows a flash drive to be used as a substitute for a direct high-speed internet connection between a Debian installation and a corresponding online software repository. The process of obtaining a Debian app isn't simply a matter of downloading a file, like downloading a Windows app, because Debian apps consist of groups of modules/files (sometimes over a hundred, in addition to those which are part of the OS), and some of the modules can be shared by multiple apps. When you tell the installation software to install an app, it refers to a list of the modules required by the app, and to a list of the modules already installed, to determine which modules have to be downloaded and installed.

The process of using apt-offline to make a change to a Debian installation typically begins by launching apt-offline's GUI on the Debian installation which is being modified, and entering the desired changes into the GUI. Then the GUI's Create button is pressed, causing the GUI to translate the inputs into commands for the Debian installation's software manager, which in turn translates the desired changes into a "signature file" (a type of download-script) which lists the modules/files required to implement the desired changes. 

The signature file is copied to the flash drive so that it can be read by an installation of apt-offline which is running in its download-manager-mode on a PC with a fast internet connection. A get-command is what launches apt-offline into its download-manager mode, and points it to the sig-file and to a destination-folder for the downloaded files (both of which I always put in the same folder on the flash drive to simplify the process of creating get-commands). I put get-commands in a batch file along with any commands required to set up apt-offline on PCs (such as library-PCs) where it must be set up before each download-session. I keep a copy of apt-offline on the flash drive along with any typically-required Python "interpreter-installer" files. First, Python is installed by launching the interpreter-installer file, and then the batch file is launched, which issues the apt-offline setup-commands and the get-commands. A terminal-window appears on screen and indicates the status of the process. 

The flash drive is then transferred back to the Debian installation, where apt-offline is used in its "install" mode to copy each type of file in the destination-folder to the directory in the installation where it must be placed for actual installation. This copy-operation would required considerable knowledge and effort without apt-offline. Actual installation is a matter of opening a package-manager GUI and performing a few simple steps.

But before generating the signature-file for the app, it might be necessary to download and install a fresh copy of the repository's large software-reference list known as the "package index" (which lists all of the modules which can possibly be required by each app in the repository) because the online index is updated nightly, and the previously-downloaded and installed copy might no longer accurately reflect the repository's current revision of the desired app. [1] In some varieties of Debian, the package index is divided into sections, and you would download only the sections which you would likely require. (The index is downloaded in a compressed form, and the download is on the order of tens of MB, depending on which sections are downloaded.) The sections were apparently designed partly for security and partly to divide the available software into common-sense categories - dividing them into smaller sections would make them less secure and create confusion. 

Downloading the package index with apt-offline also requires a signature-file because it is necessary to tell the download-manager which server/mirror to use and which sections of the repository to include in the download. These selections are made before generating a package-index signature file by making changes to the installation's "sources list," such as by opening a package-manager GUI and selecting Edit, then Software Sources, and making the desired selections in the window which appears. 

So, when using apt-offline to install an app, it might be necessary to make two trips to the high-speed-access-point: one trip for the package index, which is then installed so that the app-script can be generated, and another trip for the app itself. It would be nice if apt-offline included the package manager so that everything could be done in one trip, but it's a large, complex program, and apt-offline's developer evidently decided that it would be impractical to include it. But the slight inconvenience of having to make an extra trip is a small price to pay for the benefits which apt-offline provides, and there are ways to reduce the chances of having to make the extra trip for the package index, as described in the previous entry to this blog. 

Notes

[1] The package index must be downloaded and installed in order to access individual listings. I gather that this was originally intended for security, but it also makes it possible to modify web-access-impaired installations. Various systems were devised for this purpose, culminating in apt-offline.  

Revisions

Rev A: Added Note 1 and removed the following sentence:

(As mentioned previously, the installation's software-manager or "package manager," which is what creates sig-files, requires a "local"/installed copy. It doesn't use the online index directly, apparently for security.) [It wasn't mentioned previously in the published version, but in an earlier version, and the rest needed clarification, because individual listings in the online package index can't be accessed except by the system which generates it, and after it is downloaded and installed.]

Rev B:  Revised last sentence, which previously read "But the slight inconvenience is a small price to pay for the benefits which apt-offline provides."

Like everything Linux, this is far too complicated

Like everything Linux, this is far too complicated. WSUSOffline, which runs on Windoze or Linux, can be downloaded, and run with one simple command. Updates can be installed with another. Why isn't there such a program for Linux, rather than this hundred-step obstacle course?

Ritesh Raj Sarraf's picture

When comparing to Windows,

When comparing to Windows, yes, Linux may be complicated. Becaues WIndows/MAC taught us things in a  certain way, and we expect to see the same everywhere else.

I understand the multi-step confusion many users have had at times. But, apt-offline tries to bridge the gap of network, in a process that presumes network availability.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.