[m-rev.] for review: remove old RPMs from the BETA_WEBDIR directory.

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jun 29 11:54:16 AEST 2004


Hi Pete,

Thanks for that.  Sorry about leaving all that mess around :)

On 28-Jun-2004, Peter Ross <pro at missioncriticalit.com> wrote:
> Note that we still don't clean up the ftp directory, but seeing that 
> we use scp to copy the files there, I'm not sure what the best approach
> for deleting those files is.

You can use ssh and rm, e.g. search for "FTP" in tools/test_mercury
to see how that script does it.

> --- tools/build_rpm	16 Feb 2004 21:13:43 -0000	1.3
> +++ tools/build_rpm	28 Jun 2004 12:08:34 -0000
> @@ -104,10 +104,12 @@
>  	stable)
>  		base_version=`cat $BETA_WEBDIR/latest-stable-version`
>  		version=$base_version
> +		regex="[0-9]"
>  		;;
>  	unstable)
>  		base_version=`cat $BETA_WEBDIR/latest-unstable-version`
>  		version=$base_version-unstable
> +		regex="unstable"
>  		;;
>  esac
>  
> @@ -143,9 +145,19 @@
>     $BETA_WEBDIR/mercury-compiler-$version_with_underscores-$rel.$arch.rpm" \
>  	|| failed 'copying RPM to web site'
>  su mercury -c "\
> +rm -f `find $BETA_WEBDIR -name \*$regex-$rel.$arch.rpm -and -not -name \
> +       mercury-compiler-$version_with_underscores-$rel.$arch.rpm`" \
> +	|| failed 'to delete old RPM'

The "-and" and "-not" arguments to "find" are not standard.
Use "-a" and "!" instead; those are supported by the Posix standard.
Or alternatively, it might be easier to delete the existing .rpm files
first, and then copy the new one across; then you can just use rm without
needing the "find" command.  That is what tools/test_mercury does for
the .tar.gz files.

The pattern "*$regex-$rel.$arch.rpm" is overly broad, IMHO.
Much better to use "mercury-compiler-" at the start.  You never know
what other RPMs someone will one day put in the same directory.
In general it is a good idea to be very careful with "rm" commands in
scripts, especially where a complicated pattern is involved; it is easy
to accidentally delete more than you intended to.

The argument to find's -name option is a "pattern", not a "regex",
so the variable "regex" is misleadingly named.
I would also put the "*" in the definitions of that variable
rather than in the "rm" commands.  Then I'd name the variable
"version_pattern".

Otherwise that looks good -- thanks.

-- 
Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list