Bug#934231: anacron: please provide a runscript for runit
Package: anacron
Version: 2.3-30
Severity: wishlist
Tags: patch
Dear QA Group,
here is a patch (attached) to add support for Runit initialization system.
There is also a MR on Salsa:
https://salsa.debian.org/debian/anacron/merge_requests/1
If you need more details please ask
Thanks,
Lorenzo
-- System Information:
Debian Release: bullseye/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-3-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)
Versions of packages anacron depends on:
ii debianutils 4.8.6.3
ii libc6 2.28-10
ii lsb-base 10.2019051400
ii runit-helper 2.8.13.2
Versions of packages anacron recommends:
ii cron [cron-daemon] 3.0pl1-134
Versions of packages anacron suggests:
ii postfix [mail-transport-agent] 3.4.5-1
ii powermgmt-base 1.36
ii socklog-run [system-log-daemon] 2.1.0-8.1
-- no debconf information
>From ede36b260e97c3017d43f568f9d9908f8235d9aa Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.ru.g@gmail.com>
Date: Thu, 8 Aug 2019 13:36:43 +0200
Subject: [PATCH] Add a runscript for runit
Add a runscript for runit; rely on dh-runit for
maintscripts code.
---
debian/anacron.runit | 1 +
debian/anacron.runscript/finish | 11 +++++++++++
debian/anacron.runscript/run | 21 +++++++++++++++++++++
debian/control | 2 ++
debian/rules | 2 +-
5 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 debian/anacron.runit
create mode 100644 debian/anacron.runscript/finish
create mode 100644 debian/anacron.runscript/run
diff --git a/debian/anacron.runit b/debian/anacron.runit
new file mode 100644
index 0000000..3163021
--- /dev/null
+++ b/debian/anacron.runit
@@ -0,0 +1 @@
+debian/anacron.runscript logscript,name=anacron,since=2.3-30
diff --git a/debian/anacron.runscript/finish b/debian/anacron.runscript/finish
new file mode 100644
index 0000000..51bb98d
--- /dev/null
+++ b/debian/anacron.runscript/finish
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+NAME=Anacron
+
+[ $1 = -1 ] && echo "runsv: ERROR in $NAME: unexpected error or wrong sh syntax"
+
+[ $1 = 161 ] && echo "runsv: ERROR $1 in $NAME: disabled by local settings" \
+ && sv d $(dirname $0) && exit 0
+
+echo "$NAME Stopped "
diff --git a/debian/anacron.runscript/run b/debian/anacron.runscript/run
new file mode 100644
index 0000000..1aa888a
--- /dev/null
+++ b/debian/anacron.runscript/run
@@ -0,0 +1,21 @@
+#!/usr/bin/env /lib/runit/invoke-run
+set -e
+
+NAME=Anacron
+
+exec 2>&1
+
+# exit status of on_ac_power:
+# 0= on-ac // 1= on-battery // 255=unknown, likely a desktop witout APM
+if [ x"$ANACRON_RUN_ON_BATTERY_POWER" != x"yes" -a -x /usr/bin/on_ac_power ]; then
+ /usr/bin/on_ac_power || retval=$?
+ if [ x"$retval" = x1 ]; then
+ echo "deferred while on battery power" && exit 161
+ fi
+fi
+
+# don't restart anacron when it's done
+sv once anacron
+
+echo "Starting $NAME..."
+exec /usr/sbin/anacron -d $ANACRON_ARGS
diff --git a/debian/control b/debian/control
index 9a38b23..343b30d 100644
--- a/debian/control
+++ b/debian/control
@@ -3,6 +3,7 @@ Section: admin
Priority: optional
Build-Depends:
debhelper-compat (= 12),
+ dh-runit(>=2.8.8),
Maintainer: Debian QA Group <packages@qa.debian.org>
Standards-Version: 4.2.1
Rules-Requires-Root: no
@@ -12,6 +13,7 @@ Vcs-Browser: https://salsa.debian.org/debian/anacron
Package: anacron
Architecture: any
+Breaks: ${runit:Breaks}
Depends:
debianutils (>= 1.7),
lsb-base (>= 3.0-10),
diff --git a/debian/rules b/debian/rules
index 93acac4..5b251e6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -20,7 +20,7 @@ else
endif
%:
- dh $@
+ dh $@ --with runit
override_dh_auto_install:
$(MAKE) install PREFIX=debian/anacron MANDIR=debian/anacron/usr/share/man
--
2.23.0.rc1
Reply to: