30 July, 2007

HowTo make Ubuntu mirror

"Ubuntu 6.06 LTS (Dapper Drake)" is my favorite OS (unfortunately, my previous favorite: "RedHat 7.2 (Enigma)" is out of date for modern hardware and software).

Ubuntu 6.06 LTS is the best solution for modern computers, because it is stable, efficient, user friendly and long term supported (Desktop Edition to 2009 and Server Edition to 2011).



But, it is necessary to have wide and persistent Internet connection for updates and installing new packages. It is a good idea to create local "hard" copy of all packages from Ubuntu's site. I wrote script for this purposes and successfully use it.

This script creates FULL (~50G) mirror of "Ubuntu 6.06 LTS (Dapper Drake)".
It downloads all binary and source packages for both i386 and amd64 platforms.



xqx_mirror_dapper.sh

#!/bin/bash -x

DATE=`date +%Y.%m.%d_%H.%M.%S.%N`
LOG=~/`basename $0`-$DATE.log
touch $LOG

if test ! -w "$LOG"; then
LOG=/dev/stdout
fi

DIST=dapper

/usr/bin/debmirror -m --passive --method=ftp --progress --host=archive.ubuntulinux.org --root=ubuntu \
--dist=$DIST,$DIST-updates,$DIST-security,$DIST-proposed,$DIST-backports \
--section=main,multiverse,universe,restricted --arch=i386,amd64 \
--ignore-release-gpg --timeout=999 $DIST |tee $LOG

/usr/bin/debmirror -m --passive --method=http --progress --host=archive.canonical.com --root=ubuntu \
--dist=$DIST-commercial --section=main --arch=i386,amd64 \
--ignore-release-gpg --timeout=999 $DIST-commercial |tee -a $LOG


If you don't need sources, you may fix this script and add "--nosource" option to the "dembirror" command. Or you may select your own platform with the "--arch=" option.

When mirror created, you should switch your system to it.
I also created script for this. Here it is:



xqx_apt_update_dapper.sh

#!/bin/bash

if test -z "$1"; then
echo "Update system from new mirror."
echo "Usage: $0 <folder with mirrors>"
exit
fi

DIST=dapper
MIRRORS=$1

cat >/etc/apt/sources.list <<EOF
deb file://$MIRRORS/$DIST/ $DIST main universe multiverse restricted
deb file://$MIRRORS/$DIST/ $DIST-updates main universe multiverse restricted
deb file://$MIRRORS/$DIST/ $DIST-security main universe multiverse restricted
deb file://$MIRRORS/$DIST/ $DIST-backports main universe multiverse restricted
deb file://$MIRRORS/$DIST/ $DIST-proposed main universe multiverse restricted
deb file://$MIRRORS/$DIST-commercial/ $DIST-commercial main
EOF

echo -e "\\033[1;32m"
cat /etc/apt/sources.list
echo -e "\\033[0;39m"

echo "Continue with 'apt-get update'? [y/n]"
read
if test $REPLY = y ; then
apt-get update
else
exit
fi

echo "Continue with 'apt-get upgrade'? [y/n]"
read
if test $REPLY = y ; then
apt-get upgrade
else
exit
fi

No comments: