summaryrefslogtreecommitdiff
path: root/dh_installmenu
blob: c077f21583991547577963e46c04e9b264d21c13 (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.

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

foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
	$TMP=tmpdir($PACKAGE);
	$menu=pkgfile($PACKAGE,"menu");
	$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/");
		}
	}
}