shared/install: when creating symlinks, accept different but equivalent symlinks
We would only accept "identical" links, but having e.g. a symlink /usr/lib/systemd/system/foo-alias.service → /usr/lib/systemd/system/foo.service when we're trying to create /usr/lib/systemd/system/foo-alias.service → ./foo.service is OK. This fixes an issue found in ubuntuautopkg package installation, where we'd fail when enabling systemd-resolved.service, because the existing alias was absolute, and (with the recent patches) we were trying to create a relative one. A test is added. (For .wants/.requires symlinks we were already doing OK. A test is also added, to verify.)
This commit is contained in:
@@ -39,8 +39,29 @@ test -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
"$systemctl" --root="$root" disable test1.service
|
||||
test ! -e "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test ! -e "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
test ! -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test ! -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
: '------enable when link already exists-----------------------'
|
||||
# We don't read the symlink target, so it's OK for the symlink to point
|
||||
# to something else. We should just silently accept this.
|
||||
|
||||
mkdir -p "$root/etc/systemd/system/default.target.wants"
|
||||
mkdir -p "$root/etc/systemd/system/special.target.requires"
|
||||
ln -s /usr/lib/systemd/system/test1.service "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
ln -s /usr/lib/systemd/system/test1.service "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
"$systemctl" --root="$root" enable test1.service
|
||||
test -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
"$systemctl" --root="$root" reenable test1.service
|
||||
test -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
"$systemctl" --root="$root" disable test1.service
|
||||
test ! -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test ! -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
|
||||
: '------suffix guessing---------------------------------------'
|
||||
"$systemctl" --root="$root" enable test1
|
||||
@@ -90,6 +111,20 @@ test ! -h "$root/etc/systemd/system/default.target.wants/test1.service"
|
||||
test ! -h "$root/etc/systemd/system/special.target.requires/test1.service"
|
||||
test ! -h "$root/etc/systemd/system/test1-goodalias.service"
|
||||
|
||||
: '-------aliases when link already exists---------------------'
|
||||
cat >"$root/etc/systemd/system/test1a.service" <<EOF
|
||||
[Install]
|
||||
Alias=test1a-alias.service
|
||||
EOF
|
||||
|
||||
ln -s /usr/lib/systemd/system/test1a.service "$root/etc/systemd/system/test1a-alias.service"
|
||||
|
||||
"$systemctl" --root="$root" enable test1a.service
|
||||
test -h "$root/etc/systemd/system/test1a-alias.service"
|
||||
|
||||
"$systemctl" --root="$root" disable test1a.service
|
||||
test ! -h "$root/etc/systemd/system/test1a-alias.service"
|
||||
|
||||
: '-------also units-------------------------------------------'
|
||||
cat >"$root/etc/systemd/system/test2.socket" <<EOF
|
||||
[Install]
|
||||
|
||||
Reference in New Issue
Block a user