Software Repositories and Package Management


General matters go here...

Notes regarding this chapter

Before you do anything in this chapter, see:

What is a repository and why are they great?

Simply put, a repository (aka archive) is a software (aka package) depot directly usable by the system. This software depot may reside on a CD or DVD, local hard drive, a PC next room, or the Internet.

Don't confuse other -general- uses of these terms with their special meanings in Debian (Kubuntu) software management realm. To make an analogy, you would call firefox-1.0-setup.exe and openoffice-2.0-beta.zip as "packages", and www.download.com and www.tucows.com as "archives" (repositories) in the Windows software management realm.

A repository is basically a vast collection (a sea, a lake, or sometimes just a puddle) of programs that are tested and guaranteed to satisfy interdependencies and work smoothly with a given system. You could regard it as an amazingly sophisticated "www.download.com", except that all the programs are tuned for your system, and that they are known by the "package manager" (analogous to the "Add/Remove Programs" in Windows). That is, you are no more required to dig around Internet to search for a given program. You don't even need to fire up your web browser to search and install software. They're right there in front of you, listed in the package manager: You can search for programs just like you would do inside "download.com", read their short descriptions, and if you happen to want to install one or more of them all you need to do is just ticking on them and then confirming your selections. They, along with all their requirements, will be fetched from Internet and installed by the package manager, all transparently to you. More than 15000 programs at your fingertips by just "subscribing" to a few repos!

With some operating systems like Windows and MacOSX, you search around Internet to find a program, download it, then click on it and answer several questions to install it. In contrast, with most Linux distributions including Kubuntu, you don't search the Internet for software, but you subscribe to repositories. You subscribe to software repositories for once, and all the software they have to offer are directly known by the Kubuntu package manager as if they were part of a greater Kubuntu. By the way, official repositories are part of the greater Kubuntu, which is an iceberg, and the installation CD is just the tip of it. The rest of the iceberg is the official repositories on Internet. This is the main conceptual difference from a user's point of view. Instead of knowing which web sites to go for software, you need to know which repositories to subscribe to (certain official repositories are already subscribed to by default).

Meanwhile, in addition to the repositories, the old way of independent software downloading and installing option is also there with Kubuntu, but using repositories is so easy, convenient and satisfactory an experience, that once you get to the comfort of it you will hardly look back.

There are various repositories, some of them are "official" and maintained particularly for your version of Kubuntu by its publisher, and others are "unofficial", maintained by other people. Some of these unofficial repos contain programs not found in the official ones (e.g. due to unacceptable license terms or legal uncertainities). Some others contain latest versions of several programs in the official repos. The software found in these unofficial repositories may not always be tuned particularly for your Kubuntu system, and installing programs from them may sometimes lead to compatibility and stability issues, particularly so with the "latest version" unofficial repositories. For this reason, "latest version" unofficial repositories are ignored in this document. For a casual user, they could probably be more trouble than their worth. Anyway, Kubuntu is already releasing the latest program versions in 6 months periods.

As a side note, there are several package manager ("Add/Remove Software" in Windows) programs with differing user-interface features, yet all doing the same thing behind the scenes. Just like various KaZaA clients or various web browsers doing the same thing with different look and feel. Kubuntu comes with "kynaptic" package manager by default. It's a simple one, and thus more appealing for a new user. For others, I would recommend installing its big brother, the "synaptic" package manager.



How to add extra repositories?

This is the minimum "/etc/apt/sources.list" file you need, in order to install the programs mentioned in this FAQ, unless otherwise noted. There are also various other repositories which are not addressed in this document.
  1. Important : If you skip this step, you will probably have a wild, unstable system at the first "repository upgrade". So, as the first thing to do, download this "preferences" file and then,
    sudo cp -f preferences /etc/apt/
  2. Download this sources.list file into your working directory (which is initially tuned for amd64).
  3. Edit the downloaded sources.list (right click on it -> Open With -> Kate) and do the modifications below, according to the instructions in the file:
    • If you're using an amd64 machine then skip this step. Otherwise,
      • Replace the "deb cdrom:" line at the top of the file with the one in your original /etc/apt/sources.list file,
      • Comment-out (disable) the "deb" lines (insert '#' as the first character) in "For amd64 Only" block,
      • Uncomment (enable) the "deb" lines (remove '#' character at the start) in "For i386 Only" block.
    • Replace the "tr" occurences in official repository URLs with the country code in your original /etc/apt/sources.list file.
    • Uncomment (enable) one of the "deb" lines (the one geographically closest to you) in "Blackdown Java Mirrors" block.
      • Note that all the Java mirrors are initially commented out in the downloaded file. So, you won't have Java available unless you uncomment one of the Blackdown repositories.
      • Also note that you can get the current Java mirrors from http://www.blackdown.org/java-linux/java-linux-d2.html However, you shouldn't use one of the broken mirrors (listed in the downloaded file) without first verifying that it actually works.
    • Uncomment (enable) one of the "deb" lines (the one geographically closest to you) in "Ubuntu Backports Project Mirrors" block.
      • Note that all the UBP mirrors are initially commented out in the downloaded file. So, you won't have UBP packages available unless you uncomment one of the UBP repositories.
      • Also note that you can get the current UBP mirrors from http://backports.ubuntuforums.org/url.php
    Exit from Kate (or KWrite), saving the sources.list file in your working directory, then put it into effect as below:
  4. sudo mv /etc/apt/sources.list /etc/apt/sources.list.`date +%y%m%d-%H%M%S`
    sudo cp sources.list /etc/apt/
    gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 1F41B907
    gpg --armor --export 1F41B907 | sudo apt-key add -
    gpg --keyserver wwwkeys.pgp.net --recv-keys 0x529B8BDA
    gpg --armor --export 0x529B8BDA | sudo apt-key add -
    sudo apt-get update
  5. Also see:


How to apt-get the versatile way (Synaptic)?



How to apt-get the easy way (Kynaptic)?

Kynaptic is the default package manager of Kubuntu 5.04. It can be regarded as the "Add/Remove Programs" of Windows. Kynaptic is simple and easy to use, but it misses some powerful functions of its big brother, Synaptic. Hence, Kynaptic is more suited for new users, while experienced users might find Synaptic more appropriate.
Find... (Ctrl+F) :
Search for a string or regular expression in package name, short (one-liner) summary, and/or description (one or several paragraphs). For simple string search in package names, search results can be shown dynamically, as you type.
Packages Frame :
Found packages (or all packages if no search has been performed) are listed, each with a descriptive icon appropriate for their status, like below
: (Package "acct" not installed yet, but available in repositories)
: (Package "gzip" is installed, but a newer version is available)
: (Package "acpi" is installed and at the latest version available)
Package actions :
Actions on packages are taken by clicking on their icons. A sub-menu pops up, with various actions enabled depending on the package's status: This is for an installed but stale package (e.g. "gzip" above):

Unmark resets a previous selection for some particular operation, before it's committed.

Install selects the package for installation.

Reinstall installs the same version of package from the repository, over to the already installed one (could be necessary to fix a package whose files has been damaged in the current system).

Upgrade installs the latest version of the package over to the already installed -older- one.

Remove uninstalls an already installed package.

Also see:

How to find and install software from repositories?



How to install/uninstall a ".deb" file?

Assuming that you want to install, and then uninstall a separately downloaded (or home-brewed) package nvu_0.90-1ubuntu2_amd64.deb

How to convert an .rpm file into a ".deb" file?

'alien' should not be used to replace important system packages, like init, libc, or other things that are essential for the functioning of your system. If you can’t remove a package without breaking your system, don’t try to replace it with an alien version.
alien package_file.rpm


How to create a local repository from discrete packages?

Instead of installing discrete packages with "dpkg -i package_name.deb", these packages can be made into a repository and then installed/queried with kynaptic (or "apt-get install package_name"). It is assumed that the repository will reside in a "/myrepo" directory, which may be a local, USB, or NFS-mounted (remote) hard disk. You will need write access to /myrepo while creating the repository (become root user via "sudo -i" if necessary), and read access while using it.
  1. Put all your .deb packages into '/myrepo' directory
  2. cd /myrepo
    dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
  3. In order to use this newly created (or updated) repository,
    1. Edit '/etc/apt/sources.list', as root, and place the following line towards to top of the file, preferably just after the "deb cdrom:" line:
      deb file:/myrepo /
      The reason for placing it before other "deb" lines is, that when kynaptic (or apt-get) finds duplicate versions of a given package in more than one repository, it prefers the first one to fetch the package from. By placing your repository before the others, you effectively prevent unnecessary downloading of packages from internet which are already available in your local repository.
  4. Repeat the previous steps whenever you add/replace/remove a .deb package in /myrepo directory.


How to create a network repository from discrete packages?

  1. Install and run a http and/or ftp service (any will do, but "apache2-mpm-worker" is already shipped with the installation CD). E.g.:
    sudo apt-get install apache2-mpm-worker
  2. Create a local repository from discrete packages on the http/ftp server.
  3. Serve '/myrepo' directory, on the server, over http and/or anonymous ftp. E.g.:
    sudo ln -s /myrepo /var/www/
  4. Assuming that the corresponding URL for the repository directory being served is 'http://myreposerver/myrepo' or 'ftp://myreposerver/pub/myrepo', do as below on each remote machine:
    1. Edit '/etc/apt/sources.list', as root, and place one of the following lines at the top of the file (so that packages in your LAN-repository will have higher fetch-priority than the same version packages on Internet-repositories), depending on the protocol you're using:
      deb http://myreposerver/myrepo /
      	## OR ##
      deb ftp://myreposerver/pub/myrepo /
      
    2. Repeat the previous steps whenever a repository update occurs on "myreposerver".
    Note: Instead of 'myreposerver' you can use its IP address as well, such as
    deb http://192.168.1.2/myrepo /


How to create a CD/DVD repository from discrete packages?

  1. Create a local repository from discrete packages.
  2. Optionally, embed a descriptive title in the repo (or you'll be asked to supply one interactively) :
    mkdir /myrepo/.disk
    echo 'My Extra Packages for Kubuntu 5.04' > /myrepo/.disk/info
  3. Burn this repository directory ('/myrepo' in our example) recursively with all of its contents onto a CD or DVD.
  4. Use this CD-repository on any Kubuntu machine by inserting the CD/DVD into its tray and,
    sudo apt-cdrom add
  5. See man:/apt-cdrom (with Konqueror) for more info.


How to re-install Kubuntu offline (without re-downloading packages)?

  1. Install Kubuntu on a pilot machine and download/install all the extra packages you're interested in;
  2. Create a "network repository" or "CD/DVD repository" from the extra packages you've downloaded;
    • All the packages implicitly downloaded by apt-get (or kynaptic) are cached in '/var/cache/apt/archives' directory. Get them into your personal repository, along with other .deb packages you've downloaded manually.
    • Kubuntu installation also caches (as an "unwanted convenience") all the packages on the installation CD into /var/cache/apt/archives too. Take care not to include the packages already on installation CD into your personal repository.
    • They can safely be removed from the package cache (via "sudo apt-get clean"), but once the "installation-CD" packages get mixed with the "extra" ones, it's not so straightforward to sort them out. So, you may want to;
      1. Install the pilot machine while it's off-line,
      2. then clean the package cache via "sudo apt-get clean",
      3. then get online and download/install extra packages,
      4. and finally copy/move extra packages (/var/cache/apt/archives/*.deb) to your own repository directory, before creating your own repository.
    • Some installation-CD packages can still creep into the package cache, after the initial cache cleaning, if you install a package from the installation CD later on.
  3. Install Kubuntu on other machines (or reinstall on the pilot machine) offline;
    • Choose against automatic downloading of additional i18n/l10n packages and latest base package updates, while installing (assuming they're already included in your local repository).
  4. Introduce your personal repository to the newly installed machine via one of the ways below, depending on your repository type:
    • For network (LAN) repository, edit '/etc/apt/sources.list', as root, and place a line similar to either of the following lines at the top of the file (to give your LAN-repo higher priority)...
      deb http://myreposerver/myrepo /
      	## OR ##
      deb ftp://myreposerver/pub/myrepo /
      ...and then do a repository update:

    • For CD/DVD repository, insert the CD/DVD in the offline machine's tray and issue:
      sudo apt-cdrom add
  5. Install extra packages on the newly installed machine, from your personal repository.


How to add/remove/relocate programs in K-Menu?

Some programs (see Notes in "Stock Kubuntu Applications") don't place or mis-place their icons in K-Menu, as well as most programs you install manually. For such programs, you might need to place or relocate their icons in K-Menu manually yourself.
  1. Right click on the (K Menu) button located at the bottom-left corner of your screen, then select "Menu Editor" from the pop-up list. It is the same as entering "kmenuedit" command from Konsole terminal.
  2. In kmenuedit, you will find the editable directory tree representation of the K-Menu. You can add, delete, modify, or relocate (by just drag & dropping) both menu entries and sub-menus (directories) as you wish. Empty directories in kmenuedit are not shown as empty sub-menus in K-Menu. Sub-menus appear when you place a menu entry in them.
  3. While adding an entry, note the following:
    • Name: The name by which this program will be seen on K-Menu.
    • Description and Comment: Shown as tool-tips etc.
    • Command: The action to be taken when K-Menu entry is clicked. The command you would enter from a Konsole terminal session to start the program (usually just its name in small letters).
    • [x] Enable launch feedback: The jumping busy indicator. You'd want this enabled.
    • [ ] Place in system tray: Self explanatory. Depends on the application.
    • [ ] Run in terminal: Opens a Konsole terminal first, then runs the application from within it. Leave empty the application has GUI. Check it if it's a text based program that needs to be run in a terminal.
    • [ ] Run as a different user: Normally leave it empty. Check it for administrative programs that need to be run by the "root" user (leave the "Username" field empty).


Which files come with a given package?

  • For all packages (installed, as well as available in repositories):
    sudo apt-get install apt-file
    sudo apt-file update
    apt-file list package-name
  • From the Internet: http://packages.ubuntu.com/


  • Which package brings in a given file?



    How to backup/restore downloaded repositories cache?



    How to manually update Kubuntu?

    1. Read Chapter Notes and How to add extra repositories
    2. From Kynaptic:

    3. From command line:
      sudo apt-get update
      sudo apt-get upgrade


    Other documentation on package management