]> git.donarmstrong.com Git - debhelper.git/blob - dh_gconf
r1844: merge python and gconf changes from python-support
[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<-p<package>>]
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. The
29 syntax of this file consists of lines containing the key name, some
30 white space, and the key value, which can be an integer, a boolean, a
31 float, a string or a list of strings. Example:
32
33   /apps/myprogram/frob_number   42
34   /apps/myprogram/do_foo        true
35   /apps/myprogram/priority      1.25
36   /apps/myprogram/name          "Gotcha !"
37   /apps/myprogram/names         [Ha ha!,Let's keep serious,Ho ho!]
38
39 The gconf-schemas and update-gconf-defaults scripts are provided by the
40 gconf2 package. An appropriate dependency will be generated in
41 ${misc:Depends}.
42
43 =head1 OPTIONS
44
45 =over 4
46
47 =item B<--priority> I<priority>
48
49 Use I<priority> (which should be a 2-digit number) as the defaults
50 priority instead of 10. Children distributions are encouraged to use 20
51 for their branding, CDD distributions to use 50, and site-specific
52 packages should use 90 or more.
53
54 =cut
55
56 init();
57
58 my $priority=10;
59 if (defined $dh{PRIORITY}) {
60         $priority=$dh{PRIORITY};
61 }
62
63 foreach my $package (@{$dh{DOPACKAGES}}) {
64         my $tmp=tmpdir($package);
65         
66         my $gconf_dep = 0;
67         my $defaults = pkgfile($package,"gconf-defaults");
68         if ($defaults ne '') {
69                 doit("mkdir","-p","$tmp/usr/share/gconf/defaults");
70                 doit("install","-p","-m644",$defaults,"$tmp/usr/share/gconf/defaults/${priority}_$package");
71                 autoscript($package,"postinst","postinst-gconf-defaults");
72                 autoscript($package,"postrm","postrm-gconf-defaults");
73                 addsubstvar($package, "misc:Depends", "gconf2 (>= 2.12.1-1)");
74                 $gconf_dep = 1;
75         }
76
77         my $old_schemas_dir = "$tmp/etc/gconf/schemas";
78         my $new_schemas_dir = "$tmp/usr/share/gconf/schemas";
79
80         # Migrate schemas from /etc/gconf/schemas to /usr/share/gconf/schemas
81         if (-d $old_schemas_dir) {
82                 doit("mkdir -p $new_schemas_dir") unless -d $new_schemas_dir;
83                 doit("mv $old_schemas_dir/*.schemas $new_schemas_dir/");
84                 doit("rmdir -p --ignore-fail-on-non-empty $old_schemas_dir");
85         }
86
87         if (-d "$new_schemas_dir") {
88                 # Get a list of the schemas
89                 my $schemas = `find $new_schemas_dir -type f -name \\*.schemas -printf '%P '`;
90                 if ($schemas ne '') {
91                         autoscript($package,"postinst","postinst-gconf","s%#SCHEMAS#%$schemas%");
92                         autoscript($package,"prerm","prerm-gconf","s%#SCHEMAS#%$schemas%");
93                         autoscript($package,"postrm","postrm-gconf","s%#SCHEMAS#%$schemas%");
94                         addsubstvar($package, "misc:Depends", "gconf2 (>= 2.10.1-2)") unless $gconf_dep;
95                 }
96         }
97 }
98
99 =head1 SEE ALSO
100
101 L<debhelper(7)>
102
103 This program is a part of debhelper.
104
105 =head1 AUTHOR
106
107 Ross Burton <ross@burtonini.com>
108 Josselin Mouette <joss@debian.org>
109
110 =cut