- update_shell_title "cvsup"
- local OPTIONS="up "
- if [ -n "$CVSROOT" ]; then
- OPTIONS="-d $CVSROOT $OPTIONS"
- fi
-
- if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
- OPTIONS="$OPTIONS -A"
- else
- if [ -n "$CVSDATE" ]; then
- OPTIONS="$OPTIONS -D $CVSDATE"
- fi
- if [ -n "$CVSTAG" ]; then
- OPTIONS="$OPTIONS -r $CVSTAG"
- fi
- fi
-
- local result=1
- local retries_counter=0
- update_shell_title "cvsup: $# files"
- while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
- retries_counter=$(( $retries_counter + 1 ))
- output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
- result=$?
- [ -n "$output" ] && echo "$output"
- if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
- echo "Trying again [$*]... ($retries_counter)"
- update_shell_title "cvsup: retry #$retries_counter"
- sleep 2
- continue
- else
- break
- fi
- done
- update_shell_title "cvsup: done!"
- return $result
+ update_shell_title "cvsup"
+ local OPTIONS="up "
+ if [ -n "$CVSROOT" ]; then
+ OPTIONS="-d $CVSROOT $OPTIONS"
+ fi
+
+ if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
+ OPTIONS="$OPTIONS -A"
+ else
+ if [ -n "$CVSDATE" ]; then
+ OPTIONS="$OPTIONS -D $CVSDATE"
+ fi
+ if [ -n "$CVSTAG" ]; then
+ OPTIONS="$OPTIONS -r $CVSTAG"
+ fi
+ fi
+
+ local result=1
+ local retries_counter=0
+ if [ $# = 1 ]; then
+ update_shell_title "cvsup: $*"
+ else
+ update_shell_title "cvsup: $# files"
+ fi
+ while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
+ retries_counter=$(( $retries_counter + 1 ))
+ output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
+ result=$?
+ [ -n "$output" ] && echo "$output"
+ if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
+ echo "Trying again [$*]... ($retries_counter)"
+ update_shell_title "cvsup: retry #$retries_counter"
+ sleep 2
+ continue
+ else
+ break
+ fi
+ done
+ update_shell_title "cvsup: done!"
+ return $result
+}
+
+update_md5()
+{
+ if [ $# -eq 0 ]; then
+ return
+ fi
+
+ update_shell_title "update md5"
+ if [ -n "$DEBUG" ]; then
+ set -x;
+ set -v;
+ fi
+
+ cd "$SOURCE_DIR"
+
+ # pass 1: check files to be fetched
+ local todo
+ local need_files
+ for i in "$@"; do
+ local fp=$(nourl "$i")
+ local srcno=$(src_no "$i")
+ if [ -n "$UPDATE5" ]; then
+ if [ -n "$ADD5" ]; then
+ [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
+ grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
+ else
+ grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
+ fi
+ fi
+ if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
+ need_files="$need_files $i"
+ fi
+ done
+
+ # pass 1a: get needed files
+ if [ "$need_files" ]; then
+ get_files $need_files
+ fi
+
+ # pass 2: proceed with md5 adding or updating
+ for i in "$@"; do
+ local fp=$(nourl "$i")
+ local srcno=$(src_no "$i")
+ if [ -n "$UPDATE5" ] && \
+ ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
+ [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
+ grep -q -i -E '^#[ ]*source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
+ then
+ echo "Updating source-$srcno md5."
+ md5=$(md5sum "$fp" | cut -f1 -d' ')
+ perl -i -ne '
+ print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
+ print "# Source'$srcno'-md5:\t'$md5'\n"
+ if /^Source'$srcno'\s*:\s+/;
+ ' \
+ $SPECS_DIR/$SPECFILE
+ fi
+ done
+}
+
+check_md5()
+{
+ update_shell_title "check md5"
+
+ for i in "$@"; do
+ if good_md5 "$i" && good_size "$i"; then
+ continue
+ fi
+
+ echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
+ echo "or -5 to update md5 sums, if you're sure files are correct."
+ Exit_error err_no_source_in_repo $i
+ done