From 4df0d59cac01a9197d14d885e12b6e5461d7a562 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 30 Nov 2007 14:25:04 +0000 Subject: [PATCH] reviewed options: (*) verbose is less verbose as far as shell is concerned - but it does run rsync --verbose (*) -c allows to skip the core repo as it is not supposed to change (*) default is fedora8 (*) refactored a bit - *layout should not have changed* though --- vbuild-fedora-mirror.sh | 97 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/vbuild-fedora-mirror.sh b/vbuild-fedora-mirror.sh index 04b8568b..50421f54 100755 --- a/vbuild-fedora-mirror.sh +++ b/vbuild-fedora-mirror.sh @@ -1,26 +1,34 @@ #!/bin/bash # this can help you create/update your fedora mirror +# $Id$ COMMAND=$(basename $0) dry_run= +verbose= +skip_core= root=/data/fedora/linux rsyncurl=rsync://mirrors.kernel.org/fedora -distroname=fc6 +distroname=f8 arch=i386 function usage () { - echo "Usage: $COMMAND [-n] [-v] [-r root] [-u rsyncurl] [-f distroname] [-a arch]" + echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u rsyncurl] [-f distroname] [-a arch]" echo "Defaults to -r $root -u $rsyncurl -f $distroname -a $arch" echo "Use vserver conventions for distroname, e.g. fc6 and f7" + echo "Options:" + echo " -n : dry run" + echo " -v : verbose" + echo " -c : skips core repository" exit 1 } -while getopts "nvr:u:f:a:h" opt ; do +while getopts "nvcr:u:f:a:h" opt ; do case $opt in - n) dry_run=-n ;; - v) set -x ; verbose=true ;; + n) dry_run=--dry-run ;; + v) verbose=--verbose ;; + c) skip_core=true ;; r) root=$OPTARG ;; u) rsyncurl=$OPTARG ;; f) distroname=$OPTARG ;; @@ -46,49 +54,38 @@ case $distroname in echo "Unknown redhat distribution $distroname - exiting" RES=1 ;; - esac excludelist="debug/ iso/ ppc/ source/" -options="$dry_run -avz --delete --delete-excluded --quiet" -[ -n "$verbose" ] && options="$options --verbose" -for e in $excludelist -do +options="--archive --compress --delete --delete-excluded $dry_run $verbose" +for e in $excludelist; do options="$options --exclude $e" done -echo "root=$root" -echo "distro=$distroname" -echo "distroname=$distroname" -echo "distroindex=$distroindex" -echo "arch=$arch" -echo rsyncurl="$rsyncurl" -echo "rsync options=$options" +if [ -n "$verbose" ] ; then + echo "root=$root" + echo "distro=$distroname" + echo "distroname=$distroname" + echo "distroindex=$distroindex" + echo "arch=$arch" + echo rsyncurl="$rsyncurl" + echo "rsync options=$options" +fi -RES=0 +RES=1 +paths="" case $distro in [Ff]edora*) case $distroindex in 2|4|6) - for repopath in core/$distroindex/$arch/os/ core/updates/$distroindex/$arch/ extras/$distroindex/$arch/ - do - echo "============================== $distro -> $distroindex $repopath" - mkdir -p ${root}/${repopath} - rsync $options ${rsyncurl}/${repopath} ${root}/${repopath} - done + [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/" + paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/" + RES=0 ;; - 7|8) - for repopath in releases/$distroindex/Everything/$arch/os/ updates/$distroindex/$arch/ - do - echo "============================== $distro -> $distroindex $repopath" - mkdir -p ${root}/${repopath} - rsync $options ${rsyncurl}/${repopath} ${root}/${repopath} - done - ;; - *) - echo "Unknown fedora index $distroindex - exiting" - RES=1 + [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/" + paths="$paths updates/$distroindex/$arch/" + RES=0 ;; esac ;; @@ -96,25 +93,25 @@ case $distro in CentOS*) case $distroindex in 5) - for repopath in $distroindex/os/$arch/ $distroindex/updates/$arch/ - do - echo "============================== $distro -> $distroindex $repopath" - mkdir -p ${root}/${repopath} - rsync $options ${rsyncurl}/${repopath} ${root}/${repopath} - done - - ;; - *) - echo "$distro $distroindex currently unsupported - exiting" - RES=1 + [ -z "$skip_core" ] && paths="$distroindex/os/$arch/" + paths="$paths $distroindex/updates/$arch/" + RES=0 ;; esac ;; - *) - echo "$distro $distroindex currently unsupported - exiting" - RES=1 - ;; esac +if [ "$RES" = 1 ] ; then + echo "$distro $distroindex currently unsupported - exiting" +else + for repopath in $paths; do + echo "============================== $distro -> $distroindex $repopath" + [ -z "$dry_run" ] && mkdir -p ${root}/${repopath} + command="rsync $options ${rsyncurl}/${repopath} ${root}/${repopath}" + echo $command + $command + done +fi + exit $RES -- 2.43.0