diff mbox series

[1/2] UBUNTU: [Packaging] Add update-version-dkms

Message ID 20190717104126.11330-2-stefan.bader@canonical.com
State New
Headers show
Series Additions to pull-request | expand

Commit Message

Stefan Bader July 17, 2019, 10:41 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1834479

This script is used to update debian/dkms-versions according
to versions in a given pocket. Copied directly from Disco.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 update-version-dkms | 56 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100755 update-version-dkms
diff mbox series

Patch

diff --git a/update-version-dkms b/update-version-dkms
new file mode 100755
index 000000000000..a0aba917ad63
--- /dev/null
+++ b/update-version-dkms
@@ -0,0 +1,56 @@ 
+#!/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
+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" >>"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 -a -s -m "UBUNTU: update dkms package versions"
+else
+	rm -f "debian/dkms-versions.new"
+fi