@ -23,79 +23,60 @@
import libcalamares
def run ( ) :
"""
Setup systemd services
def systemctl ( targets , command , suffix ) :
"""
services = libcalamares . job . configuration [ ' services ' ]
targets = libcalamares . job . configuration [ ' targets ' ]
disable = libcalamares . job . configuration [ ' disable ' ]
# note that the "systemctl enable" and "systemctl disable" commands used
# here will work in a chroot; in fact, they are the only systemctl commands
# that support that, see:
# http://0pointer.de/blog/projects/changing-roots.html
For each entry in @p targets , run " systemctl <command> <thing> " ,
where < thing > is the entry ' s name plus the given @p suffix.
A dot is added between name and suffix .
# enable services
for svc in services :
Returns a failure message , or None if this was successful .
Services that are not mandatory have their failures suppressed
silently .
"""
for svc in targets :
ec = libcalamares . utils . target_env_call (
[ ' systemctl ' , ' enable ' , ' {} .service ' . format ( svc [ ' name ' ] ) ]
[ ' systemctl ' , command , " {} . {} " . format ( svc [ ' name ' ] , suffix ) ]
)
if ec != 0 :
if svc [ ' mandatory ' ] :
return ( " Cannot enable systemd service {} " . format ( svc [ ' name ' ] ) ,
" systemctl enable call in chroot returned error code "
" {} " . format ( ec )
return ( " Cannot {} systemd {} {} " . format ( command , suffix , svc [ ' name ' ] ) ,
" systemctl {} call in chroot returned error code {} " . format ( command , ec )
)
else :
libcalamares . utils . debu g(
" Cannot enable systemd service {} " . format ( svc [ ' name ' ] )
libcalamares . utils . warnin g(
" Cannot {} systemd {} {} " . format ( command , suffix , svc [ ' name ' ] )
)
libcalamares . utils . debug (
" systemctl enable call in chroot returned error code "
" {} " . format ( ec )
libcalamares . utils . warning (
" systemctl {} call in chroot returned error code {} " . format ( command , ec )
)
return None
# enable targets
for tgt in targets :
ec = libcalamares . utils . target_env_call (
[ ' systemctl ' , ' enable ' , ' {} .target ' . format ( tgt [ ' name ' ] ) ]
)
if ec != 0 :
if tgt [ ' mandatory ' ] :
return ( " Cannot enable systemd target {} " . format ( tgt [ ' name ' ] ) ,
" systemctl enable call in chroot returned error code "
" {} " . format ( ec )
)
else :
libcalamares . utils . debug (
" Cannot enable systemd target {} " . format ( tgt [ ' name ' ] )
)
libcalamares . utils . debug (
" systemctl enable call in chroot returned error code "
" {} " . format ( ec )
)
def run ( ) :
"""
Setup systemd services
"""
services = libcalamares . job . configuration [ ' services ' ]
targets = libcalamares . job . configuration [ ' targets ' ]
disable = libcalamares . job . configuration [ ' disable ' ]
for dbl in disable :
ec = libcalamares . utils . target_env_call (
[ ' systemctl ' , ' disable ' , ' {} .service ' . format ( dbl [ ' name ' ] ) ]
)
# note that the "systemctl enable" and "systemctl disable" commands used
# here will work in a chroot; in fact, they are the only systemctl commands
# that support that, see:
# http://0pointer.de/blog/projects/changing-roots.html
if ec != 0 :
if dbl [ ' mandatory ' ] :
return ( " Cannot disable systemd service "
" {} " . format ( dbl [ ' name ' ] ) ,
" systemctl disable call in chroot returned error code "
" {} " . format ( ec ) )
else :
libcalamares . utils . debug (
" Cannot disable systemd service {} " . format ( dbl [ ' name ' ] )
)
libcalamares . utils . debug (
" systemctl disable call in chroot returned error code "
" {} " . format ( ec )
)
r = systemctl ( services , " enable " , " service " )
if r is not None :
return r
r = systemctl ( targets , " enable " , " target " )
if r is not None :
return r
r = systemctl ( disable , " disable " , " service " )
if r is not None :
return r
# This could have just been return r
return None