From 584102cfb3b2fa765388edebd77526b5e4ecbc66 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 10 Mar 2011 20:35:00 +0000 Subject: Add a backport script git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@471 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- backport | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100755 backport diff --git a/backport b/backport new file mode 100755 index 0000000..50a9fe0 --- /dev/null +++ b/backport @@ -0,0 +1,115 @@ +#!/bin/bash + +# Copyright 2011 Peter Palfrader +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +set -u +set -e + +get_bp_info() { + local target="$1"; shift + local key="$1"; shift + + local result=$(awk '$1 == "'"$target"'" {print}' << 'EOF' +#arg versiontag #tilde changelogdist +sarge sarge 5 +etch etch 4 +lenny lenny 3 +squeeze squeeze 2 +wheezy wheezy 1 + +sarge-bpo bpo31 1 sarge-backports +etch-bpo bpo40 1 etch-backports +lenny-bpo bpo50 1 lenny-backports +squeeze-bpo bpo60 1 squeeze-backports + +dapper dapper 1 +edgy edgy 1 +feisty feisty 1 +gutsy gutsy 1 +hardy hardy 1 +intrepid intrepid 1 +jaunty jaunty 1 +karmic karmic 1 +lucid lucid 1 +maverick maverick 1 +EOF +) + if [ -z "$result" ] ; then + echo >&2 "Do not now about target '$target'." + exit 1 + fi + set "nothing" $result + shift + if [ "$#" != "3" ] && [ "$#" != "4" ]; then + echo >&2 "Bad result line for '$target': '$result'." + exit 1 + fi + shift + case "$key" in + versiontag) echo "$1" ;; + tilde) echo "$2" ;; + changelogdist) echo "${3:-}" ;; + *) + echo >&2 "Invalid key '$key'" + exit 1 + esac + return 0 +} + +if [ "$#" != "1" ]; then + echo >&2 "Usage: $0 " + exit 1 +fi + +target="$1" + +versiontag=$(get_bp_info "$target" versiontag) +tildenum=$(get_bp_info "$target" tilde) +tildes="" +while [ "$tildenum" -gt 0 ]; do + tildes="$tildes~" + tildenum=$((tildenum-1)) +done +cldist=$(get_bp_info "$target" changelogdist) + + +currentdist=$(dpkg-parsechangelog | grep-dctrl -n -s Distribution '') +if [ -z "$currentdist" ]; then + echo >&2 "Cannot figure out current distribution" + exit 1 +fi +currentver=$(dpkg-parsechangelog | grep-dctrl -n -s Version '') +#currentupstream="${currentver%-*}" +#currentdebian="${currentver##*-}" +newver="$currentver$tildes$versiontag+1" +if [ -z "$cldist" ]; then + if [ "$currentdist" = "experimental" ]; then + cldist="experimental-$target-backport" + else + cldist="$target-backport" + fi +fi + +dch \ + --newversion "$newver" --allow-lower-version \ + --distribution "$cldist" --force-distribution \ + "Build for $cldist." -- cgit v1.2.3