From 03c18c3987d737af10d28a7bf7f42ca8c7bf5cfd Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 25 Feb 2014 19:33:38 +0100 Subject: introduce the “purge” verb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #721244 --- script/deb-systemd-helper | 12 ++++++++---- 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 +# © 2013-2014 Michael Stapelberg # # All rights reserved. # @@ -35,7 +35,7 @@ deb-systemd-helper - subset of systemctl for machines not running systemd =head1 SYNOPSIS -B enable | disable | mask | unmask | is-enabled | was-enabled | debian-installed | update-state | reenable S ...> +B enable | disable | purge | mask | unmask | is-enabled | was-enabled | debian-installed | update-state | reenable S ...> =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 @@ -163,6 +163,26 @@ $retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh enable $random_unit"); 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 ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -- cgit v1.2.3