diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-02-25 19:33:38 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2014-02-25 19:33:38 +0100 |
commit | 03c18c3987d737af10d28a7bf7f42ca8c7bf5cfd (patch) | |
tree | 9738bb3a7d5ad442b27cebef5055c77b9ebed72d | |
parent | cbfce36a16095b9f8155ecfb620e1d6194dcc7e7 (diff) | |
download | init-system-helpers-03c18c3987d737af10d28a7bf7f42ca8c7bf5cfd.tar.gz |
introduce the “purge” verb
Closes: #721244
-rwxr-xr-x | script/deb-systemd-helper | 12 | ||||
-rw-r--r-- | t/001-deb-systemd-helper.t | 20 |
2 files changed, 28 insertions, 4 deletions
diff --git a/script/deb-systemd-helper b/script/deb-systemd-helper index efb6fe3..59e76a0 100755 --- a/script/deb-systemd-helper +++ b/script/deb-systemd-helper @@ -1,6 +1,6 @@ #!/usr/bin/env perl # vim:ts=4:sw=4:expandtab -# © 2013 Michael Stapelberg <stapelberg@debian.org> +# © 2013-2014 Michael Stapelberg <stapelberg@debian.org> # # All rights reserved. # @@ -35,7 +35,7 @@ deb-systemd-helper - subset of systemctl for machines not running systemd =head1 SYNOPSIS -B<deb-systemd-helper> enable | disable | mask | unmask | is-enabled | was-enabled | debian-installed | update-state | reenable S<I<unit file> ...> +B<deb-systemd-helper> enable | disable | purge | mask | unmask | is-enabled | was-enabled | debian-installed | update-state | reenable S<I<unit file> ...> =head1 DESCRIPTION @@ -44,8 +44,7 @@ the enable, disable, is-enabled and reenable commands from systemctl. The "enable" action will only be performed once (when first installing the package). On the first "enable", an state file is created which will be deleted -upon "disable", but only when _DEB_SYSTEMD_HELPER_PURGE=1 to distinguish purge -from remove. +upon "purge". The "mask" action will keep state on whether the service was enabled/disabled before and will properly return to that state on "unmask". @@ -445,6 +444,11 @@ if (!$ENV{DPKG_MAINTSCRIPT_PACKAGE}) { exit 1; } +if ($action eq 'purge') { + $ENV{_DEB_SYSTEMD_HELPER_PURGE} = 1; + $action = 'disable'; +} + debug "is purge = " . (is_purge() ? "yes" : "no"); my $rc = 0; diff --git a/t/001-deb-systemd-helper.t b/t/001-deb-systemd-helper.t index 652e3d1..f8a01a5 100644 --- a/t/001-deb-systemd-helper.t +++ b/t/001-deb-systemd-helper.t @@ -164,6 +164,26 @@ is_enabled($random_unit); is_debian_installed($random_unit); # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +# ┃ Verify the “purge” verb works. ┃ +# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + +$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh purge $random_unit"); + +isnt_enabled($random_unit); + +# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +# ┃ Verify “enable” after purging does re-create the symlinks. ┃ +# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + +ok(! -l $symlink_path, 'symlink does not exist yet'); +isnt_enabled($random_unit); + +$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh enable $random_unit"); + +is_enabled($random_unit); +is_debian_installed($random_unit); + +# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Verify “mask” (when enabled) results in the symlink pointing to /dev/null ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ |