There are several methods you can use to transfer files manually to a Debian-like operating system for installation by apt or a compatible package manager. I will cover the techniques I use from easiest to hardest.
Apt needs a file called sources.list to locate archives. Since I have a slow Internet connection and routinely do any necessary updates by Sneakernet, I typically set my sources.list file to a local archive that I've created and access everything from the local archive.
When it's time to update a system (change more than a few packages), it's easier to have a sources.list file that contains all the archives you're interested in working with. This can include your distribution's main archive, multimedia archives, security and backports archives, other distributions' archives or individual developer's archives. I therefore maintain two copies of sources.list. One has my local archive and the other looks more like a typical sources.list that you'd find on most Debian systems. I switch between the two as needed. By using a local archive, I feel like I have more control over what files are installed on my system and when they are updated. If the local archive doesn't have information about an updated version of a package, it won't even show it. Still, there are times when it's convenient to know all the packages in various archives that have been updated. That's when the second sources.list file becomes useful.
I'm not going to cover when to use sudo or whether you should su to root before certain steps. I leave that up to your own discretion. If you try to perform a command and don't have the rights, it's time to use a tool like sudo or su or have an adminstrator add you to the appropriate group that has the needed rights.
There are several ways to install a package.
To install one package with dpkg, use a command line similar to:
dpkg -i nameofpackage.deb
You would need to install all the dependencies for that package using the same technique before installing the package itself. The dependency packages would have to be installed in an order so that when they're installed no missing uninstalled dependencies for those packages exist.
With a local archive, one can use apt, dselect, aptitude, synaptic or other similar tools that know how to deal with dependencies. The package manager program can let you select which package to install and if all the dependency packages are available, it will install those as well automatically for you in an appropriate order.
Here's one way to create a local archive on a Debian-like system. Copy all the packages you're interested in installing (files with .deb extension) to /var/cache/apt/archives
. To create a local archive or repository, you will need to create the directory location where you want to store your package lists and you will need to add the information about it to your sources.list file typically found in /etc/apt/sources.list
. To create the directory for your package lists the very first time, use a command similar to:
mkdir -p /var/db/dists/stable/main/binary-i386
Your sources.list file should have a line similar to the following added to it:
deb file:/var/db/ stable main
My machine is using i386 files. If you're using files for another architecture, substitute the appropriate information. Once the local archive is set up, it's time to populate it. In console mode or from a terminal, use the following commands:
cd /var/cache/apt/archives dpkg-scanpackages . |gzip > Packages.gz cp Packages.gz /var/db/dists/stable/main/binary-i386
This takes you to the directory where you've placed the packages. It creates a zipped list of the packages. The list needs to be copied or moved to the location where you want to keep your local archive or repository information. In the case above, my repository information is located in the directory /var/db/dists/stable/main/binary-i386
. I've created a shell script that does the above three commands for me. You'll typically want to use them every time you add or remove packages in the /var/cache/apt/archives
directory. Once the Packages.gz file has been updated in your local repository, you can run Synaptic and click reload to see the changes. If you use another package manager, be sure to issue the appropriate commands to have it update for the changes. Once that's done, you should be able to add or work with the packages in the local archive just as you would with any other archive.
Once you've worked out the technique(s) you want to use to install packages, you'll need the packages to install. If you have a machine with no Internet connection or a slow connection, this is where sneakernet comes in.
For Debian users, you can go straight to packages.debian.org and download packages, find all related package dependencies, etc. The web site strongly recommends using a package manager, but as long as you pull all the dependencies and install them through the package manager (using a method like the local archive one), the technique works just fine. It's great if you want to try out a new program with only a few dependencies. Some developers have links to packages directly on their web sites. As long as you can get all the appropriate dependent packages, you can download the needed packages directly from a web site (especially if they're not a part of your official distribution).
If you find yourself wanting to download an application with several dependencies or several applications, there are other more automated methods. This is where I switch sources.list files. I move a sources.list file that holds all the archives I want to work with to /etc/apt/sources.list
. From within Synaptic, I mark which package or packages I'm interested in. From the File menu, I select Generate package download script. One can use the generated file on another machine to automate downloading of the packages one is interested in. Once done, I switch back to my previous sources.list file that just contains my local archive. I copy the new packages to /var/cache/apt/archives
. I update my local archive as detailed above. The new packages become available in Synaptic after I hit reload. I can then update, install and uninstall as I choose from there.
So, what do you do when you want to update all your packages or Debian switches stable from one designation to another (such as Squeeze to Wheezy)? There's an automated technique for that as well. There is actually more than one way to do this and the typical method I've read about requires using sneakernet twice. Round-trip sneakernet once to get the lists of what files are available in those repositories and round-trip sneakernet a second time to actually get those files. I wanted to cut out part of one trip.
Again, I switch the sources.list to the version that contains all the archives I want to use when updating. I can get the lists of what files are available in the repositories from sources.list with the following at a command line:
apt-get -qq --print-uris update
Redirect the output of the command to a file and take it to another machine. From there, use a tool like wget and the list of URLs in the file to download relevant package list information files. You may want to use various utilities like sed to make the output more user-friendly for tools like wget to interpret. Once the files are downloaded from the other machine, zip them up and move them back to your original machine. Modify the file names to avoid collisions and so that they can be properly located on your machine if necessary. Unzip and move them to /var/lib/apt/lists
.
As mentioned, I prefer to avoid the extra step of generating the list of files with apt-get. So, I don't deal with trying to get the output of apt-get into a form wget understands or renaming files. Instead, I take the sources.list file and sysdebapt.sh, a shell script I wrote and use them to automate the job for me. If you want to do this from Windows, you'll need the proper tools installed to be able to use the shell script. You could use msys, cygwin, gnuwin32 utilities plus a standalone bash shell or even use bash and utilities from djgpp. I'm working on putting together my own collection of tools I've compiled from source and patched to work portably so that they can be run directly from a flash drive. Place the sysdebapt.sh and the sources.list in a directory on a machine with a fast Internet connection. One could leave them on your own drive as long as they're accessible to the machine. The current sysdebapt.sh needs bash, wget, sed, tr, mv, mkdir, rm, bzip2. You can modify the sysdebapt.sh script to use other tools or send files to another directory location. The script creates a tmp directory underneath the directory it's located and places the files there. Change the FILE_LANGUAGE variable if you want something other than English. The shell script reads from the sources.list file (which it expects to be in the same directory it's located in). It fetches the files and renames them the way the package manager will expect them to be named. I then zip up the results and sneakernet to my machine to install. Again, unzip and move the files to /var/lib/apt/lists
.
Now I have updated lists of what packages are available on my system. In Synaptic, I reload the information or one can run apt-get update
. When I'm done, I close Synaptic. If I want to download all updated packages, I run the following at the command line and redirect the output to a file:
apt-get -qq --print-uris upgrade
One can also substitute dist-upgrade for upgrade. (Dist-upgrade attempts to intelligently upgrade a system and, unlike upgrade, may install new packages or remove packages no longer used as dependencies). I didn't have much luck with dist-upgrade. It couldn't come up with a useable upgrade path. So, I stuck with upgrade and that worked fine. Anything it didn't upgrade that I wanted newer versions of, I can take down using a Synaptic script or by directly downloading the package and dependencies. That way, I have more control over what packages are removed than I would if I used dist-upgrade.
Once you have the output from apt-get redirected to a file, clean up the resulting file using a tool like sed if needed. Sneakernet to a machine with a fast Internet connection and use wget or a similar tool along with this file to download newer versions of packages. I have a bash script, sysdebaptget.sh that takes the output file, cleans it up and outputs the commands to download the needed packages to stdout (standard output). If you use it, you'll need to redirect the output to a new file and use that new file to download the desired packages on a machine with fast Internet connection. The commands I use would typically look something like this:
apt-get -qq --print-uris update > debupgradeurls.txt sysdebaptget.sh debupgradeurls.txt > debupgradeurls.sh
If you're running any of these shell scripts on Linux systems, be sure file permissions are set properly for execution. I then sneakernet the package files back to my system. I switch back to the previous sources.list that has just my local archive. I copy the new packages to /var/cache/apt/archives
using cp -n
so I don't overwrite files with the exact same name. I use my script with the three commands to update my local archive by regenerating the Packages.gz file. Now, I can use Synaptic and reload or another package manager and continue with the steps mentioned above. Within Synaptic, one can choose which files to upgrade. One could also try a command such as apt-get upgrade
.
I personally do not like the Debian package management system. I find it very hard to work with from a package creation standpoint and a hindrance to development. However, it is typically very user friendly to someone who never has to deal with creating packages. It is one of the few Linux package management systems out there that seems to deal with all kinds of unusual cases such as the need to work with a machine not connected to the Internet. For my own development, I use my own package management tools and place my applications where they won't intermingle with system applications or affect the system's package manager. A subdirectory underneath the home directory is typically a good location. However, if I want to use what is already available with a Debian based distribution and someone's already done the packaging for me, the Debian package management tools can certainly get the job done. They provide an effective way to keep a system up-to-date even with no Internet access from that machine.