systemctl: Support all unit types in the directives.
authorRandy Witt <rewitt@declaratino.com>
Fri, 21 Jun 2013 04:12:57 +0000 (00:12 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 25 Jun 2013 16:44:56 +0000 (17:44 +0100)
The Alias and WantedBy directives can accept all valid unit types when
using the systemctl from systemd. And since the systemctl script should
match the behavior of systemd as much as possible, add the current set
of unit types listed at
http://www.freedesktop.org/software/systemd/man/systemd.unit.html
to the Alias and WantedBy directives.

The deficiency was exposed when trying to use:
    Alias=default.target
in a foo.target. No symlink was created by running
"systemctl enable foo.target" during the package's postinst.

(From OE-Core rev: 374b9c37b3310cf2a3373633197ca7ba21f6d1bd)

Signed-off-by: Randy Witt <rewitt@declaratino.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd-systemctl/systemctl

index 8abbdf6..f786656 100755 (executable)
@@ -77,10 +77,14 @@ for service in $services; do
        fi
        echo "Found $service in $service_file"
 
+       # If any new unit types are added to systemd they should be added
+       # to this regular expression.
+       unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$'
+
        # create the required symbolic links
        wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \
                        | tr ',' '\n' \
-                       | grep '\(\.target$\)\|\(\.service$\)')
+                       | grep "$unit_types_re")
 
        for r in $wanted_by; do
                echo "WantedBy=$r found in $service"
@@ -98,7 +102,7 @@ for service in $services; do
        # create the required symbolic 'Alias' links
        alias=$(sed '/^Alias[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \
                        | tr ',' '\n' \
-                       | grep '\.service$')
+                       | grep "$unit_types_re")
 
        for r in $alias; do
                if [ "$action" = "enable" ]; then