Import python3 gendef.py from upstream, remove python2.7 dependency, add python3

Change-Id: Iecce11eee16c9589d6a498cac6d2764ec59b200c
diff --git a/debian/control b/debian/control
index 923244a..d091dd9 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@
                gcc-aarch64-linux-gnu,
                kmod,
                libssl-dev,
-               python
+               python3
 Section: misc
 Priority: optional
 Standards-Version: 3.9.8
diff --git a/debian/rules.d/scripts/mod/Makefile b/debian/rules.d/scripts/mod/Makefile
index e57e262..35bf77c 100644
--- a/debian/rules.d/scripts/mod/Makefile
+++ b/debian/rules.d/scripts/mod/Makefile
@@ -16,7 +16,7 @@
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 modpost-opts.h: $(top_srcdir)/scripts/mod/modpost.c
-	python $(wrapperdir)/gendef.py $< > $@
+	$(wrapperdir)/gendef.py $< > $@
 
 modpost.o: modpost.c modpost-opts.h
 	$(CC) $(CFLAGS) -I $(CURDIR) -c -o $@ $<
diff --git a/debian/rules.d/scripts/mod/gendef.py b/debian/rules.d/scripts/mod/gendef.py
index 6e1bdf4..55d3fc6 100755
--- a/debian/rules.d/scripts/mod/gendef.py
+++ b/debian/rules.d/scripts/mod/gendef.py
@@ -1,20 +1,20 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 import re
 import sys
 
 for line in open(sys.argv[1]):
-    match = re.search('getopt\(argc, argv, "([\w:]*?)"\)', line)
+    match = re.search(r'getopt\(argc, argv, "([\w:]*?)"\)', line)
     if match:
         options = match.group(1)
         break
 else:
     raise RuntimeError
 
-print '#define GETOPT_OPTIONS "%s"' % options
+print('#define GETOPT_OPTIONS "%s"' % options)
 
-print '#define GETOPT_CASE',
+print('#define GETOPT_CASE', end=' ')
 for c in options:
     if c == ':' or c == 'T':
         continue
-    print "case '%c':" % c,
-print
+    print("case '%c':" % c, end=' ')
+print()