summaryrefslogtreecommitdiff
path: root/dh_installmenu
blob: 2f7320904fca10900291b22f1e84335269b96855 (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
#!/usr/bin/perl -w
#
# Integration with debian menu system:
#
# If debian/menu file exists, save it to $tmp/usr/lib/menu/$package
# If debian/menu-method file exists, save it to 
# $tmp/etc/menu-methods/$package
#
# Also, add to postinst and postrm.

use strict;
use Debian::Debhelper::Dh_Lib;
init();

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	my $menu=pkgfile($package,"menu");
	my $menu_method=pkgfile($package,"menu-method");
	
	if ($menu ne '') {
		if (! -d "$tmp/usr/lib/menu") {
			doit("install","-d","$tmp/usr/lib/menu");
		}
		doit("install","-p","-m644",$menu,"$tmp/usr/lib/menu/$package");
		
		# Add the scripts if a menu-method file doesn't exist.
		# The scripts for menu-method handle everything these do, too.
		if ($menu_method eq "" && ! $dh{NOSCRIPTS}) {
			autoscript($package,"postinst","postinst-menu");
			autoscript($package,"postrm","postrm-menu")
		}
	}

	if ($menu_method ne '') {
		if (!-d "$tmp/etc/menu-methods") {
			doit("install","-d","$tmp/etc/menu-methods");
		}
		doit("install","-p",$menu_method,"$tmp/etc/menu-methods/$package");

		if (! $dh{NOSCRIPTS}) {
			autoscript($package,"postinst","postinst-menu-method","s/#PACKAGE#/$package/");
			autoscript($package,"postrm","postrm-menu-method","s/#PACKAGE#/$package/");
		}
	}
}