[freenet-dev] [freenet-cvs] r20171 - trunk/apps/new_installer/scripts

NextGen$ nextgens at freenetproject.org
Thu Jun 26 08:43:58 UTC 2008


* Matthew Toseland <toad at amphibian.dyndns.org> [2008-06-26 02:17:28]:

> On Sunday 01 June 2008 05:23, nextgens at freenetproject.org wrote:
> > Author: nextgens
> > Date: 2008-06-01 04:23:44 +0000 (Sun, 01 Jun 2008)
> > New Revision: 20171
> > 
> > Modified:
> >    trunk/apps/new_installer/scripts/update.sh
> > Log:
> > new_installer: simplify update.sh
> > 
> > Modified: trunk/apps/new_installer/scripts/update.sh
> > ===================================================================
> > --- trunk/apps/new_installer/scripts/update.sh	2008-06-01 03:37:08 UTC (rev 
> 20170)
> > +++ trunk/apps/new_installer/scripts/update.sh	2008-06-01 04:23:44 UTC (rev 
> 20171)
> > +
> > +file_md5sum_comp () {
> > +	if file_exist "$1" "$2"
> > +	then
> > +		MD5_FILE1="`cat \"$1\"|md5sum`"
> > +		MD5_FILE2="`cat \"$2\"|md5sum`"
> > +		return `test "$MD5_FILE1" = "$MD5_FILE2"`
> 
> Doesn't work. The output of md5sum includes the filename, you need to chop it 
> out.
> 

Which in that case is "-"; why do I need to chop it exactly ?

> > +	else
> > +		return 1
> > +	fi
> > +}
> > +
> > +file_sha1sum_comp () {
> > +	if file_exist "$1" "$2"
> > +	then
> > +		SHA1_FILE1="`cat \"$1\"|sha1sum`"
> > +		SHA1_FILE2="`cat \"$2\"|sha1sum`"
> > +		echo $SHA1_FILE1 $SHA1_FILE2
> > +		return `test "$SHA1_FILE1" = "$SHA1_FILE2"`
> 
> Likewise.
> 
> > +	else
> > +		return 1
> > +	fi
> > +}
> > +
> > +# Determine which one we will use
> > +if test ! -x "`which sha1sum`"
> > +then
> > +	if test ! -x "`which md5sum`"
> > +	then
> > +		if test ! -x "`which cmp`"
> > +		then
> > +			echo "No cmp nor md5sum nor sha1sum utility detected; Please install one 
> of those"
> > +			exit 1
> > +		else
> > +			CMP="invert_return_code file_cmp_comp"
> > +		fi
> > +	else
> > +		CMP="invert_return_code file_md5sum_comp"
> > +	fi
> > +else
> > +	CMP="invert_return_code file_sha1sum_comp"
> > +fi
> 
> We should really use cmp if it's available, it's quicker.

It s not a matter of speed, we need a hash function



More information about the Devl mailing list