#!/bin/bash new_buildini="$TMP/buildini.$RANDOM" # whack the file just in case. rm -f "$new_buildini" echo -n "" >"$new_buildini" # pick a weird separator that we hope never to see. IFS='~' found_revision="" found_version="" skip_line="" while read line_found; do if [ $? != 0 ]; then break; fi #echo line found is $line_found if [ ! -z "$skip_line" ]; then # we were told to skip this line to fix win32. skip_line="" continue fi first_part="" if [ -z "$found_revision" ]; then first_part=`echo $line_found | sed -n -e 's/^ *revision *=.*$/yep/p' ` fi #echo first part is $first_part if [ ! -z "$first_part" ]; then second_part=`echo $line_found | sed -e 's/.*=\(.*\)$/\1/' ` #echo second part is $second_part new_rev=`expr $second_part + 1` echo "new build revision: $new_rev" echo "revision=$new_rev" >>"$new_buildini" found_revision="yes" else if [ -z "$found_version" ]; then if [ "$line_found" == "#[version]" ]; then # repair our special escape that makes this a valid ini file and # gnu make include file. echo -e "#\\\\\n[version]" >>"$new_buildini" found_version="yes" elif [ "$line_found" == "#" ]; then # retarded win32 case. echo -e "#\\\\\n[version]" >>"$new_buildini" found_version="yes" skip_line="yes" fi else # send the line with no processing. echo "$line_found" >>"$new_buildini" fi fi done <"$REPOSITORY_DIR/build.ini" if [ -s "$new_buildini" ]; then # we created something with contents, so let's use it. cp "$new_buildini" "$REPOSITORY_DIR/build.ini" fi # don't leave the temporary version files floating around. rm -f "$new_buildini"