diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-12-21 18:38:24 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-12-21 18:38:24 +0300 |
commit | ff0b6158d55e6254ae368d1f92c32449f8d3ef1d (patch) | |
tree | 7530301f20e8c425044e93b134aeee645ee92792 | |
parent | 1e1ba244801fda60cb962d6a907bcf8792a2ae34 (diff) | |
download | dh-smf-ff0b6158d55e6254ae368d1f92c32449f8d3ef1d.tar.gz |
dh-smf (5) unstable; urgency=mediumdyson/5
* Support multiple services in a single manifest (after CUPS)
-rw-r--r-- | debian/changelog | 6 | ||||
-rwxr-xr-x | dh_smf | 85 |
2 files changed, 52 insertions, 39 deletions
diff --git a/debian/changelog b/debian/changelog index b8d0a90..4df421e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dh-smf (5) unstable; urgency=medium + + * Support multiple services in a single manifest (after CUPS) + + -- Igor Pashev <pashev.igor@gmail.com> Sun, 21 Dec 2014 18:34:48 +0300 + dh-smf (4) unstable; urgency=medium * Fixed postrm-smf-delete: svccfg delete -f cannot work with multiple @@ -102,6 +102,44 @@ sub pkgdir { return ""; } +sub mkservices { + my ( $svc, $attrs ) = @_; + my @services = (); + if ( exists $attrs->{'create_default_instance'} ) { + push @services, + { + 'name' => "svc:/$svc:default", + 'enabled' => $attrs->{'create_default_instance'}->{'enabled'}, + 'exec_method' => $attrs->{'exec_method'}, + 'duration' => + $attrs->{'property_group'}->{'startd'}->{'propval'}->{'duration'} + ->{'value'} // 'contract', + 'upgrade' => + $attrs->{'property_group'}->{'package'}->{'propval'}->{'upgrade'} + ->{'value'} // 'stop', + }; + } + if ( exists $attrs->{'instance'} ) { + while ( my ( $k, $v ) = each %{ $attrs->{'instance'} } ) { + push @services, + { + 'name' => "svc:/$svc:$k", + 'enabled' => $v->{'enabled'}, + 'exec_method' => $v->{'exec_method'} // $attrs->{'exec_method'}, + 'duration' => + $v->{'property_group'}->{'startd'}->{'propval'}->{'duration'} + ->{'value'} + // $attrs->{'property_group'}->{'startd'}->{'propval'} + ->{'duration'}->{'value'} // 'contract', + 'upgrade' => + $v->{'property_group'}->{'package'}->{'propval'}->{'upgrade'} + ->{'value'} // 'stop', + }; + } + } + return @services; +} + init( options => {} ); foreach my $package ( @{ $dh{DOPACKAGES} } ) { @@ -140,45 +178,14 @@ foreach my $package ( @{ $dh{DOPACKAGES} } ) { # Read all services from all manifests: my @services = (); foreach my $manifest (@manifests) { - my $xml = XMLin( $manifest, - ForceArray => - [qw/instance dependency exec_method propval property_group/] ); - - my $service_base = $xml->{'service'}->{'name'}; - if ( exists $xml->{'service'}->{'create_default_instance'} ) { - push @services, - { - 'name' => "svc:/$service_base:default", - 'enabled' => - $xml->{'service'}->{'create_default_instance'}->{'enabled'}, - 'exec_method' => $xml->{'service'}->{'exec_method'}, - 'duration' => - $xml->{'service'}->{'property_group'}->{'startd'}->{'propval'} - ->{'duration'}->{'value'} // 'contract', - 'upgrade' => - $xml->{'service'}->{'property_group'}->{'package'} - ->{'propval'}->{'upgrade'}->{'value'} // 'stop', - }; - } - if ( exists $xml->{'service'}->{'instance'} ) { - while ( my ( $k, $v ) = each %{ $xml->{'service'}->{'instance'} } ) - { - push @services, - { - 'name' => "svc:/$service_base:$k", - 'enabled' => $v->{'enabled'}, - 'exec_method' => $v->{'exec_method'} - // $xml->{'service'}->{'exec_method'}, - 'duration' => - $v->{'property_group'}->{'startd'}->{'propval'} - ->{'duration'}->{'value'} - // $xml->{'service'}->{'property_group'}->{'startd'} - ->{'propval'}->{'duration'}->{'value'} // 'contract', - 'upgrade' => - $v->{'property_group'}->{'package'}->{'propval'} - ->{'upgrade'}->{'value'} // 'stop', - }; - } + my $xml = XMLin( + $manifest, + ForceArray => [ + qw/service instance dependency exec_method propval property_group/ + ], + ); + while ( my ( $svc, $attrs ) = each %{ $xml->{'service'} } ) { + push @services, mkservices( $svc, $attrs ); } } |