File: stable-update.sh

package info (click to toggle)
linux 3.16.7-ckt9-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 740,624 kB
  • ctags: 2,385,278
  • sloc: ansic: 12,217,941; asm: 277,354; perl: 53,978; xml: 47,771; makefile: 30,485; sh: 8,063; python: 6,597; cpp: 5,127; yacc: 4,254; lex: 2,215; awk: 741; pascal: 231; lisp: 218; sed: 30
file content (78 lines) | stat: -rwxr-xr-x 1,886 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash -eu

if [ $# -ne 2 ]; then
    echo >&2 "Usage: $0 REPO VERSION"
    echo >&2 "REPO is the git repository to generate a changelog from"
    echo >&2 "VERSION is the stable version (without leading v)"
    exit 2
fi

# Get base version, i.e. the Linus stable release that a version is based on
base_version() {
    local ver
    ver="${1%-rc*}"
    case "$ver" in
	2.6.*.* | [3-9].*.* | ??.*.*)
	    ver="${ver%.*}"
	    ;;
    esac
    echo "$ver"
}

add_update() {
    local base update
    base="$(base_version "$1")"
    update="${1#$base.}"
    if [ "$update" = "$1" ]; then
	update=0
    fi
    update="$((update + $2))"
    if [ $update = 0 ]; then
	echo "$base"
    else
	echo "$base.$update"
    fi
}

# Get next stable update version
next_update() {
    add_update "$1" 1
}

export GIT_DIR="$1/.git"

new_ver="$2"
cur_pkg_ver="$(dpkg-parsechangelog | sed -n 's/^Version: //p')"
cur_ver="${cur_pkg_ver%-*}"

if [ "$(base_version "$new_ver")" != "$(base_version "$cur_ver")" ]; then
    echo >&2 "$new_ver is not on the same stable series as $cur_ver"
    exit 2
fi

case "$cur_pkg_ver" in
    *~exp*)
	new_pkg_ver="$new_ver-1~exp1"
	;;
    *)
	new_pkg_ver="$new_ver-1"
	;;
esac

# dch insists on word-wrapping everything, so just add the URLs initially
dch -v "$new_pkg_ver" --preserve --multimaint-merge -D UNRELEASED \
    --release-heuristic=changelog "$(
    echo "New upstream stable update: "
    while [ "v$cur_ver" != "v$new_ver" ]; do
        cur_ver="$(next_update "$cur_ver")"
        echo "https://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-$cur_ver"
    done)"

# Then insert the shortlogs with sed
while [ "v$cur_ver" != "v$new_ver" ]; do
    next_ver="$(next_update "$cur_ver")"
    sed -i '/ChangeLog-'"${next_ver//./\\.}"'/a\
'"$(git log --reverse --pretty='    - %s\' "v$cur_ver..v$next_ver^")"'
' debian/changelog
    cur_ver="$next_ver"
done