diff mbox series

[Unstable,v2,4/5] UBUNTU: [Packaging] module-check: Handle previous ABI modules directory

Message ID 20210610080807.25518-5-juergh@canonical.com
State New
Headers show
Series Use modinfo data for the ABI | expand

Commit Message

Juerg Haefliger June 10, 2021, 8:08 a.m. UTC
Handle the modules directory of the previous ABI. We still need to support
the old style single module list until getabis retrieves an updated
buildinfo package.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 debian/scripts/module-check | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/debian/scripts/module-check b/debian/scripts/module-check
index 2e31045f834f..1045da4e3e65 100755
--- a/debian/scripts/module-check
+++ b/debian/scripts/module-check
@@ -13,8 +13,8 @@  if (-f "$prev_abidir/ignore.modules"
 	exit(0);
 }
 
-if (not -d "$abidir/$flavour.modules" or not -f
-    "$prev_abidir/$flavour.modules") {
+if (not -d "$abidir/$flavour.modules" or
+    not -e "$prev_abidir/$flavour.modules") {
 	print "previous or current modules file/directory missing!\n";
 	print "   $abidir/$flavour.modules\n";
 	print "   $prev_abidir/$flavour.modules\n";
@@ -66,10 +66,18 @@  print "read $new_count modules.\n";
 # Now the old modules, checking for missing ones
 print "   reading old modules...";
 $old_count = 0;
-open(OLD, "< $prev_abidir/$flavour.modules") or
-	die "Could not open $prev_abidir/$flavour.modules";
-while (<OLD>) {
+if (-d "$prev_abidir/$flavour.modules") {
+	opendir(OLD, "$prev_abidir/$flavour.modules") or
+		die "Could not open directory $prev_abidir/$flavour.modules";
+	@old = readdir OLD;
+} else {
+	open(OLD, "< $prev_abidir/$flavour.modules") or
+		die "Could not open $prev_abidir/$flavour.modules";
+	@old = <OLD>;
+}
+for (@old) {
 	chomp;
+	next if /^\./;  # Ignore '.' and '..'
 	if (not defined($modules{$_})) {
 		print "\n" if not $missing;
 		$missing++;