Hi All,
I thought it would be easier to fix this, but as of now, I find no
better way than this (all on the same line):

DEBVERSION=$(dpkg-parsechangelog | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*}

the first command extract the debian version (removing epoch if
present), the second removed the last "-<something>" if present.

some examples:

$ DEBVERSION=$(echo "Version: 1" | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*} ; echo $UPSTREAMVERSION
1
$ DEBVERSION=$(echo "Version: 1.2.3" | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*} ; echo $UPSTREAMVERSION
1.2.3
$ DEBVERSION=$(echo "Version: 1.2.3-5" | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*} ; echo $UPSTREAMVERSION
1.2.3
$ DEBVERSION=$(echo "Version: 9-8-7-6" | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*} ; echo $UPSTREAMVERSION
9-8-7
$ DEBVERSION=$(echo "Version: 1:1.2.3-5" | grep "^Version:" | sed
's/^Version:[[:space:]]\+\([0-9]\+:\)\?\(.*\)/\2/') ;
UPSTREAMVERSION=${DEBVERSION%-*} ; echo $UPSTREAMVERSION
1.2.3

the only thing that could break is native packages that uses "-" in
the version, but I think that if you can choose, doubtly you'll use
"-" but ".".

I will keep working on this (since it's rather interesting) for a
"better" solution.

Cheers (and Happy New Year),
Sandro

-- 
Sandro Tosi (aka morph, Morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to