sm-discuss AT lists.ibiblio.org
Subject: Public SourceMage Discussion List
List archive
- From: Dufflebunk <dufflebunk AT dufflebunk.homeip.net>
- To: sm-discuss AT lists.ibiblio.org
- Subject: [SM-Discuss] Script for Spell Maintainers
- Date: 11 Aug 2002 03:29:33 -0400
I've written a script to help with spell updates. Examples:
update_spell.sh -version 1.0b4 -updated -md5
$GRIMOIRE/devel/gcvs/DETAILS
Will update the VERSION field, update the UPDATED field, and download
and uncompress (but not untar) the archive, do an md5sum, and update the
MD5 field.
As always, for themost up to date version, check my web site
http://dufflebunk.homeip.net/~dufflebunk/sorcerer
--
Quidquid latine dictum sit, altum sonatur.
-----------------
PGP public key at
http://wwwkeys.ch.pgp.net:11371/pks/lookup?op=get&search=0x92B5D3F1
#!/bin/bash function usage() { cat << EOF syntax: update_spell.sh [ option ] file ARGs: -version <new-version> new version -updated update UPDATE field -md5 download and update MD5 field EOF } function args() { let i=0 while [ $# -gt 1 ] ; do case $1 in -version) NEW_VERSION=$2 let i+=2 shift 2 ;; -updated) NEW_UPDATED=`date +%Y%m%d` let i+=1 shift 1 ;; -md5) wget --passive-ftp -O /tmp/update_spell.dl.$$.tmp $URL && COMPRESSOR=`guess_compressor /tmp/update_spell.dl.$$.tmp` && NEW_MD5=`uncompress /tmp/update_spell.dl.$$.tmp $COMPRESSOR \ | md5sum | awk '{print $1;}'` rm /tmp/update_spell.dl.$$.tmp let i+=1 shift 1 ;; *) usage exit 1 esac done return $i } #--------------------------------------------------------------------- #=item guess_compressor ## ## Guesses what program was used to compress a file ## ## Takes one arg, the file to guess about. ## #--------------------------------------------------------------------- guess_compressor() { echo "Running guess_compressor() on $1" >> $DEBUG COMPRESSOR=`$FILEPROG -b $1 | cut -d ' ' -f1` if [ "$COMPRESSOR" = "GNU" ] ; then COMPRESSOR=`$FILEPROG -b $1 | cut -d ' ' -f2` fi echo "Compressor guessed to be $COMPRESSOR" >> $DEBUG && echo $COMPRESSOR } #--------------------------------------------------------------------- #=item uncompress ## ## Just uncompresses the file, but does not expand it. i.e. bunzip ## it, but don't untar it. It dumps the expanded file to stdout. ## ## Takes two args, filename in, and compressor. ## #--------------------------------------------------------------------- uncompress() { case $2 in bzip2) bzip2 -cdf $1 >&1 ;; gzip) gzip -cdf $1 >&1 ;; compress*) gzip -cdf $1 >&1 ;; Zip) echo $1 >&1 ;; RPM) rpmunpack < $1 | gzip -d \ >&1 ;; tar) echo $1 >&1 ;; *) false ;; esac } NEW_VERSION="" NEW_UPDATED="" NEW_MD5="" DETAILS=${!#} . /etc/sorcery/config . $DETAILS > /dev/null URL=${SOURCE_URL[0]} args $* shift $? [[ $DETAILS ]] || ( usage ; exit 1 ) SED="sed" [[ $NEW_VERSION ]] && SED="$SED -e s/^\([[:blank:]]*VERSION=\).*$/\1"$NEW_VERSION"/" [[ $NEW_UPDATED ]] && SED="$SED -e s/^\([[:blank:]]*UPDATED=\).*$/\1"$NEW_UPDATED"/" [[ $NEW_MD5 ]] && SED="$SED -e s/^\([[:blank:]]*MD5=\).*$/\1\""$NEW_MD5"\"/" echo $NEW_VERSION, $NEW_UPDATED, $NEW_MD5 echo $SED NEW_DETAILS=`$SED $DETAILS` EQ_COL=`echo "$NEW_DETAILS" | head -n 1 | awk -F '=' '{ print length($1) ;}'` if ! echo "$NEW_DETAILS" | grep -q "[[:blank:]]*VERSION=" ; then let NUM_SPACES=$EQ_COL-8 NEW_DETAILS="$NEW_DETAILS"$'\n' for (( i=0 ; i<$NUM_SPACES; i++ )) ; do NEW_DETAILS="$NEW_DETAILS " done NEW_DETAILS="${NEW_DETAILS}VERSION=$NEW_VERSION" fi if ! echo "$NEW_DETAILS" | grep -q "[[:blank:]]*UPDATED=" ; then let NUM_SPACES=$EQ_COL-8 NEW_DETAILS="$NEW_DETAILS"$'\n' for (( i=0 ; i<$NUM_SPACES ; i++ )) ; do NEW_DETAILS="$NEW_DETAILS " done NEW_DETAILS="${NEW_DETAILS}UPDATED=$NEW_UPDATED" fi if ! echo "$NEW_DETAILS" | grep -q "[[:blank:]]*MD5=" ; then let NUM_SPACES=$EQ_COL-4 echo "spaces=$NUM_SPACES" NEW_DETAILS="$NEW_DETAILS"$'\n' for (( i=0 ; i<$NUM_SPACES ; i++ )) ; do NEW_DETAILS="$NEW_DETAILS " done NEW_DETAILS="${NEW_DETAILS}MD5=\"$NEW_MD5\"" fi echo "$NEW_DETAILS"
Attachment:
signature.asc
Description: This is a digitally signed message part
-
[SM-Discuss] Script for Spell Maintainers,
Dufflebunk, 08/11/2002
- Re: [SM-Discuss] Script for Spell Maintainers, Sergey A. Lipnevich, 08/11/2002
Archive powered by MHonArc 2.6.24.