diff mbox

[Precise/lts-backport-trusty,1/1] UBUNTU: update-from-*-master -- add parameter to change source branch

Message ID 20170505123713.26880-2-kleber.souza@canonical.com
State New
Headers show

Commit Message

Kleber Sacilotto de Souza May 5, 2017, 12:37 p.m. UTC
Add a '-b' parameter to make it easier to override the default source
release branch without the need to set the env var
'_SOURCE_RELEASE_BRANCH'. When using this parameter it will also use
the tip of the branch instead of the most recent tag for the rebase.

Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
---
 debian.trusty/etc/update-from-trusty-master | 37 +++++++++++++++++++----------
 1 file changed, 24 insertions(+), 13 deletions(-)

Comments

Andy Whitcroft June 9, 2017, 3:38 p.m. UTC | #1
On Fri, May 05, 2017 at 02:37:13PM +0200, Kleber Sacilotto de Souza wrote:
> Add a '-b' parameter to make it easier to override the default source
> release branch without the need to set the env var
> '_SOURCE_RELEASE_BRANCH'. When using this parameter it will also use
> the tip of the branch instead of the most recent tag for the rebase.
> 
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
> ---
>  debian.trusty/etc/update-from-trusty-master | 37 +++++++++++++++++++----------
>  1 file changed, 24 insertions(+), 13 deletions(-)
> 
> diff --git a/debian.trusty/etc/update-from-trusty-master b/debian.trusty/etc/update-from-trusty-master
> index 9ca12218e0a..66077a33a34 100755
> --- a/debian.trusty/etc/update-from-trusty-master
> +++ b/debian.trusty/etc/update-from-trusty-master
> @@ -6,7 +6,8 @@
>  # the Raring master branch changelog with the correct release names.
>  #
>  SOURCE_RELEASE=trusty
> -SOURCE_RELEASE_BRANCH=${_SOURCE_RELEASE_BRANCH:=master-next}
> +SOURCE_RELEASE_BRANCH=master-next
> +SOURCE_BRANCH_SEARCH_TAG=true
>  DEBIAN_SOURCE=debian.master
>  
>  TARGET_RELEASE=precise
> @@ -26,16 +27,22 @@ POCKET=""
>  IGNORE_ABI=""
>  IGNORE_MODULES=""
>  
> -usage="$0 [-r RELEASE_REPO] [-p]"
> +usage="$0 [-r RELEASE_REPO] [-b BRANCH_NAME] [-p]"
>  
>  #
>  # command line options:
>  # [-r RELEASE_REPO] - override default ${SOURCE_RELEASE} git repository.
> +# [-b BRANCH_NAME] - override default ${SOURCE_RELEASE_BRANCH} and use
> +#                    the tip of the branch instead of the most recent tag.
>  # [-p] - Assume the upload target is a PPA
>  
> -while getopts ":r:pim" opt; do
> +while getopts ":r:b:pim" opt; do
>  	case $opt in
>  	r ) RELEASE_REPO="$OPTARG" ;;
> +	b )
> +	    SOURCE_RELEASE_BRANCH="$OPTARG"
> +	    SOURCE_BRANCH_SEARCH_TAG=false
> +	    ;;
>  	p ) POCKET="" ;;
>  	\? ) echo usage: ${usage}; exit ;;
>  	esac
> @@ -59,16 +66,20 @@ git fetch ${RELEASE_REPO} ${SOURCE_RELEASE_BRANCH} || exit 1
>  # rebase against it. This avoids the case where there have been some
>  # commits since the last official tag.
>  #
> -MASTER_COMMIT=`git log --pretty=one FETCH_HEAD | \
> -    awk '
> -	/Ubuntu-/ {
> -		if (match($0, /UBUNTU: Ubuntu-[0-9]/)) {
> -				print $1
> -				exit
> -                        }
> -                }
> -        '
> -`
> +if [ "$SOURCE_BRANCH_SEARCH_TAG" = true ]; then
> +	MASTER_COMMIT=`git log --pretty=one FETCH_HEAD | \
> +	    awk '
> +		/Ubuntu-/ {
> +			if (match($0, /UBUNTU: Ubuntu-[0-9]/)) {
> +					print $1
> +					exit
> +				}
> +			}
> +		'
> +	`
> +else
> +	MASTER_COMMIT=`git rev-parse FETCH_HEAD`
> +fi
>  #
>  # Find the current merge point where ${SOURCE_RELEASE} was based.
>  #

Like it.  I can see how we can use this to rebase onto a master tag with
a commit applied rather than applying the same fix to every branch.  I
can also see how one could use it to handle cves.

Is this a branch btw, if it is revparse it could be any commitish no?

Anyhow, like the idea.

-apw
diff mbox

Patch

diff --git a/debian.trusty/etc/update-from-trusty-master b/debian.trusty/etc/update-from-trusty-master
index 9ca12218e0a..66077a33a34 100755
--- a/debian.trusty/etc/update-from-trusty-master
+++ b/debian.trusty/etc/update-from-trusty-master
@@ -6,7 +6,8 @@ 
 # the Raring master branch changelog with the correct release names.
 #
 SOURCE_RELEASE=trusty
-SOURCE_RELEASE_BRANCH=${_SOURCE_RELEASE_BRANCH:=master-next}
+SOURCE_RELEASE_BRANCH=master-next
+SOURCE_BRANCH_SEARCH_TAG=true
 DEBIAN_SOURCE=debian.master
 
 TARGET_RELEASE=precise
@@ -26,16 +27,22 @@  POCKET=""
 IGNORE_ABI=""
 IGNORE_MODULES=""
 
-usage="$0 [-r RELEASE_REPO] [-p]"
+usage="$0 [-r RELEASE_REPO] [-b BRANCH_NAME] [-p]"
 
 #
 # command line options:
 # [-r RELEASE_REPO] - override default ${SOURCE_RELEASE} git repository.
+# [-b BRANCH_NAME] - override default ${SOURCE_RELEASE_BRANCH} and use
+#                    the tip of the branch instead of the most recent tag.
 # [-p] - Assume the upload target is a PPA
 
-while getopts ":r:pim" opt; do
+while getopts ":r:b:pim" opt; do
 	case $opt in
 	r ) RELEASE_REPO="$OPTARG" ;;
+	b )
+	    SOURCE_RELEASE_BRANCH="$OPTARG"
+	    SOURCE_BRANCH_SEARCH_TAG=false
+	    ;;
 	p ) POCKET="" ;;
 	\? ) echo usage: ${usage}; exit ;;
 	esac
@@ -59,16 +66,20 @@  git fetch ${RELEASE_REPO} ${SOURCE_RELEASE_BRANCH} || exit 1
 # rebase against it. This avoids the case where there have been some
 # commits since the last official tag.
 #
-MASTER_COMMIT=`git log --pretty=one FETCH_HEAD | \
-    awk '
-	/Ubuntu-/ {
-		if (match($0, /UBUNTU: Ubuntu-[0-9]/)) {
-				print $1
-				exit
-                        }
-                }
-        '
-`
+if [ "$SOURCE_BRANCH_SEARCH_TAG" = true ]; then
+	MASTER_COMMIT=`git log --pretty=one FETCH_HEAD | \
+	    awk '
+		/Ubuntu-/ {
+			if (match($0, /UBUNTU: Ubuntu-[0-9]/)) {
+					print $1
+					exit
+				}
+			}
+		'
+	`
+else
+	MASTER_COMMIT=`git rev-parse FETCH_HEAD`
+fi
 #
 # Find the current merge point where ${SOURCE_RELEASE} was based.
 #