-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-version
executable file
·133 lines (112 loc) · 3.66 KB
/
update-version
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
here=$(dirname $(readlink -f "$0"))
tag_prefix=`dpkg-parsechangelog -SSource | sed 's/linux-meta/Ubuntu/'`-
commit=:
no_update=false
master_version=
master_dir=
while :
do
if [ "$1" = "--commit" ]; then
shift
commit=
elif [ "$1" = "--no-update" ]; then
shift
no_update=true
elif [ "$1" = "--master-version" ]; then
master_version="$2"
shift 2
else
break
fi
done
if [ "$master_version" = "" ]; then
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <linux-source-directory>" 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 -SVersion $changelog)`
else
no_update=true
fi
# Work out our current version taking into account closed sections.
here_series=$( LC_ALL=C dpkg-parsechangelog -SDistribution )
if [ "$here_series" = "UNRELEASED" ]; then
here_version=$( LC_ALL=C dpkg-parsechangelog -o 1 -SVersion )
here_series=$( LC_ALL=C dpkg-parsechangelog -c 1 -SDistribution )
else
here_version=$( LC_ALL=C dpkg-parsechangelog -SVersion )
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
update_file()
{
local src="$1"
local dst="$2"
cp -p "$src" "$dst" || exit 1
if ! git diff --exit-code -- "$dst" >/dev/null; then
git commit -m "UBUNTU: $dst -- update from master" -s -- "$dst"
else
echo "$dst: no changes from master"
fi
}
# Update things from the primary package.
if [ "$no_update" = 'false' ]; then
update_file "$master_dir/$branch/dkms-versions" "debian/dkms-versions"
update_file "$master_dir/debian/scripts/misc/git-ubuntu-log" "debian/scripts/misc/git-ubuntu-log"
fi
#echo "here_version<$here_version>"
#echo "master_version<$master_version>"
# Work out a sensible new version based on the primary kernel version.
if dpkg --compare-versions "$here_version" lt "$master_version"; then
here_newversion="$master_version"
elif dpkg --compare-versions "$here_version" eq "$master_version"; then
here_newversion="$master_version+1"
else
minor=$(( ${here_version##*+} + 1 ))
here_newversion="$master_version+$minor"
fi
# First insert any primary changes.
marker="__CHANGELOG_FRAGMENT_MARKER__"
dch --newversion "$here_newversion" "$marker"
# Prepare the blank changelog.
tmp="/tmp/$$.msg"
# Note we are being synced to the master version.
if dpkg --compare-versions "$here_version" lt "$master_version"; then
echo "Updated to version: $master_version"
[ -f "$tmp" ] && echo "" >>"$tmp"
echo " * Master version: $master_version" >>"$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 'TUXEDO: $tag_prefix$here_newversion' debian/changelog"
$commit git commit -s -m "TUXEDO: $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'"
$commit git tag -s -m "$tag_prefix$here_newversion" "$here_tagversion"