Making a Local Ubuntu 9.10 Repository Server

Ubuntu repository servers are easy to find on the Internet . But not all people have the easy and good quality of Internet access to install the package from it . Beside that , it will cost much time and bandwidth if we have tons of Ubuntu GNU/Linux machines to get the latest package installed even if we have access to the internet . So that's why we have to use the local repository server in our network. How to make one ? it's easy , but you have to prepare these things first :
- Ubuntu 9.10 is already installed on the machine that you want to make it as a server
- Get the Ubuntu 9.10 Repository DVDs ( 7 DVDs ) ; You can buy it on the Internet , just Google it
- Connected to the Internet
Steps :
1. Copy the DVD files to your machine , for this example on "/media/sda1/repo/karmic"
$ sudo mkdir -p /media/sda1/repo/karmic
insert DVD 1st to the DVD drive , go to the dvd directory and then copy all the content to "/media/sda1/repo/karmic"
$ sudo cp -rfa * /media/sda1/repo/karmic/
after copy process is finished , do the same thing like before ( copy the files to the "/media/sda1/repo/karmic" ) at the 2nd to 7th DVD .
2. Change the owner of the whole folders and files inside "/media/sda1/repo/karmic" to "root"
$ sudo chown -Rf root.root /media/sda1/repo/karmic/$ sudo chown -Rf root.root /media/sha1/repo/karmic/*
3. Set the whole file access permission inside "/media/sda1/repo/karmic" to "644" and "755" for the folders.
$ sudo find /media/sda1/repo/karmic/ -type f -exec chmod 644 {} \;$ sudo find /media/sda1/repo/karmic/ -type d -exec chmod 755 {} \;
4. Delete all the index files "Packages.gz" from the DVD inside "/media/sda1/repo/karmic"
$ sudo find /media/sda1/repo/karmic/dists/karmic/ -name "Packaged.gz" -exec rm {} \;
5. Before we can make index files , make sure that "dpkg-dev" is installed , to make sure it's installed use this command :
$ sudo apt-get install dpkg-dev
6. Now we will make "Packages.gz" index files from each repository components : main , multiverse , restricted , and universe
we will start the with the "main" component .
Login as root and go to /media/sda1/repo/karmic
$ sudo su -$ cd /media/sda1/repo/karmic
make the "Packages.gz" index file for "main" to the "/media/sda1/repo/karmic/dists/karmic/main/binary-i386"
# dpkg-scanpackages pool/main /dev/null | gzip -9c > dists/karmic/main/binary-i386/Packages.gz
Note : Generating process of Packages.gz takes time , wait till finish
continue with the other components :
# dpkg-scanpackages pool/multiverse /dev/null | gzip -9c > dists/karmic/multiverse/binary-i386/Packages.gz# dpkg-scanpackages pool/restricted /dev/null | gzip -9c > dists/karmic/restricted/binary-i386/Packages.gz# dpkg-scanpackages pool/universe /dev/null | gzip -9c > dists/karmic/universe/binary-i386/Packages.gz
7. We're done with Index files making process . To make it is accessible by the client , we have to install the Apache server
$ sudo apt-get install apache2
8. To redirect the repository to the "/media/sda1/repo/karmic/" , enable the alias mod in apache
$ sudo a2enmod alias
9. edit the alias configuration file and add some codes in it
$ gksudo gedit /etc/apache2/mods-available/alias.conf<IfModule alias_module>......Alias /karmic "/media/sda1/repo/karmic"<Directory /media/sda1/repo/karmic>Options Indexes FollowSymLinks MultiViewsAllowOverride AllOrder allow,denyallow from allAddType text/plain gzAddEncoding x-gzip gz</Directory></IfModule>
10. Restart the apache service
$ sudo /etc/init.d/apache2 restart
How do the client can access it ?
1. For Example the server's IP is 192.168.1.1 . So the Ubuntu 9.10 client(s) on the same subnet can add a line in "/etc/apt/sources.list"
$ gksudo gedit /etc/apt/sources.listdeb http://192.168.1.1/karmic karmic main multiverse restricted universe
2. Save the changes on "/etc/apt/sources.list" and the update the packages indexes
$ sudo apt-get update
Happy Hacking !! :-)