Fwd: [opensuse-packaging] How to detect package's version in specfile?
在 2012-11-1 下午11:37,"Guido Berhoerster"
PS: Guido, is "s|\\..*$||" regression? I asked around on gtalk, but no one knows such regex style...can you explain it a little bit?
Not sure what you mean, it's just a BRE, the double backslash is needed there because rpmbuild also interprets backslashes.
What is BRE? I mean, the rpmquery gets a 16.0.1, and you used a pipe and sed s/// replacement to get 16. But \..*$ doesn't looks like the regex we normally use, the [0–9]\.[0-9]\. Stuff. So.I want to know how it works like regex. Eg I want to cut 2.8.9 to 9, how can I do that in your way? And why in spec you cant compare %if 16.0.1 == 16 (get a -1) but can compare %if 16 > 15? Why I have to cut it using sed or I have to use lua script to compare the full output? I think all the numbers here are treated as strings, but why some fails while some still works? Thanks Marguerite -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Fri, 2 Nov 2012 06:14, Marguerite Su wrote:
在 2012-11-1 下午11:37,"Guido Berhoerster"
写道: PS: Guido, is "s|\\..*$||" regression? I asked around on gtalk, but no one knows such regex style...can you explain it a little bit?
Not sure what you mean, it's just a BRE, the double backslash is needed there because rpmbuild also interprets backslashes.
What is BRE? [snip] BRE = Basic Regular Expression (e.g. "grep -G", or sed w/o "-r") ERE = Extended Regular Expression (e.g. "grep -E" or "sed -r") PRE = Perl Regular Expression (e.g. "grep -P" or pcregrep)
and yes, in combination with rpmbuild that can be confusing (as already said: rpmbuild 'eats' single backslashes) -- Yamaban
On Fri, Nov 2, 2012 at 2:51 PM, Yamaban
What is BRE?
[snip] BRE = Basic Regular Expression (e.g. "grep -G", or sed w/o "-r") ERE = Extended Regular Expression (e.g. "grep -E" or "sed -r") PRE = Perl Regular Expression (e.g. "grep -P" or pcregrep)
Thanks! \..*$ \. means plain dot .* means any char $ means end so 2.8.9 to 9 might be sed '|^.\..\.||' (I didn't know . means any char, so I didn't understand Guido's BRE... M -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Quoting Marguerite Su :
在 2012-11-1 下午11:37,"Guido Berhoerster"
写道: PS: Guido, is "s|\\..*$||" regression? I asked around on gtalk, but no one knows such regex style...can you explain it a little bit?
Not sure what you mean, it's just a BRE, the double backslash is needed there because rpmbuild also interprets backslashes.
What is BRE?
I mean, the rpmquery gets a 16.0.1, and you used a pipe and sed s/// replacement to get 16.
But \..*$ doesn't looks like the regex we normally use, the [0–9]\.[0-9]\. Stuff. So.I want to know how it works like regex. Eg I want to cut 2.8.9 to 9, how can I do that in your way?
sed is flexible in which character. So Guide decided to usw | insead of / so you could also write "s/\\..*$//" then, what does this sed mean: as Guido already said, \\ is just for rpm to consume one, so we get a 'real' sed string of: s/\..*$//, which in turn means: \. => a literal dot (looking at 16.0.1, this matches the 'first' dot') .* => any amount of characters of any type $ => end of line. so we match .0.1 in this and using substitution, replaces this with [nothing] resulting in '16' being left alone. Hth, Dominique -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (3)
-
Dominique Leuenberger a.k.a DimStar
-
Marguerite Su
-
Yamaban