]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - update-dkms-versions
kallsyms: Fix kallsyms_selftest failure
[mirror_ubuntu-kernels.git] / update-dkms-versions
CommitLineData
81213768
AR
1#!/bin/bash
2
3remote_repo=''
6f3a7d34 4remote_branch='main'
81213768
AR
5sru_cycle=
6while :
7do
8 if [ "$1" = "--remote-repo" ]; then
9 remote_repo="$2"
10 shift 2
11
6f3a7d34
SB
12 elif [ "$1" = "--remote-branch" ]; then
13 remote_branch="$2"
14 shift 2
15
81213768
AR
16 elif [ "$1" = "--sru-cycle" ]; then
17 sru_cycle="$2"
18 shift 2
19
20 else
21 break
22 fi
23done
24if [ "$#" -ne 0 ]; then
25 {
26 echo "Usage: $0 [<options>]"
27 echo " --remote-repo <url>"
28 echo " --sru-cycle <cycle>"
29 } 1>&2
30 exit 1
31fi
32
33default_sru_cycle()
34{
35 local tracking_bug
36 local version
37
38 # Pick out the cycle from the tracking bug file.
39 if [ -f "$DEBIAN/tracking-bug" ]; then
40 read tracking_bug sru_cycle X <"$DEBIAN/tracking-bug"
41 fi
42
43 if [ -z "$sru_cycle" ]; then
44 echo "$0: sru-cycle not found via debian/tracking-bug; specify --sru-cycle" 1>&2
45 exit 1
46 fi
47
48 sru_cycle=$(echo "$sru_cycle" | sed -e 's/-[0-9][0-9]*$//' -e 's/^kernel-sru-cycle-//')
49
50 #echo "default_sru_cycle: version<$version> sru_cycle<$sru_cycle>"
51}
52
53# Determine where our changelog is.
54DEBIAN=debian
55[ -f 'debian/debian.env' ] && . 'debian/debian.env'
56
57[ -z "$sru_cycle" ] && default_sru_cycle
58if [ -z "$remote_repo" ]; then
59 case "$sru_cycle" in
613945ce 60 c[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9])
81213768
AR
61 remote_repo='security' ;;
62 *)
63 remote_repo='main' ;;
64 esac
65fi
66case "$remote_repo" in
67security)
68 remote_repo='ssh+git://git.launchpad.net/~canonical-kernel-security-team/canonical-kernel-private/+git/kernel-versions'
69 remote_name='security'
70 ;;
71main)
72 remote_repo='git://git.launchpad.net/~canonical-kernel/+git/kernel-versions'
73 remote_name='main'
74 ;;
75*)
76 remote_name='adhoc'
77 ;;
78esac
79
80#
81# kernel-versoins repository dkms-version mapping see below for details:
82# https://git.launchpad.net/~canonical-kernel/+git/kernel-versions/plain/README
83#
84kv_repo="$HOME/.cache/kernel-versions-bare"
81213768
AR
85
86# Now we know where our repo is and what it called update it.
87# We maintain "persistent" remotes for main and security, but assume
88# any manually supplied entries are transient.
89(
90 [ ! -d "$kv_repo" ] && mkdir -p "$kv_repo"
91 cd "$kv_repo" || exit 1
92 [ ! -f config ] && git init -q --bare
93 current_url=$(git config "remote.$remote_name.url")
94 if [ -z "$current_url" ]; then
95 git remote add "$remote_name" "$remote_repo"
96 elif [ "$current_url" != "$remote_repo" ]; then
97 git config "remote.$remote_name.url" "$remote_repo"
98 fi
99 git fetch -q -p "$remote_name"
100) || exit 1
101
102cat_file()
103{
104 (cd "$kv_repo" && git cat-file "$@") || exit 1
105}
106
6f3a7d34
SB
107# Determine if this is merge format (main branch exists).
108present=$(cat_file -t "$remote_name/main" 2>/dev/null)
109if [ "$present" ]; then
110 git_base="$remote_name/$remote_branch:$sru_cycle/"
111 git_base_devel="$remote_name/$remote_branch:tip/"
112else
113 git_base="$remote_name/$sru_cycle:"
114 git_base_devel="$remote_name/master:"
115fi
116git_human="$remote_name/$sru_cycle"
117
81213768
AR
118# Determine if we have this cycle.
119present=$(cat_file -t "$git_base" 2>/dev/null)
120if [ "$present" = "" ]; then
121 # If we don't have the cycle in the development cycle then
122 # fall back to master.
123 case "$sru_cycle" in
6f3a7d34 124 d*) git_base="$git_base_devel" ;;
81213768
AR
125 *) echo "$sru_cycle: cycle not found in $remote_repo" 2>&1
126 exit 1
127 ;;
128 esac
129fi
130
131# Determine our series and mainline version from our own changelog.
132our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SDistribution)
133if [ "$our_series" = "UNRELEASED" ]; then
134 our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -o1 -c1 -SDistribution)
135fi
136our_mainline=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SVersion | sed -e 's/-.*//')
137our_package=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SSource)
138our_source=$(echo "$our_package" | sed -e 's/-restricted-modules//')
139case "$our_package" in
140linux-restricted-modules*) our_type="lrm" ;;
141*) our_type="main" ;;
142esac
143
144# Update rules are complex. We update development series kernels to the
145# versions in development. For stable series we update versions against
146# the series in which our prime kernel was built. This is expressed
147# via the map/dkms-versions namespace. Attempt to map via our series
148# and then our mainline-version.
149
150# Try and find a package specific dkms-versions fragment. Try:
151# handle+type
152# series+type
153# mainline+type
154# series - backwards compatibility
155# mainline - backwards compatibility
156for versions_path_tail in \
157 "$our_series:$our_source:$our_type" \
158 "$our_series:$our_type" \
159 "$our_mainline:$our_type" \
160 "$our_series" \
161 "$our_mainline"
162do
163 echo "II: trying $versions_path_tail ..."
6f3a7d34 164 versions_paths=$(echo $(cat_file -p "${git_base}map/dkms-versions/$versions_path_tail" 2>/dev/null))
81213768
AR
165 [ -n "$versions_paths" ] && break
166done
167
168if [ -z "$versions_paths" ]; then
169 echo "$0: unable to identify dkms-versions mapping" 1>&2
170 exit 1
171fi
172
173echo "git_base<$git_base> versions_paths<$versions_paths>"
174echo "II: grabbing dkms-versions from $sru_cycle $versions_paths"
175
176: ">debian/dkms-versions.new"
177for versions_path in $versions_paths
178do
6f3a7d34 179 cat_file -p "$git_base$versions_path" >>"debian/dkms-versions.new"
81213768
AR
180 if [ "$?" -ne 0 ]; then
181 echo "$0: unable to download an updated dkms-versions file" 1>&2
182 exit 1
183 fi
184done
185mv "debian/dkms-versions.new" "debian/dkms-versions"
186
187thing="debian/dkms-versions"
188if ! git diff --exit-code -- "$thing" >/dev/null; then
6f3a7d34 189 git commit -m "UBUNTU: $thing -- update from kernel-versions ($git_human)" \
81213768
AR
190 -m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
191 -s -- "$thing"
192else
193 echo "$thing: no changes from kernel-versions"
194fi
195
196exit 0