• No results found

Setting up a local APT repository

If you have a plethora of machines running on a local server, which you probably have, since you are reading this guide, you will notice that it is a wasteful process of downloading packages from each machine from the internet, of course you have the alternative for syncing the /var/apt/ cache for each machine, but that is a tedious and cumbersome process, and would not work for upgrades, instead the recommended way is to set up a local repository via the apt-cacher. This way, you won't download common packages more than once from official repositories. Here is the situation, we have one machine called repository-cache, this machine is going to act as the repository cache, basically, any other machines in your network is going to use it as a repository.

On your terminal, type:

$ sudo apt-get install apt-cacher

Now, we need to configure it for our specifications, since it is primarily aimed at administrators, there is no graphical user interface and all the editing will be done by modifying the /etc/apt-cacher/apt-cacher. conf.

So now, open apt-cacher's main configuration file: /etc/apt-cacher/ apt-cacher.conf and start editing it according to your settings. The default port apt-cacher is running on is port 3142. You might want to change this value accordingly to your needs. You won't typicaly need to bother with this unless, you have a specific service already running on that port.

allowed_hosts: by default, all host are allowed to use the repository cache. If you want only a particular IP range to access, you can specify here. If you want to allow over your Wi-Fi say 10.0.0.0/24 and localhost, then put the following values

allowed_hosts= 10.0.0.0/24

notice how localhost is always allowed by default.

Let us forget about the generate_reports option, it is also self explainatory. Next comes the import setting of path_map

path_map: This is an interesting directive. Here you can define different aliases for different repository host. So for a typical ubuntu setup, you will have:

path_map = ubuntu archive.ubuntu.com/ubuntu; ubuntu- updates archive.ubuntu.com/ubuntu ; ubuntu-security security.ubuntu.com/ubuntu

The mappings above are explained below:

ubuntu and ubuntu-updates to host archive.ubuntu.com/ ubuntu

Linux Administration

Setting up a local APT repository

6

and ubuntu-security to security.ubuntu.com

Now, in order to access a specific repository, we simply need to append the mapping name to our cache repository server, like: repository_cache_ machine:port/mapping_name

So, for instance, we can access Ubuntu security repository through http://

repository-cache:3142/ubuntu-security.

The autostart value of 1, enables the apt-cacher. AUTOSTART=1

At this point we should restart the apt-cacher for our changes to take place.

$ sudo /etc/init.d/apt-cacher restart.

This was the server part of our setup, now login to each of the clients. Don't worry, you don't need to physically move, you can log in via SSH as explained earlier, or you can even write an automated script to do so. Let us update all our clients /etc/apt/sources.list files so every host on the network will use our repository-cache machine. It is a good idea to even update the sources.list on the server, as any software downloaded by the server will also be available for rest of the machines.

6.1 Editing the sources.list

Here is a sample original sources.list

# deb cdrom:[Ubuntu 10.04 LTS _Lucid Lynx_ - Release amd64 (20100429)]/ lucid main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to

# newer versions of the distribution.

deb http://lk.archive.ubuntu.com/ubuntu/ lucid main restricted

deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid main restricted

## Major bug fix updates produced after the final release of the

## distribution.

deb http://lk.archive.ubuntu.com/ubuntu/ lucid-updates main restricted

deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid- updates main restricted

Linux Administration

Setting up a local APT repository

6

UNSUPPORTED by the Ubuntu

## team. Also, please note that software in universe WILL NOT receive any

## review or updates from the Ubuntu security team. deb http://lk.archive.ubuntu.com/ubuntu/ lucid universe deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid universe

deb http://lk.archive.ubuntu.com/ubuntu/ lucid-updates universe

deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid- updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

## team, and may not be under a free licence. Please satisfy yourself as to

## your rights to use the software. Also, please note that software in

## multiverse WILL NOT receive any review or updates from the Ubuntu

## security team.

deb http://lk.archive.ubuntu.com/ubuntu/ lucid multiverse deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid multiverse

deb http://lk.archive.ubuntu.com/ubuntu/ lucid-updates multiverse

deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid- updates multiverse

## Uncomment the following two lines to add software from the 'backports'

## repository.

## N.B. software from this repository may not have been tested as

## extensively as that contained in the main release, although it includes

## newer versions of some applications which may provide useful features.

## Also, please note that software in backports WILL NOT receive any review

## or updates from the Ubuntu security team.

Linux Administration

Setting up a local APT repository

6

backports main restricted universe multiverse

# deb-src http://lk.archive.ubuntu.com/ubuntu/ lucid- backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's

## 'partner' repository.

## This software is not part of Ubuntu, but is offered by Canonical and the

## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu lucid partner # deb-src http://archive.canonical.com/ubuntu lucid partner

deb http://security.ubuntu.com/ubuntu lucid-security main restricted

deb-src http://security.ubuntu.com/ubuntu lucid-security main restricted

deb http://security.ubuntu.com/ubuntu lucid-security universe

deb-src http://security.ubuntu.com/ubuntu lucid-security universe

deb http://security.ubuntu.com/ubuntu lucid-security multiverse

deb-src http://security.ubuntu.com/ubuntu lucid-security multiverse

This will become the following, notice how third-party sources won't be touched. In case you are wondering what lk is, it stands for Sri Lanka.

# deb cdrom:[Ubuntu 10.04 LTS _Lucid Lynx_ - Release amd64 (20100429)]/ lucid main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to

# newer versions of the distribution.

deb Insert-Repository-Server-Ip lucid main restricted deb-src Insert-Repository-Server-Ip lucid main restricted ## Major bug fix updates produced after the final release of the

Linux Administration

Setting up a local APT repository

6

deb Insert-Repository-Server-Ip lucid-updates main restricted

deb-src Insert-Repository-Server-Ip lucid-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

## team. Also, please note that software in universe WILL NOT receive any

## review or updates from the Ubuntu security team. deb Insert-Repository-Server-Ip lucid universe deb-src Insert-Repository-Server-Ip lucid universe deb Insert-Repository-Server-Ip lucid-updates universe deb-src Insert-Repository-Server-Ip lucid-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

## team, and may not be under a free licence. Please satisfy yourself as to

## your rights to use the software. Also, please note that software in

## multiverse WILL NOT receive any review or updates from the Ubuntu

## security team.

deb Insert-Repository-Server-Ip lucid multiverse deb-src Insert-Repository-Server-Ip lucid multiverse deb Insert-Repository-Server-Ip lucid-updates multiverse deb-src Insert-Repository-Server-Ip lucid-updates multiverse

## Uncomment the following two lines to add software from the 'backports'

## repository.

## N.B. software from this repository may not have been tested as

## extensively as that contained in the main release, although it includes

## newer versions of some applications which may provide useful features.

## Also, please note that software in backports WILL NOT receive any review

Linux Administration

Setting up a local APT repository

6

## or updates from the Ubuntu security team.

# deb Insert-Repository-Server-Ip lucid-backports main restricted universe multiverse

# deb-src Insert-Repository-Server-Ip lucid-backports main restricted universe multiverse

Running the following command after updating the settings will ensure downloading from our local apt-cache.

Related documents