@@ -113,7 +113,7 @@ printchanges:
$(DROOT)/scripts/misc/git-ubuntu-log $(ubuntu_log_opts)
insertchanges: autoreconstruct finalchecks
- @perl -w -f $(DROOT)/scripts/misc/insert-changes.pl $(DROOT) $(DEBIAN)
+ $(DROOT)/scripts/misc/insert-changes $(DROOT) $(DEBIAN)
autoreconstruct:
# No need for reconstruct for -rc kernels since we don't upload an
new file mode 100755
@@ -0,0 +1,42 @@
+#!/usr/bin/python3
+
+import os
+import sys
+
+from subprocess import check_output
+
+droot = 'debian'
+if len(sys.argv) > 1:
+ droot = sys.argv[1]
+
+debian = 'debian.master'
+if len(sys.argv) > 2:
+ debian = sys.argv[2]
+
+rules = os.path.join(droot, 'rules')
+changelog = os.path.join(debian, 'changelog')
+changelog_new = os.path.join(debian, 'changelog.new')
+
+# Generate the list of new changes
+changes = check_output(['make', '-s', '-f', rules, 'printchanges']).decode('UTF-8')
+
+# Insert the new changes into the changelog
+with open(changelog) as orig, open(changelog_new, 'w') as new:
+ printed = False
+ skip_newline = False
+ for line in orig:
+ if line.startswith(' CHANGELOG: '):
+ if not printed:
+ printed = True
+ if changes == '':
+ skip_newline = True
+ continue
+ new.write(changes)
+ else:
+ if skip_newline and line.strip() == '':
+ skip_newline = False
+ continue
+ new.write(line)
+
+# Replace the original changelog with the new one
+os.rename(changelog_new, changelog)
deleted file mode 100755
@@ -1,43 +0,0 @@
-#!/usr/bin/perl -w
-
-my $debian;
-$droot = $ARGV[0] if (defined $ARGV[0]);
-$droot = 'debian' if (!defined $droot);
-$debian = $ARGV[1] if (defined $ARGV[1]);
-$debian = 'debian.master' if (!defined $debian);
-
-system("make -s -f $droot/rules printchanges > $debian/changes");
-
-open(CHANGELOG, "< $debian/changelog") or die "Cannot open changelog";
-open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
-open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
-
-$printed = 0;
-my $skip_newline = 0;
-
-while (<CHANGELOG>) {
- if (/^ CHANGELOG: /) {
- next if $printed;
-
- $skip_newline = 1;
- while (<CHANGES>) {
- $skip_newline = 0;
- print NEW;
- }
-
- $printed = 1;
- } else {
- if (/^$/ && $skip_newline == 1) {
- $skip_newline = 0;
- next;
- }
- print NEW;
- }
-}
-
-close(NEW);
-close(CHANGES);
-close(CHANGELOG);
-
-rename("$debian/changelog.new", "$debian/changelog");
-unlink("$debian/changes");
Rewrite the insert-changes.pl script in Python to get us one step closer to dropping Perl as an Ubuntu kernel build dependency. Signed-off-by: Juerg Haefliger <juergh@canonical.com> --- v1 -> v2: - Fix default value of 'debian' variable - Add missing 'skip_newline' flag debian/rules.d/1-maintainer.mk | 2 +- debian/scripts/misc/insert-changes | 42 ++++++++++++++++++++++++++ debian/scripts/misc/insert-changes.pl | 43 --------------------------- 3 files changed, 43 insertions(+), 44 deletions(-) create mode 100755 debian/scripts/misc/insert-changes delete mode 100755 debian/scripts/misc/insert-changes.pl