7 default_url="http://localhost/mirror/"
9 all_distros="f8 f10 f12 f13 centos5"
11 function check_distro () {
12 local distro=$1; shift
13 if [ ! -d $DIRNAME/$distro/yum.repos.d ] ; then
14 echo "Distro $distro not supported - skipped"
21 local distro=$1; shift
22 sedargs="-e s,@MIRRORURL@,$URL,"
23 [ -n "$GPGOFF" ] && sedargs="$sedargs -e "'s,gpgcheck\W*=\W*1,gpgcheck=0,'
24 sed $sedargs $DIRNAME/$distro/yum.repos.d/building.repo.in
28 local distro=$1; shift
29 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
30 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
31 if [ ! -d $dir ] ; then
32 [ -n "$VERBOSE" ] && echo Creating dir $dir
35 [ -n "$VERBOSE" ] && echo "Creating $repo"
36 do_repo $distro > $repo
40 local distro=$1; shift
41 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
42 if [ ! -f $repo ] ; then
43 echo "Cannot find $repo"
45 would=/tmp/$COMMAND.$$
46 do_repo $distro > $would
47 echo "==================== DIFF for $distro" '(current <-> would be)'
53 function do_display () {
54 local distro=$1; shift
55 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
57 echo "====================" Contents of $dir
58 ls $dir/*.repo 2> /dev/null | xargs head --verbose --lines=1000
60 echo "====================" $dir does not exist
64 function do_clean () {
65 local distro=$1; shift
66 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
67 [ -n "$VERBOSE" ] && echo Removing $repo
71 function do_superclean () {
72 local distro=$1; shift
73 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
74 [ -n "$VERBOSE" ] && echo Removing all repo files in $dir
79 echo "Usage $COMMAND [options] <command>"
80 echo " a help to manage the yum.repos.d template in /etc/vservers/.distributions/<distro>"
81 echo "Available commands"
82 echo " display: shows content (default if <command> is missing)"
83 echo " diff: shows diff between current and what init would do"
84 echo " init: creates /etc/vservers/.distributions/<distro>/yum.repos.d/building.repo"
85 echo " clean: removes building.repo"
86 echo " superclean: removes yum.repos.d altogether"
88 echo " -u URL to specify another location"
89 echo " default is to use mirror root at $default_url"
90 echo " -f <distro> : defaults to $default_distro"
91 echo " -a : runs on all distros $all_distros"
92 echo " -0 : turns off gpgcheck"
95 echo " $COMMAND -a display "
96 echo " $COMMAND -a superclean"
97 echo " $COMMAND -a -u http://mirror.onelab.eu/ init"
98 echo " $COMMAND -a display"
109 while getopts "u:f:a0v" opt; do
112 f) DISTROS="$DISTROS $OPTARG" ;;
113 a) DISTROS="$DISTROS $all_distros" ;;
120 shift $(($OPTIND - 1))
122 # no action = display
129 disp*) action=display ;;
130 init*) action=init ;;
131 diff*) action=diff ;;
132 clea*) action=clean ;;
133 super*) action=superclean ;;
140 [ -z "$URL" ] && URL=$default_url
141 [ -z "$DISTROS" ] && DISTROS="$default_distro"
143 # remove trailing slash
144 URL=$(echo $URL | sed -e 's,/$,,')
146 for distro in $DISTROS; do
147 [ -n "$VERBOSE" ] && echo ==================== Running $action for $distro
148 check_distro $distro && do_$action $distro