#!/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. use strict; use Debian::Debhelper::Dh_Lib; init(); my $upstream=shift; if (isnative($dh{MAINPACKAGE}) && defined $upstream) { error("Cannot specify an upstream changelog for a native debian package."); } my $changelog_name="changelog.Debian"; if (isnative($dh{MAINPACKAGE})) { $changelog_name='changelog'; } foreach my $package (@{$dh{DOPACKAGES}}) { my $tmp=tmpdir($package); my $changelog=pkgfile($package,"changelog"); if (!$changelog) { $changelog="debian/changelog"; } if (! -e $changelog) { error("could not find changelog $changelog"); } if (! -d "$tmp/usr/share/doc/$package") { # If it is a dangling symlink, then don't do anything. # Think multi-binary packages that depend on each other and # want to link doc dirs. next if -l "$tmp/usr/share/doc/$package"; doit("install","-d","$tmp/usr/share/doc/$package"); } doit("install","-o",0,"-g",0,"-p","-m644",$changelog, "$tmp/usr/share/doc/$package/$changelog_name"); if ($upstream) { my $link_to; if ($upstream=~m/\.html?$/i) { # HTML changelog doit("install","-o",0,"-g",0,"-p","-m644", $upstream,"$tmp/usr/share/doc/$package/changelog.html"); complex_doit("lynx -dump $upstream > $tmp/usr/share/doc/$package/changelog"); $link_to='changelog.html'; } else { doit("install","-o",0,"-g",0,"-p","-m644", $upstream,"$tmp/usr/share/doc/$package/changelog"); $link_to='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",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream)); } } }