r39995 - /trunk/libconfig-model-perl/debian/dh/dh_config
ddumont-guest at users.alioth.debian.org
ddumont-guest at users.alioth.debian.org
Thu Jul 16 13:14:26 UTC 2009
Author: ddumont-guest
Date: Thu Jul 16 13:13:56 2009
New Revision: 39995
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=39995
Log:
- many bug and doc fix.
Modified:
trunk/libconfig-model-perl/debian/dh/dh_config
Modified: trunk/libconfig-model-perl/debian/dh/dh_config
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-perl/debian/dh/dh_config?rev=39995&op=diff
==============================================================================
--- trunk/libconfig-model-perl/debian/dh/dh_config (original)
+++ trunk/libconfig-model-perl/debian/dh/dh_config Thu Jul 16 13:13:56 2009
@@ -27,49 +27,63 @@
use Debian::Debhelper::Dh_Lib ;
-init(options => { model_name => \$dh{MODEL_NAME},
- model_package => \$dh{MODEL_PACKAGE},
- model_version => \$dh{MODEL_VERSION},
+$dh{model_name} = ''; # avoids undef warnings
+
+init(options => { "model_name|mn=s" => \$dh{model_name},
+ "model_package|mp=s" => \$dh{model_package},
+ "model_version|mv=s" => \$dh{model_version},
}
);
+my @do_packages = @{$dh{DOPACKAGES}} ;
+
+unless (@do_packages) {
+ @do_packages = map { m!debian/(.*)\.config-model!; $1; }
+ glob("debian/*.config-model") ;
+}
+
# debian/config file: foo.config-model
-my $package = $dh{MAIN_PACKAGE};
-exit 0 unless defined $package ;
-
-my $metaconf = "debian/$package.config-model" ;
-
-# do nothing if no model name was provided
-exit 0 unless ($dh{MODEL} or -e $metaconf) ;
-
-# declare model name to load ($model below)
-# declare which package provides the model (optional)
-open(META,$metaconf) || die "Can't open $metaconf:$!";
-foreach (<META>) {
- chomp;
- my ($k,$v) = split /\s*?[:= ]\s*/ ;
- foreach my $dhk (grep /^MODEL_/,keys %dh) {
- $dh{$dhk} ||= $v if uc($k) eq $dhk ;
+foreach my $package (@do_packages) {
+
+ verbose_print("dh_config: package $package") ;
+
+ my $metaconf = "debian/$package.config-model" ;
+
+ my %cm_config = map { $_ => $dh{$_} ; }
+ qw/model_name model_version model_package/;
+
+ # declare model name to load ($model below)
+ # declare which package provides the model (optional)
+ if (-e $metaconf) {
+ open my $meta,$metaconf || die "Can't open $metaconf:$!";
+ foreach (<$meta>) {
+ chomp;
+ my ($k,$v) = split /\s*?[:= ]\s*/ ;
+ foreach my $cmhk (keys %cm_config) {
+ $cm_config{$cmhk} ||= $v if $k eq $cmhk ;
+ }
+ }
+ close $meta ;
}
+
+ next unless defined $dh{model_name} ;
+
+ # add dependency
+ addsubstvar($package,'misc:Depends', 'libconfig-model-perl', '>= 0.637') ;
+
+ if (defined $cm_config{model_package}) {
+ # add dependency in misc:Depends control file
+ addsubstvar($package,'misc:Depends',
+ $cm_config{model_package},$cm_config{model_version}) ;
+ }
+ else {
+ # should we check that model file is declared in *.install ?
+ }
+
+ # calls autoscript to update pkg.postinst with config-edit command
+ autoscript($package,postinst => 'postinst-config-model',
+ 's/%MODEL%/'.$dh{model_name}.'/') ;
}
-
-next unless defined $dh{MODEL_NAME} ;
-
-# add dependency
-addsubstvar($package,'misc:Depends', 'libconfig-model-perl', '>= 0.637') ;
-
-if (defined $dh{MODEL_PACKAGE}) {
- # add dependency in misc:Depends control file
- addsubstvar($package,'misc:Depends',
- $dh{MODEL_PACKAGE},$dh{MODEL_VERSION}) ;
-}
-else {
- # should we check that model file is declared in *.install ?
-}
-
-# calls autoscript to update pkg.postinst with config-edit command
-autoscript($package,postinst => 'postinst-config-model') ;
-
__END__
=head1 NAME
@@ -78,8 +92,8 @@
=head1 SYNOPSIS
- dh_config [ debhelper options ] [ -model_name xx ] \
- [ -model_package xx [ -model_version yy ] ]
+ dh_config [ debhelper options ] [ --model_name xx ] \
+ [ --model_package xx [ --model_version yy ] ] [ -p pkg ]
=head1 DESCRIPTION
@@ -106,22 +120,57 @@
=head1 OPTIONS
-=head2 -model_name XX
+=head2 --model_name XX
Specifies the model name (à la C<Config::Model>) that will be used to
perform the upgrade. Without this information, C<dh_config> will do
-nothing.
-
-=head2 -model_package XX
+nothing. (shortcut C<--mn>)
+
+=head2 --model_for "xx yy"
+
+Specifies the package to act upon. Without this option, C<dh_config>
+will do nothing. To specify several packages, list the packages
+between quotes. (shortcut C<--mf>)
+
+=head2 --model_package XX
Specifies the debian package that provide the model specified bu
-C<-model_name>.
-
-=head2 -model_version YY
+C<-model_name>. (shortcut C<--mp>)
+
+=head2 --model_version YY
Specifies the minimal version of the package that provides the model.
-
-=head1 EXAMPLE
+(shortcut C<--mv>)
+
+=head2 -p
+
+debhelper option to specify which package(s) to act on.
+
+=head1 Usage
+
+C<dh_config> can be used with only command line options. For instance
+
+ dh_config --model_name Sshd -p openssh-server \
+ --model_package lib-config-model-openssh-perl --model_version 1.206
+
+Alternatively, you can specify relevant informations in
+configuration files. For instance:
+
+ $ cat debian/openssh-server.config-model
+ model_name: Sshd
+ model_package: lib-config-model-openssh-perl
+ model_version: 1.206
+ $ cat debian/openssh-client.config-model
+ model_name: Ssh
+ model_package: lib-config-model-openssh-perl
+ model_version: 1.206
+
+In this case, C<dh_config> will be invoked this way
+
+ dh_config
+
+If the model are delivered within the package, you will have to
+specify them in xx.install file.
Here's a example based on C<approx> package where the model file and
the parser/writer are delivered in approx package.
@@ -140,6 +189,11 @@
dh_config -model_name Approx
+=head1 CAVEATS
+
+Using options with a single dash (e.g. C<-model_name> instead of
+C<--model_name>) will lead to "C<Unknown option>" errors.
+
=head1 SEE ALSO
L<debhelper>
More information about the Pkg-perl-cvs-commits
mailing list