@ -56,6 +56,22 @@ class OpenrcController:
self . initdDir = libcalamares . job . configuration [ ' initdDir ' ]
self . runlevelsDir = libcalamares . job . configuration [ ' runlevelsDir ' ]
def make_failure_description ( self , state , name , runlevel ) :
"""
Returns a generic " could not <foo> " failure message , specialized
for the action @p state and the specific service @p name in @p runlevel .
"""
if state == " add " :
description = _ ( " Cannot add service {name!s} to run-level {level!s} . " )
elif state == " del " :
description = _ ( " Cannot remove service {name!s} from run-level {level!s} . " )
else :
description = _ ( " Unknown service-action <code> {arg!s} </code> for service {name!s} in run-level {level!s} . " )
return description . format ( arg = state , name = name , level = runlevel )
def update ( self , state ) :
"""
Call rc - update for each service listed
@ -83,19 +99,28 @@ class OpenrcController:
warning ( " Cannot {} service {} to {} " . format ( state , name , runlevel ) )
warning ( " rc-update returned error code {!s} " . format ( ec ) )
if mandatory :
return ( _ ( " Cannot {} service {} to {} " ) . format ( state , name , runlevel ) ,
_ ( " rc-update {} call in chroot returned error code {} " ) . format ( state , ec )
title = _ ( " Cannot modify service " )
diagnostic = _ ( " <code>rc-update {arg!s} </code> call in chroot returned error code {num!s} . " ) . format ( arg = state , num = ec )
return ( title ,
self . make_failure_description ( state , name , runlevel ) + " " + diagnostic
)
else :
warning ( " Target runlevel {} does not exist for {} . " . format ( runlevel , name ) )
if mandatory :
return ( _ ( " Target runlevel {} does not exist for {} . " ) . format ( runlevel , name ) ,
_ ( " No {} found. " ) . format ( runlevel_path ) )
title = _ ( " Target runlevel does not exist " )
diagnostic = _ ( " The path for runlevel {level!s} is <code> {path!s} </code>, which does not exist. " ) . format ( level = runlevel , path = runlevel_path )
return ( title ,
self . make_failure_description ( state , name , runlevel ) + " " + diagnostic
)
else :
warning ( " Target service {} does not exist in {} . " . format ( name , self . initdDir ) )
if mandatory :
return ( _ ( " Target service {} does not exist. " ) . format ( name ) ,
_ ( " No {} found. " ) . format ( service_path ) )
title = _ ( " Target service does not exist " )
diagnostic = _ ( " The path for service {name!s} is <code> {path!s} </code>, which does not exist. " ) . format ( name = name , path = service_path )
return ( title ,
self . make_failure_description ( state , name , runlevel ) + " " + diagnostic
)
def run ( self ) :