Doing a debian mirror repository with hand and some bash

December 1, 2006 – 5:56 pm

This week i have needed to do one debian local repository for build - i satarted and i hope finally this month - a network of small computers run remote X sessions with XDMCP protocol to centralized server, and i was have a big problem, the place have not any connection to internet for retrive the debian packages.

I had the possibility to retrieve full debian DVDs, but i had think it's more likeable try to make a local debian repository in my laptop, and add my laptop to the netwok with configure all computers because retrieve all packets from my local repository.

Make a local repository, it's easy but little heavy for your network connection because the finally size is about 15 Gbytes ... only unstable release !
First your need create the basical structure, based in some directeor and some files.

root@hidrogen:/var/www# mkdir -p debian/dists/testing/contrib/binary-i386
root@hidrogen:/var/www# mkdir -p debian/dists/testing/non-free/binary-i386
root@hidrogen:/var/www# mkdir -p debian/dists/testing/main/binary-i386

Next retrive some metadata files for description you architecture, release, security and others parameters of repository

root@hidrogen:/var/www/debian/dists/testing# wget http://ftp.fr.debian.org/debian/dists/testing/Contents-i386.gz
root@hidrogen:/var/www/debian/dists/testing# wget http://ftp.fr.debian.org/debian/dists/testing/Release
root@hidrogen:/var/www/debian/dists/testing# wget http://ftp.fr.debian.org/debian/dists/testing/Release.gpg

Do the same for Packages.tar.gz and Release files for contrib, main, non-free directorys into binary-i386 sub direcotry.

And finaly launch a ease basch script for retrive all packages for contrib, main, non-free directorys

for file in `gunzip -c Packages.gz | grep Filename | cut -d" " -f2`;
do
if [ ! -e "ftp.fr.debian.org/debian/$file" ];
then wget -x http://ftp.fr.debian.org/debian/$file;
else
echo "$file exists";
fi;
done

Repeat this script for three kind of packages and put these output into pool directory

root@hidrogen:/var/www# mkdir -p debian/pool

root@hidrogen:/var/www/debian/pool# mv dists/testing/main/binary-i386/ftp.fr.debian.org/debian/pool/main .

root@hidrogen:/var/www/debian/pool#mv dists/testing/contrib/binary-i386/ftp.fr.debian.org/debian/pool/contrib .

root@hidrogen:/var/www/debian/pool#mv dists/testing/contrib/binary-i386/ftp.fr.debian.org/debian/pool/non-free .

And finally add this new directory into your apache default configuration ...

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word