• [^] # Re: Mirroirs Mandrake en vrac...l'explication

    Posté par . En réponse au journal Mirroirs Mandrake en vrac...l'explication. Évalué à 1.

    Mandrake a merdé avec les miroirs et c'est de leur faute.

    Par contre que ta cooker "merde", ce sont tes oignons. C'est une version de développment.

    J'ai une fedora synchro sur la branche de développement que je mirror.
    J'ai un petit script maison pour conserver les vieux paquets (dans le cas où les nouveaux sont plus mauvais que les anciens).

    Voilà la hiérarchie utiliséee :
    development/i386
    backup/development/i386_1
    backup/development/i386_2
    backup/development/i386_3
    backup/development/i386_4
    backup/development/i386_5
    backup/development/i386_archive

    J'utilise les liens hards pour ne pas bouffer trop de place disque.

    #!/bin/bash

    # 1ドル source rsync url
    # Take care about the trailing slash.
    # 2ドル destination directory
    function rotate ()
    {
    # DRY_RUN=--dry-run
    source=1ドル
    desti=2ドル
    if [ ! -d $desti ]; then mkdir -p $desti || return 1; fi
    # remove rsync tmp files if any.
    rm -f $desti/.??* || return 1
    TEMPDIR=`mktemp -d tmp_XXXXXX` || return 1
    # create a pristine copy with hard links
    cp -plr $desti/. $TEMPDIR || return 1

    rsync -av $DRY_RUN --delete $source $desti
    if [ $? -ne 0 ] ; then
    # This work because rsync erase file (mv .toto.XXXXXX toto).
    echo "Something go wrong, restore the tmp copy in $TEMPDIR"
    rm -r -f $desti || return 1
    mv $TEMPDIR $desti
    return 1
    fi

    # find out files with only one link in the tmp copy
    RETVAL=`find $TEMPDIR -links 1 -type f | wc -l`
    if [ $RETVAL -eq 0 ] ; then
    echo "Nothing to backup"
    rm -r -f $TEMPDIR
    return 0
    fi

    # archive
    if [ ! -d backup ]; then mkdir backup || return 1; fi
    if [ ! -d backup/`dirname $desti` ]; then mkdir -p backup/`dirname $desti` || return 1; fi

    # Uncomment this lines to store all retrieve packages.
    if [ -d backup/${desti}_5 ]; then
    if [ ! -d backup/${desti}_archive ]; then mkdir -p backup/${desti}_archive || return 1; fi
    find backup/${desti}_5 -links 1 -print0 | xargs -0 -i mv -v -f {} backup/${desti}_archive || return 1
    fi
    rm -r -f backup/${desti}_5 || return 1
    if [ -d backup/${desti}_4 ]; then mv backup/${desti}_4 backup/${desti}_5 || return 1; fi
    if [ -d backup/${desti}_3 ]; then mv backup/${desti}_3 backup/${desti}_4 || return 1; fi
    if [ -d backup/${desti}_2 ]; then mv backup/${desti}_2 backup/${desti}_3 || return 1; fi
    if [ -d backup/${desti}_1 ]; then mv backup/${desti}_1 backup/${desti}_2 || return 1; fi

    # backup removed files.
    # if [ ! -d backup/${desti}_1 ]; then mkdir backup/${desti}_1 || return 1; fi
    # find $TEMPDIR -links 1 -print0 | xargs -0 -i mv -v {} backup/${desti}_1 || return 1
    # rm -r -f $TEMPDIR

    # or backup all files. This one is little better (theoretically less rotate) but more confusing.
    mv $TEMPDIR backup/${desti}_1 || return 1

    return 0
    }
    # example :
    rotate fr2.rpmfind.net::linux/fedora/core/development/i386/Fedora/RPMS/ development/i386 || exit $?
    rotate fr2.rpmfind.net::linux/fedora/core/development/SRPMS/ development/SRPMS || exit $?