diff options
author | Tomas Novotny <tomas@novotny.cz> | 2016-02-26 15:57:40 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-28 11:32:41 +0000 |
commit | 6f4d9d9675ce39f5154de30b2921ada019a93d0f (patch) | |
tree | 0562ca9db704033663b07348b0d11cf6e6c6924f /meta | |
parent | 2a3276653b110f020e2f906be5d6966c9b6efbb3 (diff) | |
download | openembedded-core-6f4d9d9675ce39f5154de30b2921ada019a93d0f.tar.gz openembedded-core-6f4d9d9675ce39f5154de30b2921ada019a93d0f.tar.bz2 openembedded-core-6f4d9d9675ce39f5154de30b2921ada019a93d0f.zip |
systemctl: handle RequiredBy dependencies
Install section of a systemd service may contain RequiredBy dependency,
which is not handled currently. This means that symlinks to enable the
service are not created and the service may not be started.
Also fix debug output (all dependencies were printed instead of the one
which was enabled or disabled).
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl index 697fbd59df..1164dd4950 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl @@ -125,33 +125,46 @@ for service in $services; do | tr ',' '\n' \ | grep "$unit_types_re") - for r in $wanted_by; do - echo "WantedBy=$r found in $service" - if [ "$action" = "enable" ]; then - enable_service=$service - if [ "$service_template" = true -a "$instance_specified" = false ]; then - default_instance=$(sed '/^DefaultInstance[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file") - if [ -z $default_instance ]; then - echo "Template unit without instance or DefaultInstance directive, nothing to enable" - continue - else - echo "Found DefaultInstance $default_instance, enabling it" - enable_service=$(echo $service | sed "s/@/@$(echo $default_instance | sed 's/\\/\\\\/g')/") + required_by=$(sed '/^RequiredBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ + | tr ',' '\n' \ + | grep "$unit_types_re") + + for dependency in WantedBy RequiredBy; do + if [ "$dependency" = "WantedBy" ]; then + suffix="wants" + dependency_list="$wanted_by" + elif [ "$dependency" = "RequiredBy" ]; then + suffix="requires" + dependency_list="$required_by" + fi + for r in $dependency_list; do + echo "$dependency=$r found in $service" + if [ "$action" = "enable" ]; then + enable_service=$service + if [ "$service_template" = true -a "$instance_specified" = false ]; then + default_instance=$(sed '/^DefaultInstance[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file") + if [ -z $default_instance ]; then + echo "Template unit without instance or DefaultInstance directive, nothing to enable" + continue + else + echo "Found DefaultInstance $default_instance, enabling it" + enable_service=$(echo $service | sed "s/@/@$(echo $default_instance | sed 's/\\/\\\\/g')/") + fi fi - fi - mkdir -p $ROOT/etc/systemd/system/$r.wants - ln -s $service_file $ROOT/etc/systemd/system/$r.wants/$enable_service - echo "Enabled $enable_service for $wanted_by." - else - if [ "$service_template" = true -a "$instance_specified" = false ]; then - disable_service="$ROOT/etc/systemd/system/$r.wants/`echo $service | sed 's/@/@*/'`" + mkdir -p $ROOT/etc/systemd/system/$r.$suffix + ln -s $service_file $ROOT/etc/systemd/system/$r.$suffix/$enable_service + echo "Enabled $enable_service for $r." else - disable_service="$ROOT/etc/systemd/system/$r.wants/$service" + if [ "$service_template" = true -a "$instance_specified" = false ]; then + disable_service="$ROOT/etc/systemd/system/$r.$suffix/`echo $service | sed 's/@/@*/'`" + else + disable_service="$ROOT/etc/systemd/system/$r.$suffix/$service" + fi + rm -f $disable_service + [ -d $ROOT/etc/systemd/system/$r.$suffix ] && rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.$suffix + echo "Disabled ${disable_service##$ROOT/etc/systemd/system/$r.$suffix/} for $r." fi - rm -f $disable_service - [ -d $ROOT/etc/systemd/system/$r.wants ] && rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants - echo "Disabled ${disable_service##$ROOT/etc/systemd/system/$r.wants/} for $wanted_by." - fi + done done # create the required symbolic 'Alias' links |