[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

dh_gconf



Hi,

Attached is my first debhelper tool, dh_gconf. It appears to work for
me, and if no-one objects or finds serious issues, I'll ask for it to be
included in the gconf2 package.

To use it, simply call dh_gconf somewhere after 'make install'.  If you
don't want to drop the postinst-gconf file into
/usr/share/debhelper/autoscripts, you can set DH_AUTOSCRIPTDIR.  The
script will find any installed gconf schemas, and generate the relevant
postinst script.

Debhelper rocks.

Regards,
Ross
-- 
Ross Burton                                 mail: ross@burtonini.com
                                           jabber: ross@nerdfest.org
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF
#!/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<-p<package>>]

=head1 DESCRIPTION

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

It automatically generates the postinst script to call gconftool, and
register the schemas which have been installed into
/etc/gconf/schemas.

To use this script, call it in the relevant binary-% target in
debian/rules, and add $(misc:Depends) to your Depends so your packages
require the correct GConf tools.

=cut

# Get the debhelper init groove going.
init();

foreach my $package (@{$dh{DOPACKAGES}}) {
  my $tmp=tmpdir($package);

  # Only run if there have been GConf schemas installed
  if (-d "$tmp/etc/gconf/schemas") {
    # Get a list of the schemas
    my $schemas = `find debian/$package/etc/gconf/schemas -type f -printf '%P '`;
    # If there were some schemas...
    if ($schemas ne '') {
      # Add the postinst script to register the schemas
      autoscript($package,"postinst","postinst-gconf","s%#SCHEMAS#%$schemas%");

      # Add the prerm script to unregister the schemas
      # TODO: gconftool-2 needs work for this :(

      # To run the postinst script we need gconftool-2
      addsubstvar($package, "misc:Depends", "gconf2");
    } else {
      # If it turns out there were not any schemas installed, warn
      error("No schemas were present but the schema folder exists. Looks like 'make install' didn't work correctly.");
    }
  } else {
    # dh_gconf is being called but no gconf schemas were installed
    error("The directory /etc/gconf/schemas was not present. Does this package supply GConf schemas?");
  }
}

=head1 SEE ALSO

L<debhelper(1)>

This program uses debhelper, and should appear to be part of
debhelper.

=head1 AUTHOR

Ross Burton <ross@burtonini.com>

=cut
if [ "$1" = "configure" ]; then
    SCHEMA_LOCATION=/etc/gconf/schemas
    SCHEMA_FILES="#SCHEMAS#"
    for SCHEMA in $SCHEMA_FILES; do
        if [ -e $SCHEMA_LOCATION/$SCHEMA ]; then
            HOME=/root GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
            gconftool-2 \
            --makefile-install-rule $SCHEMA_LOCATION/$SCHEMA > /dev/null
        fi
    done
fi

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: