]> git.donarmstrong.com Git - debhelper.git/blob - dh_gconf
Merge branch 'dh_overrides'
[debhelper.git] / dh_gconf
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_gconf - generate GConf schema registration scripts
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_gconf> [S<I<debhelper options>>] [B<--priority=<number>>]
15
16 =head1 DESCRIPTION
17
18 dh_gconf is a debhelper program that is responsible for registering
19 GConf schemas.
20
21 It automatically generates the postinst and prerm fragments needed
22 to register and unregister the schemas in usr/share/gconf/schemas, using
23 gconf-schemas.
24
25 If a file named debian/package.gconf-defaults exists, then it is
26 installed into usr/share/gconf/defaults/10_package in the package build
27 directory, with "package" replaced by the package name. Some postinst and
28 postrm fragments will be generated to launch update-gconf-defaults.
29
30 If a file named debian/package.gconf-mandatory exists, then it is
31 installed into usr/share/gconf/mandatory/10_package in the package build
32 directory, with "package" replaced by the package name, and similar
33 postinst and postrm fragments will be generated.
34
35 The gconf-schemas and update-gconf-defaults scripts are provided by the
36 gconf2 package. An appropriate dependency will be generated in
37 ${misc:Depends}.
38
39 =head1 OPTIONS
40
41 =over 4
42
43 =item B<--priority> I<priority>
44
45 Use I<priority> (which should be a 2-digit number) as the defaults
46 priority instead of 10. Higher values than ten can be used by 
47 derived distributions (20), CDD distributions (50), or site-specific
48 packages (90).
49
50 =back
51
52 =cut
53
54 init();
55
56 my $priority=10;
57 if (defined $dh{PRIORITY}) {
58         $priority=$dh{PRIORITY};
59 }
60
61 foreach my $package (@{$dh{DOPACKAGES}}) {
62         my $tmp=tmpdir($package);
63         
64         my $gconf_dep = 0;
65         my $mandatory = pkgfile($package, "gconf-mandatory");
66         if ($mandatory ne '') {
67                 doit("mkdir","-p","$tmp/usr/share/gconf/mandatory");
68                 doit("install","-p","-m644",$mandatory,"$tmp/usr/share/gconf/mandatory/${priority}_$package");
69                 autoscript($package,"postinst","postinst-gconf-defaults","s%#OPT#%--mandatory%");
70                 autoscript($package,"postrm","postrm-gconf-defaults","s%#OPT#%--mandatory%");
71                 addsubstvar($package, "misc:Depends", "gconf2 (>= 2.24.0-5)");
72                 $gconf_dep = 1;
73         }
74         my $defaults = pkgfile($package,"gconf-defaults");
75         if ($defaults ne '') {
76                 doit("mkdir","-p","$tmp/usr/share/gconf/defaults");
77                 doit("install","-p","-m644",$defaults,"$tmp/usr/share/gconf/defaults/${priority}_$package");
78                 autoscript($package,"postinst","postinst-gconf-defaults","s%#OPT#%%");
79                 autoscript($package,"postrm","postrm-gconf-defaults","s%#OPT#%%");
80                 addsubstvar($package, "misc:Depends", "gconf2 (>= 2.12.1-1)") unless $gconf_dep;
81                 $gconf_dep = 1;
82         }
83
84         my $old_schemas_dir = "$tmp/etc/gconf/schemas";
85         my $new_schemas_dir = "$tmp/usr/share/gconf/schemas";
86
87         # Migrate schemas from /etc/gconf/schemas to /usr/share/gconf/schemas
88         if (-d $old_schemas_dir) {
89                 doit("mkdir -p $new_schemas_dir") unless -d $new_schemas_dir;
90                 doit("mv $old_schemas_dir/*.schemas $new_schemas_dir/");
91                 doit("rmdir -p --ignore-fail-on-non-empty $old_schemas_dir");
92         }
93
94         if (-d "$new_schemas_dir") {
95                 # Get a list of the schemas
96                 my $schemas = `find $new_schemas_dir -type f -name \\*.schemas -printf '%P '`;
97                 if ($schemas ne '') {
98                         autoscript($package,"postinst","postinst-gconf","s%#SCHEMAS#%$schemas%");
99                         autoscript($package,"prerm","prerm-gconf","s%#SCHEMAS#%$schemas%");
100                         autoscript($package,"postrm","postrm-gconf","s%#SCHEMAS#%$schemas%");
101                         addsubstvar($package, "misc:Depends", "gconf2 (>= 2.10.1-2)") unless $gconf_dep;
102                 }
103         }
104 }
105
106 =head1 SEE ALSO
107
108 L<debhelper(7)>
109
110 This program is a part of debhelper.
111
112 =head1 AUTHOR
113
114 Ross Burton <ross@burtonini.com>
115 Josselin Mouette <joss@debian.org>
116
117 =cut