Page 1 of 1

Compile without SVN keyword substitution

Posted: Sun Aug 01, 2010 8:29 pm
by BostX
An email from Linus Torvalds may explain my motivation for writing this script:
http://article.gmane.org/gmane.comp.ver ... .git/44654,

Bost

PS: I call the script 'make.no-svn-keywords.sh'

Code: Select all

#!/bin/bash

# Build the project without interference with SVN keyword substitution by replacing
# the SVN keywords with empty values. This way the default global revision number 
# specified by __REV in macros.inc will be used

svn_keywords=(
"LastChangedRevision"
"Revision"
"Rev"
"LastChangedDate"
"Date"
"LastChangedBy"
"Author"
"HeadURL"
"URL"
"Id"
)

# type of files where to look for svn keywords
regexCmd='.*\.inc\|.*\.asm\|.*\.conf\|.*\.txt\|.*\.bat\|.*\.sh\|.*\.ini\|.*\.asc'

for kWord in ${svn_keywords[@]}; do
  echo "Set svn keyword '$kWord' to ''"
  sedCmd="s:\\\$$kWord\\\$:\\\$$kWord \\\$:g"
  find ./ -type f -regex $regexCmd | xargs sed -i "$sedCmd"
done

echo ----- Now call the default buils script:
./make.sh $1

echo -----
for kWord in ${svn_keywords[@]}; do
  echo "Reset svn keyword '$kWord'"
  sedCmd="s:\\\$$kWord \\\$:\\\$$kWord\\\$:g"
  find ./ -type f -regex $regexCmd | xargs sed -i "$sedCmd"
done