Patchwork [06,of,22] buildrpm: introduce --rev for building RPMs for other versions

login
register
mail settings
Submitter Mads Kiilerich
Date May 20, 2014, 2:10 a.m.
Message ID <a95a7bf9ed7ef26f622c.1400551801@mk-desktop>
Download mbox | patch
Permalink /patch/4828/
State Changes Requested
Headers show

Comments

Mads Kiilerich - May 20, 2014, 2:10 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1400111317 -7200
#      Thu May 15 01:48:37 2014 +0200
# Node ID a95a7bf9ed7ef26f622cbc01bfa28ee049fbf231
# Parent  2259d306178fe5cce7f57cda30241d7a991f0b8d
buildrpm: introduce --rev for building RPMs for other versions

Can be used to build packages on the stable branch using packaging improvements
on the development branch.
Gilles Moris - May 21, 2014, 5:28 a.m.
Le 20/05/2014 04:10, Mads Kiilerich a écrit :
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1400111317 -7200
> #      Thu May 15 01:48:37 2014 +0200
> # Node ID a95a7bf9ed7ef26f622cbc01bfa28ee049fbf231
> # Parent  2259d306178fe5cce7f57cda30241d7a991f0b8d
> buildrpm: introduce --rev for building RPMs for other versions
>
> Can be used to build packages on the stable branch using packaging improvements
> on the development branch.
>
> diff --git a/contrib/buildrpm b/contrib/buildrpm
> --- a/contrib/buildrpm
> +++ b/contrib/buildrpm
> @@ -7,6 +7,25 @@
>   # - CentOS 5
>   # - centOS 6
>   
> +if [ -z "$REV" ]; then
> +    REV=.
> +else
> +    echo "Using \$REV=$REV for --rev" 1>&2
> +fi
Why does the "if" block above does not go after the while as a fallback.
There is a risk that we lie in the echo if we override REV with the 
--rev option.

> +while [ "$1" ]; do
> +    case "$1" in
> +    -r | --rev )
> +        shift
> +        REV="$1"
> +        shift
> +        ;;
> +    * )
> +        echo "Invalid parameter $1!" 1>&2
> +        exit 1
> +        ;;
> +    esac
> +done
> +
>   cd "`dirname $0`/.."
>   
>   specfile=contrib/mercurial.spec
> @@ -40,7 +59,7 @@ mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $
>   # Tags with -rc are named X.X.X-0.rc instead of X.X.X-rc - that makes sure that
>   # the final -1.x cames after -0.rc.x (so 3.0.0-1.7 comes after 3.0.0-0.rc.7).
>   
> -hgversion=`$HG par -T '{ifeq(branch, "stable", "", "0.next.")}{sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n'`
> +hgversion=`$HG log -r "$REV" -T '{ifeq(branch, "stable", "", "0.next.")}{sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n'`
>   
>   # An example of full version numbers:
>   # 3.0.0-1.0.2195ac506c6a
> @@ -53,7 +72,7 @@ hgversion=`$HG par -T '{ifeq(branch, "st
>   version=${hgversion%-*}
>   release=${hgversion#*-}
>   
> -$HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
> +$HG archive -r "$REV" -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
>   rpmspec=$rpmdir/SPECS/mercurial.spec
>   
>   (
> @@ -61,7 +80,7 @@ sed \
>       -e "s,^Version:.*,Version: $version," \
>       -e "s,^Release:.*,Release: $release," \
>       $specfile
> -$HG log -r "sort(::.-::parents(tagged('re:^[0-9.]*$')&::parents(.)),-date)" \
> +$HG log -r "sort(::($REV)-::parents(tagged('re:^[0-9.]*$')&::parents($REV)),-date)" \
>       -T '* {date(date|localdate, "%a %b %d %Y")} {author} {sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n{if(tags,"- {tags}\n")}- {desc|firstline}\n\n'
>   ) > $rpmspec
>   
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active.
http://www.avast.com
Mads Kiilerich - May 21, 2014, 12:27 p.m.
On 05/21/2014 07:28 AM, Gilles Moris wrote:
>
> Le 20/05/2014 04:10, Mads Kiilerich a écrit :
>> # HG changeset patch
>> # User Mads Kiilerich <madski@unity3d.com>
>> # Date 1400111317 -7200
>> #      Thu May 15 01:48:37 2014 +0200
>> # Node ID a95a7bf9ed7ef26f622cbc01bfa28ee049fbf231
>> # Parent  2259d306178fe5cce7f57cda30241d7a991f0b8d
>> buildrpm: introduce --rev for building RPMs for other versions
>>
>> Can be used to build packages on the stable branch using packaging 
>> improvements
>> on the development branch.
>>
>> diff --git a/contrib/buildrpm b/contrib/buildrpm
>> --- a/contrib/buildrpm
>> +++ b/contrib/buildrpm
>> @@ -7,6 +7,25 @@
>>   # - CentOS 5
>>   # - centOS 6
>>   +if [ -z "$REV" ]; then
>> +    REV=.
>> +else
>> +    echo "Using \$REV=$REV for --rev" 1>&2
>> +fi
> Why does the "if" block above does not go after the while as a fallback.
> There is a risk that we lie in the echo if we override REV with the 
> --rev option.

It could. The intention is that this message should inform that it is 
picking this value up from the environment. Just to make sure it doesn't 
silently do something the user didn't expect. In that way it is "using" 
it. And that check has to be before we "parse" --rev.

I do not consider it a risk that the user overrules that with an 
explicit option.

Admittedly this is a bit fragile and not the perfect user experience ... 
but this is shell script and we want to keep it as simple as possible.

>
>> +while [ "$1" ]; do
>> +    case "$1" in
>> +    -r | --rev )
>> +        shift
>> +        REV="$1"
>> +        shift
>> +        ;;
>> +    * )
>> +        echo "Invalid parameter $1!" 1>&2
>> +        exit 1
>> +        ;;
>> +    esac
>> +done
>> +
>>   cd "`dirname $0`/.."
>>     specfile=contrib/mercurial.spec

/Mads

Patch

diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -7,6 +7,25 @@ 
 # - CentOS 5
 # - centOS 6
 
+if [ -z "$REV" ]; then
+    REV=.
+else
+    echo "Using \$REV=$REV for --rev" 1>&2
+fi
+while [ "$1" ]; do
+    case "$1" in
+    -r | --rev )
+        shift
+        REV="$1"
+        shift
+        ;;
+    * )
+        echo "Invalid parameter $1!" 1>&2
+        exit 1
+        ;;
+    esac
+done
+
 cd "`dirname $0`/.."
 
 specfile=contrib/mercurial.spec
@@ -40,7 +59,7 @@  mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $
 # Tags with -rc are named X.X.X-0.rc instead of X.X.X-rc - that makes sure that
 # the final -1.x cames after -0.rc.x (so 3.0.0-1.7 comes after 3.0.0-0.rc.7).
 
-hgversion=`$HG par -T '{ifeq(branch, "stable", "", "0.next.")}{sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n'`
+hgversion=`$HG log -r "$REV" -T '{ifeq(branch, "stable", "", "0.next.")}{sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n'`
 
 # An example of full version numbers:
 # 3.0.0-1.0.2195ac506c6a
@@ -53,7 +72,7 @@  hgversion=`$HG par -T '{ifeq(branch, "st
 version=${hgversion%-*}
 release=${hgversion#*-}
 
-$HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
+$HG archive -r "$REV" -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
 rpmspec=$rpmdir/SPECS/mercurial.spec
 
 (
@@ -61,7 +80,7 @@  sed \
     -e "s,^Version:.*,Version: $version," \
     -e "s,^Release:.*,Release: $release," \
     $specfile
-$HG log -r "sort(::.-::parents(tagged('re:^[0-9.]*$')&::parents(.)),-date)" \
+$HG log -r "sort(::($REV)-::parents(tagged('re:^[0-9.]*$')&::parents($REV)),-date)" \
     -T '* {date(date|localdate, "%a %b %d %Y")} {author} {sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n{if(tags,"- {tags}\n")}- {desc|firstline}\n\n'
 ) > $rpmspec