summaryrefslogtreecommitdiff
path: root/dh_gconf
blob: 8c30de7326f4f4cb42fee40ea44396629ce85ef8 (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
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
#!/usr/bin/perl -w

=head1 NAME

dh_gconf - generate GConf schema registration scripts

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_gconf> [S<I<debhelper options>>] [B<--priority=<number>>]

=head1 DESCRIPTION

dh_gconf is a debhelper program that is responsible for registering
GConf schemas.

It automatically generates the postinst and prerm fragments needed
to register and unregister the schemas in usr/share/gconf/schemas, using
gconf-schemas.

If a file named debian/package.gconf-defaults exists, then it is
installed into usr/share/gconf/defaults/10_package in the package build
directory, with "package" replaced by the package name. Some postinst and
postrm fragments will be generated to launch update-gconf-defaults.

If a file named debian/package.gconf-mandatory exists, then it is
installed into usr/share/gconf/mandatory/10_package in the package build
directory, with "package" replaced by the package name, and similar
postinst and postrm fragments will be generated.

The gconf-schemas and update-gconf-defaults scripts are provided by the
gconf2 package. An appropriate dependency will be generated in
${misc:Depends}.

=head1 OPTIONS

=over 4

=item B<--priority> I<priority>

Use I<priority> (which should be a 2-digit number) as the defaults
priority instead of 10. Higher values than ten can be used by 
derived distributions (20), CDD distributions (50), or site-specific
packages (90).

=back

=cut

init();

my $priority=10;
if (defined $dh{PRIORITY}) {
	$priority=$dh{PRIORITY};
}

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	
	my $gconf_dep = 0;
	my $mandatory = pkgfile($package, "gconf-mandatory");
	if ($mandatory ne '') {
		doit("mkdir","-p","$tmp/usr/share/gconf/mandatory");
		doit("install","-p","-m644",$mandatory,"$tmp/usr/share/gconf/mandatory/${priority}_$package");
		autoscript($package,"postinst","postinst-gconf-defaults","s%#OPT#%--mandatory%");
		autoscript($package,"postrm","postrm-gconf-defaults","s%#OPT#%--mandatory%");
		addsubstvar($package, "misc:Depends", "gconf2 (>= 2.24.0-5)");
		$gconf_dep = 1;
	}
	my $defaults = pkgfile($package,"gconf-defaults");
	if ($defaults ne '') {
		doit("mkdir","-p","$tmp/usr/share/gconf/defaults");
		doit("install","-p","-m644",$defaults,"$tmp/usr/share/gconf/defaults/${priority}_$package");
		autoscript($package,"postinst","postinst-gconf-defaults","s%#OPT#%%");
		autoscript($package,"postrm","postrm-gconf-defaults","s%#OPT#%%");
		addsubstvar($package, "misc:Depends", "gconf2 (>= 2.12.1-1)") unless $gconf_dep;
		$gconf_dep = 1;
	}

	my $old_schemas_dir = "$tmp/etc/gconf/schemas";
	my $new_schemas_dir = "$tmp/usr/share/gconf/schemas";

	# Migrate schemas from /etc/gconf/schemas to /usr/share/gconf/schemas
	if (-d $old_schemas_dir) {
		doit("mkdir -p $new_schemas_dir") unless -d $new_schemas_dir;
		doit("mv $old_schemas_dir/*.schemas $new_schemas_dir/");
		doit("rmdir -p --ignore-fail-on-non-empty $old_schemas_dir");
	}

	if (-d "$new_schemas_dir") {
		# Get a list of the schemas
		my $schemas = `find $new_schemas_dir -type f -name \\*.schemas -printf '%P '`;
		if ($schemas ne '') {
			autoscript($package,"postinst","postinst-gconf","s%#SCHEMAS#%$schemas%");
			autoscript($package,"prerm","prerm-gconf","s%#SCHEMAS#%$schemas%");
			autoscript($package,"postrm","postrm-gconf","s%#SCHEMAS#%$schemas%");
			addsubstvar($package, "misc:Depends", "gconf2 (>= 2.10.1-2)") unless $gconf_dep;
		}
	}
}

=head1 SEE ALSO

L<debhelper(7)>

This program is a part of debhelper.

=head1 AUTHOR

Ross Burton <ross@burtonini.com>
Josselin Mouette <joss@debian.org>

=cut