Danny
Danny

Reputation: 5410

Trouble getting revision number out of svn for spec file

I'm working on a spec file where I want to use the revision number of the SVN repo as part of the version number.

If I use just:

%(svnversion -c %{sourcedir})

Then I get PackageName-1-209:299 where 299 is the revision number. So I am trying to crop out the "1-209" section as it's consistently there and doesn't change.

The line I'm having issues with is:

%(svnversion -c %{sourcedir} | sed 's/^1\-209://')

What I seem to get out from this is PackageName209:299 still.

Any help would be much appreciated!

Upvotes: 0

Views: 854

Answers (1)

pmod
pmod

Reputation: 11007

You probably should try another regular expression:

%(svnversion -cn %{sourcedir} | sed -r 's/.+://')

However, note that svnversion may also add some letters in the end (M if there are local modifications, S - if it is the switched working copy). Do you need to check them - is up to you.

PS

There is a faster way to get the current revision (since svnrevision requests svn server to collect data) described here:

grep revision .svn/entries |  awk -F\" '{print $2}'

However, this will not work for svn since version 1.7.

Upvotes: 1

Related Questions