File: debchange

package info (click to toggle)
devscripts 1.8.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 232 kB
  • ctags: 15
  • sloc: sh: 553; perl: 150; ansic: 108; makefile: 46
file content (123 lines) | stat: -rwxr-xr-x 3,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl

# debchange : update the debian changelog using your favorite visual editor
# Options:
# -n generate a new changelog bumping up the release number
#    otherwise add entry to existing changelog section.
# Christoph Lameter <clameter@debian.org>

$VISUAL=$ENV{"VISUAL"};

if (!$VISUAL) {
        $VISUAL=$ENV{"EDITOR"};
        if (!$VISUAL) {
		if ( -x "/usr/bin/joe" ) {
			$VISUAL="joe";
		} else {
			$VISUAL="ae";
		}
	}
}

# Look for the debian changelog
until (-e "debian/changelog")
{
	chdir "..";
	if (`pwd` eq "/\n")
	{
		print "Cannot find a changelog to edit anywhere\n";
		exit(1);
	}
}

($basename=$0) =~ s|.*/||;
die "debian/changelog.dch already exists; please move before running $basename.\n" if ( -e "debian/changelog.dch" );

system("cp debian/changelog debian/changelog.dch");

if ($?) { die "Cannot copy changelog\n"; }


if ($ARGV[0] eq "-n" || -f "debian/RELEASED" || $ARGV[0] eq "-v")
{
	if ($ARGV[0] eq "-n") {
		shift
	} elsif ($ARGV[0] eq "-v") {
		shift;
		$NEW_VERSION=$ARGV[0];
		shift;
	}
	if (-f "debian/RELEASED") {
		unlink("debian/RELEASED");
	}
	$TEXT="@ARGV";
	$DATE=`822-date`;chop $DATE;
	open(S,"<debian/changelog.dch") || die "Cannot read debian/changelog.dch";
	$_=<S>;
	if (/^(.*) \((.*)-(.*)\) (.*); urgency=(.*)/) {
		($PACKAGE,$VERSION,$RELEASE,$DISTRIB,$URGENT) = ($1,$2,$3,$4,$5);
		$separator="-";
	} elsif  (/^(.*) \((.*)\.(.*)\) (.*); urgency=(.*)/) {
		($PACKAGE,$VERSION,$RELEASE,$DISTRIB,$URGENT) = ($1,$2,$3,$4,$5);
		$separator=".";
	} else {
		die "Header of changelog has bad format\n";
	}
	while (<S>) {
		if (/^ -- (.* .*) <(.*)>  .* [+-][0-9][0-9][0-9][0-9]/) {
			($MAINTAINER,$EMAIL) = ($1,$2);
			last;
		}
	}
	if (!$MAINTAINER) {
		print 'Format error in debian/changelog incorrect "  --" line'."\n";
		exit(1);
	}
	close(S);
	open(O,">debian/changelog");
	if ($NEW_VERSION)
	{ $VERSION=$NEW_VERSION;
          if ($separator eq ".") {
		$RELEASE=0;
	    } else {
		$RELEASE=1;
	    }
	} else {
		$RELEASE++;
	}
	print O "$PACKAGE ($VERSION$separator$RELEASE) unstable; urgency=low\n\n";
	print O "  * ";
	print O $TEXT if ($TEXT);
	print O "\n\n -- $MAINTAINER <$EMAIL>  $DATE\n\n";
	if ($separator eq ".") {
		system "mv `pwd` ../$PACKAGE-$VERSION$separator$RELEASE";
	}
	open (S,"<debian/changelog.dch") || die "Cannot open debian/changelog.dch\n";
} else {
	# This means we just have to generate a new * entry in changelog
	$TEXT="@ARGV";
	open(O,">debian/changelog") || die "Cannot open debian/changelog\n";
	open(S,"<debian/changelog.dch") || die "Cannot open debian/changelog.dch\n";
	# The first two lines stay the same
	if ($_=<S>) { print O; } else { die "No first line in changelog\n"; }
	if ($_=<S>) { print O; } else { die "No second line in changelog\n"; }
	# And the third gets the new entry
	if ($TEXT) {
		print O "  * $TEXT\n";
	} else {
		print O "  * \n";
	}
}

# Copy the rest of the changelog file to new one
while (<S>) { print O; }

close S;
close O;

unlink "debian/changelog.dch";

# Now Run the Editor
if (! $TEXT) {
	exec("$VISUAL +3 debian/changelog");
}