* new default layout for mirrors - see https://svn.planet-lab.org/wiki/VserverCentos
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 20 Mar 2008 15:26:04 +0000 (15:26 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 20 Mar 2008 15:26:04 +0000 (15:26 +0000)
* new defaults mirrors, specified for fedora and centos in US and EU
* new -U option for specifying centos URL

vbuild-fedora-mirror.sh

index 42934a8..1d6e1a4 100755 (executable)
@@ -7,63 +7,58 @@ COMMAND=$(basename $0)
 dry_run=
 verbose=
 skip_core=
-root=/data/fedora/linux
+root=/mirror/
 
-us_rsyncurl=rsync://mirrors.kernel.org/fedora
-eu_rsyncurl=rsync://ftp-stud.hs-esslingen.de/fedora/linux
+us_fedora_url=rsync://mirrors.kernel.org/fedora
 # change this
-jp_rsyncurl=rsync://ftp-stud.hs-esslingen.de/fedora/linux
+us_centos_url=rsync://mirrors.rit.edu/centos
+
+eu_fedora_url=rsync://ftp-stud.hs-esslingen.de/fedora/linux
+eu_centos_url=rsync://mirrors.ircam.fr/CentOS
+
+# change this
+jp_fedora_url="need-to-be-defined"
+# change this
+jp_centos_url="need-to-be-defined"
 
 default_distroname=f8
-all_distronames="f7 f8"
+all_distronames="f7 f8 centos5.1"
 default_arch=i386
 all_archs="i386 x86_64"
 
 case $(hostname) in 
     *.fr|*.de|*.uk)
-       rsyncurl=$eu_rsyncurl ;;
+       fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ;;
     *.jp)
-       rsyncurl=$jp_rsyncurl ;;
+       fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ;;
     *)
-       rsyncurl=$us_rsyncurl ;;
+       fedora_url=$us_fedora_url ; centos_url=$us_centos_url ;;
 esac
 
-function usage () {
-    echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u rsyncurl|-e] [-f distroname|-F] [-a arch|-A]"
-    echo "Defaults to -r $root -u $rsyncurl -f $default_distroname -a $default_arch"
-    echo "Options:"
-    echo " -n : dry run"
-    echo " -v : verbose"
-    echo " -c : skips core repository"
-    echo " -r root (default is $root)"
-    echo " -u rsyncurl (default is $rsyncurl)"
-    echo " -e : uses European mirror $eu_rsyncurl"
-    echo " -f distroname - use vserver convention, e.g. fc6 and f7"
-    echo " -F : for distroname in $all_distronames"
-    echo " -a arch - use yum convention"
-    echo " -A : for arch in $all_archs"
-    exit 1
-}
-
 function mirror_distro_arch () {
     distroname=$1; shift
     arch=$1; shift
 
+    distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
     case $distroname in
        fc*[1-6])
            distroindex=$(echo $distroname | sed -e "s,fc,,g")
            distro="Fedora Core"
+           rsyncurl=$fedora_url
            ;;
        f*[7-8])
            distroindex=$(echo $distroname | sed -e "s,f,,g")
            distro="Fedora"
+           rsyncurl=$fedora_url
            ;;
-       centos*[4-5])
+       centos[4-5]|centos[4-5].[0-9])
            distroindex=$(echo $distroname | sed -e "s,centos,,g")
            distro="CentOS"
+           rsyncurl=$centos_url
            ;;
        *)
-           echo "Unknown distribution $distroname - skipped"
+           echo "WARNING -- Unknown distribution $distroname -- skipped"
+           return 1
            ;;
     esac
 
@@ -100,27 +95,29 @@ function mirror_distro_arch () {
                    RES=0
                    ;;
            esac
+           localpath=fedora
            ;;
     
        CentOS*)
            case $distroindex in
-               5)
+               5*)
                    [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
                    paths="$paths $distroindex/updates/$arch/"
                    RES=0
                    ;;
            esac
+           localpath=centos
            ;;
 
     esac
 
     if [ "$RES" = 1 ] ; then
-       echo "$distro $distroindex currently unsupported - skipped"
+       echo "DISTRIBUTION $distro $distroindex CURRENTLY UNSUPPORTED - skipped"
     else
        for repopath in $paths; do
            echo "============================== $distro -> $distroindex $repopath"
            [ -z "$dry_run" ] && mkdir -p ${root}/${repopath}
-           command="rsync $options ${rsyncurl}/${repopath} ${root}/${repopath}"
+           command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
            echo $command
            $command
        done
@@ -129,17 +126,38 @@ function mirror_distro_arch () {
     return $RES 
 }
 
+function usage () {
+    echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
+    echo "Defaults to -r $root -u $rsyncurl -f $default_distroname -a $default_arch"
+    echo "Options:"
+    echo " -n : dry run"
+    echo " -v : verbose"
+    echo " -c : skips core repository"
+    echo " -r root (default is $root)"
+    echo " -u rsyncurl for fedora (default is $fedora_url)"
+    echo " -U rsyncurl for centos (default is $centos_url)"
+    echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url"
+    echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url"
+    echo " -f distroname - use vserver convention, e.g. fc6 and f7"
+    echo " -F : for distroname in $all_distronames"
+    echo " -a arch - use yum convention"
+    echo " -A : for arch in $all_archs"
+    exit 1
+}
+
 function main () {
     distronames=""
     archs=""
-    while getopts "nvcr:u:ef:Fa:Ah" opt ; do
+    while getopts "nvcr:u:U:ef:Fa:Ah" opt ; do
        case $opt in
            n) dry_run=--dry-run ; verbose=--verbose ;;
            v) verbose=--verbose ;;
            c) skip_core=true ;;
            r) root=$OPTARG ;;
-           u) rsyncurl=$OPTARG ;;
-           e) rsyncurl=$eu_rsyncurl ;;
+           u) fedora_url=$OPTARG ;;
+           U) centos_url=$OPTARG ;;
+           e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ;;
+           j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ;;
            f) distronames="$distronames $OPTARG" ;;
            F) distronames="$distronames $all_distronames" ;;
            a) archs="$archs $OPTARG" ;;
@@ -151,8 +169,8 @@ function main () {
     [ -z "$archs" ] && archs=$default_arch
 
     RES=0
-    for arch in $archs; do 
-       for distroname in $distronames ; do 
+    for distroname in $distronames ; do 
+       for arch in $archs; do 
            mirror_distro_arch "$distroname" "$arch" || RES=1
        done
     done