summaryrefslogtreecommitdiff
path: root/dh_installchangelogs
blob: 3ebb04ec1920984405f1b8805621b295c288c508 (plain)
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
#!/usr/bin/perl -w
#
# Installs debian/changelog. If another filename is passed to it, installs
# that file as the upstream changelog.
#
# Looks at debian/control to determine if this is a native debian package,
# if so, the debian changelog is just installed as "changelog", and it is an 
# error to specify an upstream changelog on the command line.

BEGIN { push @INC, "debian", "/usr/share/debhelper" }
use Dh_Lib;
init();

$upstream=shift;

if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
	error("Cannot specify an upstream changelog for a native debian package.");
}

if (isnative($dh{MAINPACKAGE})) {
	$changelog_name='changelog';
}
else {
	$changelog_name='changelog.Debian';
}

foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
	$TMP=tmpdir($PACKAGE);
	$changelog=pkgfile($PACKAGE,"changelog");

	if (!$changelog) {
		$changelog="debian/changelog";
	}

	if (! -e $changelog) {
		error("could not find changelog $changelog");
	}

	if (! -d "$TMP/usr/doc/$PACKAGE") {
		doit("install","-d","$TMP/usr/doc/$PACKAGE");
	}
	doit("install","-o","root","-g","root","-p","-m644",$changelog,
		"$TMP/usr/doc/$PACKAGE/$changelog_name");

	if ($upstream) {
		if ($upstream=~m/\.html?$/i) {
			# HTML changelog
			doit("install","-o","root","-g","root","-p","-m644",
				$upstream,"$TMP/usr/doc/$PACKAGE/changelog.html");
			doit("ln", "-sf", 'changelog.html',
				"$TMP/usr/doc/$PACKAGE/changelog");
		}
		else {
			doit("install","-o","root","-g","root","-p","-m644",
				$upstream,"$TMP/usr/doc/$PACKAGE/changelog");
		}
		if ($dh{K_FLAG}) {
			# Install symlink to original name of the upstream changelog file.
			# Use basename in case original file was in a subdirectory or something.
			doit("ln","-sf","changelog","$TMP/usr/doc/$PACKAGE/".Dh_Lib::basename($upstream));
		}
	}
}