switch to use rsync://mirrors.kernel.org/fedora by default
[build.git] / vbuild-fedora-mirror.sh
1 #!/bin/bash
2 # this can help you create/update your fedora mirror
3
4 COMMAND=$(basename $0)
5
6 dry_run=
7 root=/data/fedora/linux
8 rsyncurl=rsync://mirrors.kernel.org/fedora
9 #rsyncurl=rsync://fr.rpmfind.net/linux/fedora
10 fcdistro=fc6
11 arch=i386
12
13
14 function usage () {
15     echo "Usage: $COMMAND [-n] [-v] [-r root] [-u rsyncurl] [-f fcdistro] [-a arch]"
16     echo "Defaults to -r $root -u $rsyncurl -f $fcdistro -a $arch"
17     echo "Use vserver conventions for fcdistro, e.g. fc6 and f7"
18     exit 1
19 }
20
21 while getopts "nvr:u:f:a:h" opt ; do
22     case $opt in
23         n) dry_run=-n ;;
24         v) set -x ;;
25         r) root=$OPTARG ;;
26         u) rsyncurl=$OPTARG ;;
27         f) fcdistro=$OPTARG ;;
28         a) arch=$OPTARG ;;
29         h|*) usage ;;
30     esac
31 done
32
33 case $fcdistro in
34     fc*[1-6])
35         findex=$(echo $fcdistro | sed -e s,fc,,g)
36         ;;
37     *)
38         findex=$(echo $fcdistro | sed -e s,f,,g)
39         ;;
40 esac
41
42 echo "root=$root"
43 echo rsyncurl="$rsyncurl"
44 echo "fcdistro=$fcdistro"
45 echo "findex=$findex"
46 echo "arch=$arch"
47
48 case $findex in
49     2|4|6)
50         echo "============================== $findex core"
51         mkdir -p ${root}/core/$findex/$arch/os/
52         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/$findex/$arch/os/ ${root}/core/$findex/$arch/os/
53         echo "============================== $findex updates"
54         mkdir -p  ${root}/core/updates/$findex/$arch/
55         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/updates/$findex/$arch/ ${root}/core/updates/$findex/$arch/
56         echo "============================== $findex extras"
57         mkdir -p ${root}/extras/$findex/$arch/
58         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/extras/$findex/$arch/ ${root}/extras/$findex/$arch/
59         ;;
60     7)
61         echo "============================== $findex core"
62         mkdir -p ${root}/core/$findex/$arch/os/
63         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/$findex/Everything/$arch/os/ ${root}/core/$findex/$arch/os/
64         echo "============================== $findex updates"
65         mkdir -p ${root}/core/updates/$findex/$arch/
66         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/updates/$findex/$arch/ ${root}/core/updates/$findex/$arch/
67         ;;
68     8)
69     # somehow the layout on my favorite mirror is different in 7 and 8, /Everything/ has gone 
70         echo "============================== $findex core"
71         mkdir -p ${root}/core/$findex/$arch/os/
72         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/$findex/$arch/os/ ${root}/core/$findex/$arch/os/
73         echo "============================== $findex updates"
74         mkdir -p ${root}/core/updates/$findex/$arch/
75         rsync $dry_run -avz --delete --exclude debug/ ${rsyncurl}/core/updates/$findex/$arch/ ${root}/core/updates/$findex/$arch/
76         ;;
77     *)
78         echo "Unknown fedora index $findex - exiting"
79         exit 1
80         ;;
81 esac