From patchwork Wed Feb 1 14:01:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 722549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vD4Yn6nwvz9s65; Thu, 2 Feb 2017 01:01:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1cYvTn-0007sK-5b; Wed, 01 Feb 2017 14:01:47 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1cYvTP-0007kv-Ka for kernel-team@lists.ubuntu.com; Wed, 01 Feb 2017 14:01:23 +0000 Received: from 1.general.cascardo.us.vpn ([10.172.70.58] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1cYvTO-0000HM-TS for kernel-team@lists.ubuntu.com; Wed, 01 Feb 2017 14:01:23 +0000 From: Thadeu Lima de Souza Cascardo To: kernel-team@lists.ubuntu.com Subject: [xenial linux-meta-snapdragon 3/3] UBUNTU: add update-version to simplify updates Date: Wed, 1 Feb 2017 12:01:12 -0200 Message-Id: <20170201140112.28220-4-cascardo@canonical.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201140112.28220-1-cascardo@canonical.com> References: <20170201140112.28220-1-cascardo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Andy Whitcroft BugLink: http://bugs.launchpad.net/bugs/1601954 Signed-off-by: Andy Whitcroft Signed-off-by: Tim Gardner [cascardo: changed tagprefix to Ubuntu-snapdragon-] Signed-off-by: Thadeu Lima de Souza Cascardo --- update-version | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 update-version diff --git a/update-version b/update-version new file mode 100755 index 0000000..08b0ee0 --- /dev/null +++ b/update-version @@ -0,0 +1,85 @@ +#!/bin/bash + +tag_prefix="Ubuntu-snapdragon-" + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " 1>&2 + exit 1 +fi +master_dir="$1" + +# Work out the master kernel version. +if [ -f "$master_dir/debian/debian.env" ]; then + branch=`sed -ne 's/DEBIAN=//p' <"$master_dir/debian/debian.env"` + changelog="-l$branch/changelog" +else + changelog="" +fi +master_version=`(cd "$master_dir" && LC_ALL=C dpkg-parsechangelog -S Version $changelog)` + +# Work out our current version taking into account closed sections. +here_series=$( LC_ALL=C dpkg-parsechangelog -S Distribution ) +if [ "$here_series" = "UNRELEASED" ]; then + here_version=$( LC_ALL=C dpkg-parsechangelog -o 1 -S Version ) + here_series=$( LC_ALL=C dpkg-parsechangelog -c 1 -S Distribution ) +else + here_version=$( LC_ALL=C dpkg-parsechangelog -S Version ) +fi + +# Ensure we have the appropriate tag. +here_tagversion=$( echo "$tag_prefix$here_version" | sed -e 's/~/_/g' ) +count=$( git for-each-ref "refs/tags/$here_tagversion" | wc -l ) +if [ "$count" != 1 ]; then + echo "$0: $here_tagversion: tag not found" 1>&2 + exit 1 +fi + +# We need to ensure the ABI number matches our master source. +# extract both for comparison. +here_abi=${here_version%.*} +master_abi=$(echo ${master_version%.*} | sed -e 's/-/./g') +master_abi_human=${master_version%.*} + +# Extract the upload number from the _previous_ upload and increment it. +here_upload=${here_version##*.} +here_upload=$(( $here_upload + 1 )) +here_newversion="$master_abi.$here_upload" + +#echo "here_version<$here_version> here_abi<$here_abi> here_newversion<$here_newversion>" +#echo "master_version<$master_version> master_abi<$master_abi>" + +# First insert any primary changes. +marker="__CHANGELOG_FRAGMENT_MARKER__" +dch --newversion "$here_newversion" "$marker" + +# Prepare the the blank changelog. +tmp="/tmp/$$.msg" + +# If the parent represents an ABI bump include that. +if dpkg --compare-versions "$here_abi" lt "$master_abi"; then + echo "Updated to ABI: $master_abi" + [ -f "$tmp" ] && echo "" >>"$tmp" + echo " * Bump ABI $master_abi_human" >>"$tmp" +fi + +# Format any existing commits. +count=$( git log --oneline "$here_tagversion".. | wc -l ) +if [ "$count" != 0 ]; then + [ -f "$tmp" ] && echo "" >>"$tmp" + git log "$here_tagversion".. | "debian/scripts/misc/git-ubuntu-log" >>"$tmp" +fi + +# Insert official changelog fragment. +sed -i -e '/^ \* '"$marker"'/{ +r '"$tmp"' +d +}' debian/changelog +rm -f "$tmp" + +# Close this changelog entry. +dch --distribution "$here_series" --release '' + +# Emit final closing commands. +echo "git commit -s -m 'UBUNTU: $tag_prefix$here_newversion' debian/changelog" +here_tagversion=$( echo "$tag_prefix$here_newversion" | sed -e 's/~/_/g' ) +echo "git tag -s -m '$tag_prefix$here_newversion' '$here_tagversion'"