Eric Faurot wrote:
>
> I set up a cron job at ibiblio to get the snapshots
> Here is the script:
>
> --------------------------------------------------
> #!/bin/bash
>
> # CVS tree
> CVSDIR=<path to local cvs copy>
>
> # Where should all the snapshots go
> SNPDIR=<path to ftp>
>
> # We keep logs in case
> LOGDIR=<path to log>
>
> # The modules that need snapshots. If a module is to be added,
> # it must be imported from cvs manually first.
> MODULES="ggi-core lowlevel"
>
> # how long before we trash the snapshots
> HISTORY=30
>
> BIN=/bin
>
> TODAY=`$BIN/date +%Y%m%d`
>
> makesnapshot() {
> if [ -f $LOGDIR/$1-$TODAY ]; then
> echo `$BIN/date` : Snapshot for $1 already done today >> $LOGDIR/log
> else
> echo `$BIN/date` : Making snapshot for $1 >> $LOGDIR/log
> $BIN/rm -f $LOGDIR/$1*
> # stamp
> $BIN/touch $LOGDIR/$1-$TODAY
> cd $CVSDIR
>
> # duplicate the current tree
> $BIN/cp -R $1 $1-pre
>
> #update the package
> cd $1; /usr/bin/cvs -Q update >> $LOGDIR/log; cd ..
>
> #create the diff
> /usr/bin/diff -ur $1-pre $1 > $SNPDIR/$1-diff-$TODAY
>
> #erase the old tree
> $BIN/rm -rf $1-pre
> if test -s $SNPDIR/$1-diff-$TODAY; then
> #build the snapshot
> $BIN/tar cvfz $SNPDIR/$1-$TODAY.tgz $1
> $BIN/gzip $SNPDIR/$1-diff-$TODAY
> else
> # no diff
> $BIN/rm $SNPDIR/$1-diff-$TODAY
> fi
> fi
> }
>
> for I in $MODULES; do
> makesnapshot $I
> done
> #erase all snapshots that are too old.
> /usr/bin/find $SNPDIR/ -ctime $HISTORY -exec /bin/rm {};
>
> ##############################################################
Another idea that could let you spare ibiblio's disk space and CPU time
(no more "cp -R", "rm -rf" and diff) :
- Let the CVS server do the diff for you
cvs -Q rdiff -D yesterday module_name > patch-for-today
- If the patch file is empty, nothing more is done except removing it.
- Else apply it on the current snapshot, make your tarball and [bg]zip
the patch file (btw why not compress with the -9 option ?)
That way, you no more need CVS dirs in your tree (are they useful for a
snapshot ?). If for some reason you want to keep them, do a cvs update
instead of applying the patch in the third step (the bad news is that
makes the CVS server work twice for each module).
Maybe I did not see some edge effects but this solution seems ok to me.
Do you see something wrong ?
Xavier