6 default_url="http://localhost/mirror/"
8 all_distros="f12 f14 f16 f18 f20"
10 function check_distro () {
11 local distro=$1; shift
12 if [ ! -d $DIRNAME/$distro/yum.repos.d ] ; then
13 echo "Distro $distro not supported - skipped"
20 local distro=$1; shift
21 sedargs="-e s,@MIRRORURL@,$URL,g"
22 [ -n "$GPGOFF" ] && sedargs="$sedargs -e "'s,gpgcheck\W*=\W*1,gpgcheck=0,'
23 sed $sedargs $DIRNAME/$distro/yum.repos.d/building.repo.in
27 local distro=$1; shift
28 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
29 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
30 if [ ! -d $dir ] ; then
31 [ -n "$VERBOSE" ] && echo Creating dir $dir
34 [ -n "$VERBOSE" ] && echo "Creating $repo"
35 do_repo $distro > $repo
39 local distro=$1; shift
40 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
41 if [ ! -f $repo ] ; then
42 echo "Cannot find $repo"
44 would=/tmp/$COMMAND.$$
45 do_repo $distro > $would
46 echo "==================== DIFF for $distro" '(current <-> would be)'
52 function do_display () {
53 local distro=$1; shift
54 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
56 echo "====================" Contents of $dir
57 ls $dir/*.repo 2> /dev/null | xargs head --verbose --lines=1000
59 echo "====================" $dir does not exist
63 function do_clean () {
64 local distro=$1; shift
65 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
66 [ -n "$VERBOSE" ] && echo Removing $repo
70 function do_superclean () {
71 local distro=$1; shift
72 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
73 [ -n "$VERBOSE" ] && echo Removing all repo files in $dir
78 echo "Usage $COMMAND [options] <command>"
79 echo " a help to manage the yum.repos.d template in /etc/vservers/.distributions/<distro>"
80 echo "Available commands"
81 echo " display: shows content (default if <command> is missing)"
82 echo " diff: shows diff between current and what init would do"
83 echo " init: creates /etc/vservers/.distributions/<distro>/yum.repos.d/building.repo"
84 echo " clean: removes building.repo"
85 echo " superclean: removes yum.repos.d altogether"
87 echo " -u URL to specify another location"
88 echo " default is to use mirror root at $default_url"
89 echo " -f <distro> : defaults to $default_distro"
90 echo " -a : runs on all distros $all_distros"
91 echo " -0 : turns off gpgcheck"
94 echo " $COMMAND -a display "
95 echo " $COMMAND -a superclean"
96 echo " $COMMAND -a -u http://mirror.onelab.eu/ init"
97 echo " $COMMAND -a display"
108 while getopts "u:f:a0v" opt; do
111 f) DISTROS="$DISTROS $OPTARG" ;;
112 a) DISTROS="$DISTROS $all_distros" ;;
119 shift $(($OPTIND - 1))
121 # no action = display
128 disp*) action=display ;;
129 init*) action=init ;;
130 diff*) action=diff ;;
131 clea*) action=clean ;;
132 super*) action=superclean ;;
139 [ -z "$URL" ] && URL=$default_url
140 [ -z "$DISTROS" ] && DISTROS="$default_distro"
142 # remove trailing slash
143 URL=$(echo $URL | sed -e 's,/$,,')
145 for distro in $DISTROS; do
146 [ -n "$VERBOSE" ] && echo ==================== Running $action for $distro
147 check_distro $distro && do_$action $distro