diff mbox series

[hirsute/master-next,1/1] UBUNTU: [Packaging] switch to kernel-versions

Message ID 20210901125144.1539387-2-apw@canonical.com
State New
Headers show
Series [hirsute/master-next,1/1] UBUNTU: [Packaging] switch to kernel-versions | expand

Commit Message

Andy Whitcroft Sept. 1, 2021, 12:51 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1928921

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 update-dkms-versions | 162 +++++++++++++++++++++++++++++++++++++++++++
 update-version-dkms  |  58 +---------------
 2 files changed, 164 insertions(+), 56 deletions(-)
 create mode 100755 update-dkms-versions

Comments

Stefan Bader Sept. 1, 2021, 1:41 p.m. UTC | #1
On 01.09.21 14:51, Andy Whitcroft wrote:
> BugLink: https://bugs.launchpad.net/bugs/1928921

This replaces update-versions-dkms with update-dkms-versions. The change in name 
is deliberate as the new script must be called at a different stage of the crank 
process. (Either continue to explain below or refer to crank documentation)
> 
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

Assuming this more or less is what I already manually did when preparing last cycle:
- first do link-tb and then
- use the lrm script to update the versions from the repo instead of the archive

-Stefan

>   update-dkms-versions | 162 +++++++++++++++++++++++++++++++++++++++++++
>   update-version-dkms  |  58 +---------------
>   2 files changed, 164 insertions(+), 56 deletions(-)
>   create mode 100755 update-dkms-versions
> 
> diff --git a/update-dkms-versions b/update-dkms-versions
> new file mode 100755
> index 000000000000..11d9db31cd4d
> --- /dev/null
> +++ b/update-dkms-versions
> @@ -0,0 +1,162 @@
> +#!/bin/bash
> +
> +remote_repo=''
> +sru_cycle=
> +while :
> +do
> +	if [ "$1" = "--remote-repo" ]; then
> +		remote_repo="$2"
> +		shift 2
> +
> +	elif [ "$1" = "--sru-cycle" ]; then
> +		sru_cycle="$2"
> +		shift 2
> +
> +	else
> +		break
> +	fi
> +done
> +if [ "$#" -ne 0 ]; then
> +	{
> +		echo "Usage: $0 [<options>]"
> +		echo "       --remote-repo <url>"
> +		echo "       --sru-cycle <cycle>"
> +	} 1>&2
> +	exit 1
> +fi
> +
> +default_sru_cycle()
> +{
> +	local tracking_bug
> +	local version
> +
> +	# Pick out the cycle from the tracking bug file.
> +	if [ -f "$DEBIAN/tracking-bug" ]; then
> +		read tracking_bug sru_cycle X <"$DEBIAN/tracking-bug"
> +	fi
> +
> +	if [ -z "$sru_cycle" ]; then
> +		echo "$0: sru-cycle not found via debian/tracking-bug; specify --sru-cycle" 1>&2
> +		exit 1
> +	fi
> +
> +	sru_cycle=$(echo "$sru_cycle" | sed -e 's/-[0-9][0-9]*$//' -e 's/^kernel-sru-cycle-//')
> +
> +	#echo "default_sru_cycle: version<$version> sru_cycle<$sru_cycle>"
> +}
> +
> +# Determine where our changelog is.
> +DEBIAN=debian
> +[ -f 'debian/debian.env' ] && . 'debian/debian.env'
> +
> +[ -z "$sru_cycle" ] && default_sru_cycle
> +if [ -z "$remote_repo" ]; then
> +	case "$sru_cycle" in
> +	s[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9])
> +		remote_repo='security' ;;
> +	*)
> +		remote_repo='main' ;;
> +	esac
> +fi
> +case "$remote_repo" in
> +security)
> +	remote_repo='ssh+git://git.launchpad.net/~canonical-kernel-security-team/canonical-kernel-private/+git/kernel-versions'
> +	remote_name='security'
> +	;;
> +main)
> +	remote_repo='git://git.launchpad.net/~canonical-kernel/+git/kernel-versions'
> +	remote_name='main'
> +	;;
> +*)
> +	remote_name='adhoc'
> +	;;
> +esac
> +
> +#
> +# kernel-versoins repository dkms-version mapping see below for details:
> +#  https://git.launchpad.net/~canonical-kernel/+git/kernel-versions/plain/README
> +#
> +kv_repo="$HOME/.cache/kernel-versions-bare"
> +git_base="$remote_name/$sru_cycle"
> +
> +# Now we know where our repo is and what it called update it.
> +# We maintain "persistent" remotes for main and security, but assume
> +# any manually supplied entries are transient.
> +(
> +	[ ! -d "$kv_repo" ] && mkdir -p "$kv_repo"
> +	cd "$kv_repo" || exit 1
> +	[ ! -f config ] && git init -q --bare
> +	current_url=$(git config "remote.$remote_name.url")
> +	if [ -z "$current_url" ]; then
> +		git remote add "$remote_name" "$remote_repo"
> +	elif [ "$current_url" != "$remote_repo" ]; then
> +		git config "remote.$remote_name.url" "$remote_repo"
> +	fi
> +	git fetch -q -p "$remote_name"
> +) || exit 1
> +
> +cat_file()
> +{
> +	(cd "$kv_repo" && git cat-file "$@") || exit 1
> +}
> +
> +# Determine if we have this cycle.
> +present=$(cat_file -t "$git_base" 2>/dev/null)
> +if [ "$present" = "" ]; then
> +	# If we don't have the cycle in the development cycle then
> +	# fall back to master.
> +	case "$sru_cycle" in
> +	d*)	git_base="$remote_name/master" ;;
> +	*)	echo "$sru_cycle: cycle not found in $remote_repo" 2>&1
> +		exit 1
> +		;;
> +	esac
> +fi
> +
> +# Determine our series and mainline version from our own changelog.
> +our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SDistribution)
> +if [ "$series" = "UNRELEASED" ]; then
> +	our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -c1 -SDistribution)
> +fi
> +our_mainline=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SVersion | sed -e 's/-.*//')
> +
> +# Update rules are complex.  We update development series kernels to the
> +# versions in development.  For stable series we update versions against
> +# the series in which our prime kernel was built.  This is expressed
> +# via the map/dkms-versions namespace.  Attempt to map via our series
> +# and then our mainline-version.
> +
> +# Attempt to map via our series, if that works assume we are development.
> +versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_series" 2>/dev/null)
> +
> +# If we do not yet have a mapping re-map using our mainline version.
> +if [ -z "$versions_path" ]; then
> +	versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_mainline")
> +fi
> +
> +echo "git_base<$git_base> versions_path<$versions_path>"
> +echo "II: grabbing dkms-versions from $sru_cycle $versions_path"
> +
> +cat_file -p "$git_base:$versions_path" >"debian/dkms-versions.new"
> +rc="$?"
> +if [ "$rc" -ne 0 ]; then
> +	echo "$0: unable to download an updated dkms-versions file" 1>&2
> +	exit 1
> +
> +elif [ "$rc" -eq 0 ]; then
> +	mv "debian/dkms-versions.new" "debian/dkms-versions"
> +
> +else
> +	rm -f "debian/dkms-versions.new"
> +fi
> +
> +thing="debian/dkms-versions"
> +if ! git diff --exit-code -- "$thing" >/dev/null; then
> +	git commit -m "UBUNTU: $thing -- update from kernel-versions ($git_base)" \
> +		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
> +		-s -- "$thing"
> +else
> +	echo "$thing: no changes from kernel-versions"
> +fi
> +
> +exit "$rc"
> diff --git a/update-version-dkms b/update-version-dkms
> index d90ce2c85f65..a266fecc06f8 100755
> --- a/update-version-dkms
> +++ b/update-version-dkms
> @@ -1,58 +1,4 @@
>   #!/bin/bash
>   
> -if [ "$#" -ne 1 ]; then
> -	echo "Usage: $0 <pocket>" 1>&2
> -	exit 1
> -fi
> -pocket="$1"
> -
> -case "$pocket" in
> -proposed)			pocket_list="-$pocket -updates -release" ;;
> -updates|security)		pocket_list="-$pocket -release" ;;
> -release)			pocket_list="-release" ;;
> -*)
> -	echo "$0: $pocket: unknown archive pocket" 1>&2
> -	exit 1
> -	;;
> -esac
> -
> -# find our changelog.
> -debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
> -
> -# identify the current series
> -series=$(dpkg-parsechangelog -l"$debian/changelog" -SDistribution)
> -if [ "$series" = "UNRELEASED" ]; then
> -	series=$(dpkg-parsechangelog -l"$debian/changelog" -c1 -o1 -SDistribution)
> -fi
> -
> -# Determine if we have any updates.
> -: >"debian/dkms-versions.new"
> -while read package version remainder
> -do
> -	for pocket_raw in $pocket_list
> -	do
> -		pocket="${pocket_raw#-release}"
> -		read x x pocket_version x <<EOL
> -$(rmadison -a source -s "$series$pocket" $package)
> -EOL
> -		[ "$pocket_version" != '' ] && break
> -	done
> -	if [ "$pocket_version" = '' ]; then
> -		echo "$0: $package: no version found in $pocket_list" 1>&2
> -		exit 1
> -	else
> -		echo "$package: $pocket_version found in $pocket_raw"
> -	fi
> -	if [ "$version" != "$pocket_version" ]; then
> -		echo "$package: updated to $pocket_version"
> -	fi
> -	echo "$package $pocket_version $remainder" | sed -e 's/  *$//' >>"debian/dkms-versions.new"
> -done <"debian/dkms-versions"
> -if ! cmp -s "debian/dkms-versions.new" "debian/dkms-versions"; then
> -	mv -f "debian/dkms-versions.new" "debian/dkms-versions"
> -	git commit -s -m "UBUNTU: update dkms package versions" \
> -		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
> -		"debian/dkms-versions"
> -else
> -	rm -f "debian/dkms-versions.new"
> -fi
> +echo "EE: run update-dkms-versions after link-to-tracker" 1>&2
> +exit 1
>
Kleber Sacilotto de Souza Sept. 2, 2021, 8:46 a.m. UTC | #2
On 01.09.21 14:51, Andy Whitcroft wrote:
> BugLink: https://bugs.launchpad.net/bugs/1928921
> 
> Signed-off-by: Andy Whitcroft <apw@canonical.com>

As this goes to the main kernels I have fixed the nominations on the bug
report.


Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Thanks

> ---
>   update-dkms-versions | 162 +++++++++++++++++++++++++++++++++++++++++++
>   update-version-dkms  |  58 +---------------
>   2 files changed, 164 insertions(+), 56 deletions(-)
>   create mode 100755 update-dkms-versions
> 
> diff --git a/update-dkms-versions b/update-dkms-versions
> new file mode 100755
> index 000000000000..11d9db31cd4d
> --- /dev/null
> +++ b/update-dkms-versions
> @@ -0,0 +1,162 @@
> +#!/bin/bash
> +
> +remote_repo=''
> +sru_cycle=
> +while :
> +do
> +	if [ "$1" = "--remote-repo" ]; then
> +		remote_repo="$2"
> +		shift 2
> +
> +	elif [ "$1" = "--sru-cycle" ]; then
> +		sru_cycle="$2"
> +		shift 2
> +
> +	else
> +		break
> +	fi
> +done
> +if [ "$#" -ne 0 ]; then
> +	{
> +		echo "Usage: $0 [<options>]"
> +		echo "       --remote-repo <url>"
> +		echo "       --sru-cycle <cycle>"
> +	} 1>&2
> +	exit 1
> +fi
> +
> +default_sru_cycle()
> +{
> +	local tracking_bug
> +	local version
> +
> +	# Pick out the cycle from the tracking bug file.
> +	if [ -f "$DEBIAN/tracking-bug" ]; then
> +		read tracking_bug sru_cycle X <"$DEBIAN/tracking-bug"
> +	fi
> +
> +	if [ -z "$sru_cycle" ]; then
> +		echo "$0: sru-cycle not found via debian/tracking-bug; specify --sru-cycle" 1>&2
> +		exit 1
> +	fi
> +
> +	sru_cycle=$(echo "$sru_cycle" | sed -e 's/-[0-9][0-9]*$//' -e 's/^kernel-sru-cycle-//')
> +
> +	#echo "default_sru_cycle: version<$version> sru_cycle<$sru_cycle>"
> +}
> +
> +# Determine where our changelog is.
> +DEBIAN=debian
> +[ -f 'debian/debian.env' ] && . 'debian/debian.env'
> +
> +[ -z "$sru_cycle" ] && default_sru_cycle
> +if [ -z "$remote_repo" ]; then
> +	case "$sru_cycle" in
> +	s[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9])
> +		remote_repo='security' ;;
> +	*)
> +		remote_repo='main' ;;
> +	esac
> +fi
> +case "$remote_repo" in
> +security)
> +	remote_repo='ssh+git://git.launchpad.net/~canonical-kernel-security-team/canonical-kernel-private/+git/kernel-versions'
> +	remote_name='security'
> +	;;
> +main)
> +	remote_repo='git://git.launchpad.net/~canonical-kernel/+git/kernel-versions'
> +	remote_name='main'
> +	;;
> +*)
> +	remote_name='adhoc'
> +	;;
> +esac
> +
> +#
> +# kernel-versoins repository dkms-version mapping see below for details:
> +#  https://git.launchpad.net/~canonical-kernel/+git/kernel-versions/plain/README
> +#
> +kv_repo="$HOME/.cache/kernel-versions-bare"
> +git_base="$remote_name/$sru_cycle"
> +
> +# Now we know where our repo is and what it called update it.
> +# We maintain "persistent" remotes for main and security, but assume
> +# any manually supplied entries are transient.
> +(
> +	[ ! -d "$kv_repo" ] && mkdir -p "$kv_repo"
> +	cd "$kv_repo" || exit 1
> +	[ ! -f config ] && git init -q --bare
> +	current_url=$(git config "remote.$remote_name.url")
> +	if [ -z "$current_url" ]; then
> +		git remote add "$remote_name" "$remote_repo"
> +	elif [ "$current_url" != "$remote_repo" ]; then
> +		git config "remote.$remote_name.url" "$remote_repo"
> +	fi
> +	git fetch -q -p "$remote_name"
> +) || exit 1
> +
> +cat_file()
> +{
> +	(cd "$kv_repo" && git cat-file "$@") || exit 1
> +}
> +
> +# Determine if we have this cycle.
> +present=$(cat_file -t "$git_base" 2>/dev/null)
> +if [ "$present" = "" ]; then
> +	# If we don't have the cycle in the development cycle then
> +	# fall back to master.
> +	case "$sru_cycle" in
> +	d*)	git_base="$remote_name/master" ;;
> +	*)	echo "$sru_cycle: cycle not found in $remote_repo" 2>&1
> +		exit 1
> +		;;
> +	esac
> +fi
> +
> +# Determine our series and mainline version from our own changelog.
> +our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SDistribution)
> +if [ "$series" = "UNRELEASED" ]; then
> +	our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -c1 -SDistribution)
> +fi
> +our_mainline=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SVersion | sed -e 's/-.*//')
> +
> +# Update rules are complex.  We update development series kernels to the
> +# versions in development.  For stable series we update versions against
> +# the series in which our prime kernel was built.  This is expressed
> +# via the map/dkms-versions namespace.  Attempt to map via our series
> +# and then our mainline-version.
> +
> +# Attempt to map via our series, if that works assume we are development.
> +versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_series" 2>/dev/null)
> +
> +# If we do not yet have a mapping re-map using our mainline version.
> +if [ -z "$versions_path" ]; then
> +	versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_mainline")
> +fi
> +
> +echo "git_base<$git_base> versions_path<$versions_path>"
> +echo "II: grabbing dkms-versions from $sru_cycle $versions_path"
> +
> +cat_file -p "$git_base:$versions_path" >"debian/dkms-versions.new"
> +rc="$?"
> +if [ "$rc" -ne 0 ]; then
> +	echo "$0: unable to download an updated dkms-versions file" 1>&2
> +	exit 1
> +
> +elif [ "$rc" -eq 0 ]; then
> +	mv "debian/dkms-versions.new" "debian/dkms-versions"
> +
> +else
> +	rm -f "debian/dkms-versions.new"
> +fi
> +
> +thing="debian/dkms-versions"
> +if ! git diff --exit-code -- "$thing" >/dev/null; then
> +	git commit -m "UBUNTU: $thing -- update from kernel-versions ($git_base)" \
> +		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
> +		-s -- "$thing"
> +else
> +	echo "$thing: no changes from kernel-versions"
> +fi
> +
> +exit "$rc"
> diff --git a/update-version-dkms b/update-version-dkms
> index d90ce2c85f65..a266fecc06f8 100755
> --- a/update-version-dkms
> +++ b/update-version-dkms
> @@ -1,58 +1,4 @@
>   #!/bin/bash
>   
> -if [ "$#" -ne 1 ]; then
> -	echo "Usage: $0 <pocket>" 1>&2
> -	exit 1
> -fi
> -pocket="$1"
> -
> -case "$pocket" in
> -proposed)			pocket_list="-$pocket -updates -release" ;;
> -updates|security)		pocket_list="-$pocket -release" ;;
> -release)			pocket_list="-release" ;;
> -*)
> -	echo "$0: $pocket: unknown archive pocket" 1>&2
> -	exit 1
> -	;;
> -esac
> -
> -# find our changelog.
> -debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
> -
> -# identify the current series
> -series=$(dpkg-parsechangelog -l"$debian/changelog" -SDistribution)
> -if [ "$series" = "UNRELEASED" ]; then
> -	series=$(dpkg-parsechangelog -l"$debian/changelog" -c1 -o1 -SDistribution)
> -fi
> -
> -# Determine if we have any updates.
> -: >"debian/dkms-versions.new"
> -while read package version remainder
> -do
> -	for pocket_raw in $pocket_list
> -	do
> -		pocket="${pocket_raw#-release}"
> -		read x x pocket_version x <<EOL
> -$(rmadison -a source -s "$series$pocket" $package)
> -EOL
> -		[ "$pocket_version" != '' ] && break
> -	done
> -	if [ "$pocket_version" = '' ]; then
> -		echo "$0: $package: no version found in $pocket_list" 1>&2
> -		exit 1
> -	else
> -		echo "$package: $pocket_version found in $pocket_raw"
> -	fi
> -	if [ "$version" != "$pocket_version" ]; then
> -		echo "$package: updated to $pocket_version"
> -	fi
> -	echo "$package $pocket_version $remainder" | sed -e 's/  *$//' >>"debian/dkms-versions.new"
> -done <"debian/dkms-versions"
> -if ! cmp -s "debian/dkms-versions.new" "debian/dkms-versions"; then
> -	mv -f "debian/dkms-versions.new" "debian/dkms-versions"
> -	git commit -s -m "UBUNTU: update dkms package versions" \
> -		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
> -		"debian/dkms-versions"
> -else
> -	rm -f "debian/dkms-versions.new"
> -fi
> +echo "EE: run update-dkms-versions after link-to-tracker" 1>&2
> +exit 1
>
Andy Whitcroft Sept. 2, 2021, 1:16 p.m. UTC | #3
On Wed, 1 Sept 2021 at 14:42, Stefan Bader <stefan.bader@canonical.com>
wrote:

> On 01.09.21 14:51, Andy Whitcroft wrote:
> > BugLink: https://bugs.launchpad.net/bugs/1928921
>
> This replaces update-versions-dkms with update-dkms-versions. The change
> in name
> is deliberate as the new script must be called at a different stage of the
> crank
> process. (Either continue to explain below or refer to crank documentation)
>

Switch to obtaining the DKMS package versions from the kernel-versions
dataset rather than from the archive.  This allows it to be more
resilient against parallel update of those versions in the archive.

Replace the existing `update-versions-dkms` script with
`update-dkms-versions`.  This change in name is deliberate as the new
script must be called at a different stage of the crank process, it must
follow the `cranky link-tb` stage to obtain the correct versions.  See
the crank documentation for details.


> >
> > Signed-off-by: Andy Whitcroft <apw@canonical.com>
> Acked-by: Stefan Bader <stefan.bader@canonical.com>
> > ---
>
> Assuming this more or less is what I already manually did when preparing
> last cycle:
> - first do link-tb and then
> - use the lrm script to update the versions from the repo instead of the
> archive
>

Exactly that.

-Stefan
>

-apw
diff mbox series

Patch

diff --git a/update-dkms-versions b/update-dkms-versions
new file mode 100755
index 000000000000..11d9db31cd4d
--- /dev/null
+++ b/update-dkms-versions
@@ -0,0 +1,162 @@ 
+#!/bin/bash
+
+remote_repo=''
+sru_cycle=
+while :
+do
+	if [ "$1" = "--remote-repo" ]; then
+		remote_repo="$2"
+		shift 2
+
+	elif [ "$1" = "--sru-cycle" ]; then
+		sru_cycle="$2"
+		shift 2
+
+	else
+		break
+	fi
+done
+if [ "$#" -ne 0 ]; then
+	{
+		echo "Usage: $0 [<options>]"
+		echo "       --remote-repo <url>"
+		echo "       --sru-cycle <cycle>"
+	} 1>&2
+	exit 1
+fi
+
+default_sru_cycle()
+{
+	local tracking_bug
+	local version
+
+	# Pick out the cycle from the tracking bug file.
+	if [ -f "$DEBIAN/tracking-bug" ]; then
+		read tracking_bug sru_cycle X <"$DEBIAN/tracking-bug"
+	fi
+
+	if [ -z "$sru_cycle" ]; then
+		echo "$0: sru-cycle not found via debian/tracking-bug; specify --sru-cycle" 1>&2
+		exit 1
+	fi
+
+	sru_cycle=$(echo "$sru_cycle" | sed -e 's/-[0-9][0-9]*$//' -e 's/^kernel-sru-cycle-//')
+
+	#echo "default_sru_cycle: version<$version> sru_cycle<$sru_cycle>"
+}
+
+# Determine where our changelog is.
+DEBIAN=debian
+[ -f 'debian/debian.env' ] && . 'debian/debian.env'
+
+[ -z "$sru_cycle" ] && default_sru_cycle
+if [ -z "$remote_repo" ]; then
+	case "$sru_cycle" in
+	s[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9])
+		remote_repo='security' ;;
+	*)
+		remote_repo='main' ;;
+	esac
+fi
+case "$remote_repo" in
+security)
+	remote_repo='ssh+git://git.launchpad.net/~canonical-kernel-security-team/canonical-kernel-private/+git/kernel-versions'
+	remote_name='security'
+	;;
+main)
+	remote_repo='git://git.launchpad.net/~canonical-kernel/+git/kernel-versions'
+	remote_name='main'
+	;;
+*)
+	remote_name='adhoc'
+	;;
+esac
+
+#
+# kernel-versoins repository dkms-version mapping see below for details:
+#  https://git.launchpad.net/~canonical-kernel/+git/kernel-versions/plain/README
+#
+kv_repo="$HOME/.cache/kernel-versions-bare"
+git_base="$remote_name/$sru_cycle"
+
+# Now we know where our repo is and what it called update it.
+# We maintain "persistent" remotes for main and security, but assume
+# any manually supplied entries are transient.
+(
+	[ ! -d "$kv_repo" ] && mkdir -p "$kv_repo"
+	cd "$kv_repo" || exit 1
+	[ ! -f config ] && git init -q --bare
+	current_url=$(git config "remote.$remote_name.url")
+	if [ -z "$current_url" ]; then
+		git remote add "$remote_name" "$remote_repo"
+	elif [ "$current_url" != "$remote_repo" ]; then
+		git config "remote.$remote_name.url" "$remote_repo"
+	fi
+	git fetch -q -p "$remote_name"
+) || exit 1
+
+cat_file()
+{
+	(cd "$kv_repo" && git cat-file "$@") || exit 1
+}
+
+# Determine if we have this cycle.
+present=$(cat_file -t "$git_base" 2>/dev/null)
+if [ "$present" = "" ]; then
+	# If we don't have the cycle in the development cycle then
+	# fall back to master.
+	case "$sru_cycle" in
+	d*)	git_base="$remote_name/master" ;;
+	*)	echo "$sru_cycle: cycle not found in $remote_repo" 2>&1
+		exit 1
+		;;
+	esac
+fi
+
+# Determine our series and mainline version from our own changelog.
+our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SDistribution)
+if [ "$series" = "UNRELEASED" ]; then
+	our_series=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -c1 -SDistribution)
+fi
+our_mainline=$(LC_ALL=C dpkg-parsechangelog -l"$DEBIAN/changelog" -SVersion | sed -e 's/-.*//')
+
+# Update rules are complex.  We update development series kernels to the
+# versions in development.  For stable series we update versions against
+# the series in which our prime kernel was built.  This is expressed
+# via the map/dkms-versions namespace.  Attempt to map via our series
+# and then our mainline-version.
+
+# Attempt to map via our series, if that works assume we are development.
+versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_series" 2>/dev/null)
+
+# If we do not yet have a mapping re-map using our mainline version.
+if [ -z "$versions_path" ]; then
+	versions_path=$(cat_file -p "$git_base:map/dkms-versions/$our_mainline")
+fi
+
+echo "git_base<$git_base> versions_path<$versions_path>"
+echo "II: grabbing dkms-versions from $sru_cycle $versions_path"
+
+cat_file -p "$git_base:$versions_path" >"debian/dkms-versions.new"
+rc="$?"
+if [ "$rc" -ne 0 ]; then
+	echo "$0: unable to download an updated dkms-versions file" 1>&2
+	exit 1
+
+elif [ "$rc" -eq 0 ]; then
+	mv "debian/dkms-versions.new" "debian/dkms-versions"
+
+else
+	rm -f "debian/dkms-versions.new"
+fi
+
+thing="debian/dkms-versions"
+if ! git diff --exit-code -- "$thing" >/dev/null; then
+	git commit -m "UBUNTU: $thing -- update from kernel-versions ($git_base)" \
+		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
+		-s -- "$thing"
+else
+	echo "$thing: no changes from kernel-versions"
+fi
+
+exit "$rc"
diff --git a/update-version-dkms b/update-version-dkms
index d90ce2c85f65..a266fecc06f8 100755
--- a/update-version-dkms
+++ b/update-version-dkms
@@ -1,58 +1,4 @@ 
 #!/bin/bash
 
-if [ "$#" -ne 1 ]; then
-	echo "Usage: $0 <pocket>" 1>&2
-	exit 1
-fi
-pocket="$1"
-
-case "$pocket" in
-proposed)			pocket_list="-$pocket -updates -release" ;;
-updates|security)		pocket_list="-$pocket -release" ;;
-release)			pocket_list="-release" ;;
-*)
-	echo "$0: $pocket: unknown archive pocket" 1>&2
-	exit 1
-	;;
-esac
-
-# find our changelog.
-debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
-
-# identify the current series
-series=$(dpkg-parsechangelog -l"$debian/changelog" -SDistribution)
-if [ "$series" = "UNRELEASED" ]; then
-	series=$(dpkg-parsechangelog -l"$debian/changelog" -c1 -o1 -SDistribution)
-fi
-
-# Determine if we have any updates.
-: >"debian/dkms-versions.new"
-while read package version remainder
-do
-	for pocket_raw in $pocket_list
-	do
-		pocket="${pocket_raw#-release}"
-		read x x pocket_version x <<EOL
-$(rmadison -a source -s "$series$pocket" $package)
-EOL
-		[ "$pocket_version" != '' ] && break
-	done
-	if [ "$pocket_version" = '' ]; then
-		echo "$0: $package: no version found in $pocket_list" 1>&2
-		exit 1
-	else
-		echo "$package: $pocket_version found in $pocket_raw"
-	fi
-	if [ "$version" != "$pocket_version" ]; then
-		echo "$package: updated to $pocket_version"
-	fi
-	echo "$package $pocket_version $remainder" | sed -e 's/  *$//' >>"debian/dkms-versions.new"
-done <"debian/dkms-versions"
-if ! cmp -s "debian/dkms-versions.new" "debian/dkms-versions"; then
-	mv -f "debian/dkms-versions.new" "debian/dkms-versions"
-	git commit -s -m "UBUNTU: update dkms package versions" \
-		-m "BugLink: https://bugs.launchpad.net/bugs/1786013" \
-		"debian/dkms-versions"
-else
-	rm -f "debian/dkms-versions.new"
-fi
+echo "EE: run update-dkms-versions after link-to-tracker" 1>&2
+exit 1