summaryrefslogtreecommitdiff
path: root/dh_smf
diff options
context:
space:
mode:
Diffstat (limited to 'dh_smf')
-rwxr-xr-xdh_smf85
1 files changed, 46 insertions, 39 deletions
diff --git a/dh_smf b/dh_smf
index 49d58d7..4ecacad 100755
--- a/dh_smf
+++ b/dh_smf
@@ -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 );
}
}