[1/3] UBUNTU: (buildenv) Add insert-ubuntu-changes

Submitted by Stefan Bader on March 19, 2010, 10:45 a.m.

Details

Message ID 1268995541-12057-2-git-send-email-stefan.bader@canonical.com
State Accepted
Delegated to: Stefan Bader
Headers show

Commit Message

Stefan Bader March 19, 2010, 10:45 a.m.
Usage: ./debian/scripts/misc/insert-ubuntu-changes <changelog> <orev> <nrev>

where changelog is the changelog to be modified (needs to be in UNRELEASED
state), orev is the the revision number from which to start looking for
changes and nrev is the revision number where to stop.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 debian/scripts/misc/insert-ubuntu-changes |   57 +++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100755 debian/scripts/misc/insert-ubuntu-changes

Patch hide | download patch | download mbox

diff --git a/debian/scripts/misc/insert-ubuntu-changes b/debian/scripts/misc/insert-ubuntu-changes
new file mode 100755
index 0000000..0d97ec4
--- /dev/null
+++ b/debian/scripts/misc/insert-ubuntu-changes
@@ -0,0 +1,57 @@ 
+#!/usr/bin/perl
+
+if ($#ARGV != 2) {
+	die "Usage: $0 <changelog> <stop at> <start at>\n";
+}
+my ($changelog, $end, $start) = @ARGV;
+
+$end =~ s/.*\.//;
+$start =~ s/.*\.//;
+
+my @changes = ();
+my $output = 0;
+open(CHG, "git show master:debian/changelog|") ||
+	die "$0: master:debian/changelog: open failed - $!\n";
+while (<CHG>) {
+	if (/^\S+\s+\((.*\.(\d+))\)/) {
+		if ($2 <= $end) {
+			last;
+		}
+		if ($2 == $start) {
+			$output = 1;
+		}
+		if ($output) {
+			push(@changes, "\n  [ Ubuntu: $1 ]\n\n");
+			next;
+		}
+	}
+	next if ($output == 0);
+
+	next if (/^\s*$/);
+	next if (/^\s--/);
+	next if (/^\s\s[^\*\s]/);
+
+	push(@changes, $_);
+}
+close(CHG);
+
+open(CHANGELOG, "< $changelog") or die "Cannot open changelog";
+open(NEW, "> $changelog.new") or die "Cannot open new changelog";
+
+$printed = 3;
+while (<CHANGELOG>) {
+	if (/^  CHANGELOG: /) {
+		$printed--;
+		print NEW;
+		if ($printed == 0) {
+			print NEW @changes;
+		}
+		next;
+	}
+	print NEW;
+}
+
+close(NEW);
+close(CHANGELOG);
+
+rename("$changelog.new", "$changelog");