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