[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#934231: anacron: please provide a runscript for runit



Package: anacron
Version: 2.3-29
Followup-For: Bug #934231

Hi,
I have updated the patches and the MR:
First patch adds Gtilab CI test and include a test for the runscript

https://salsa.debian.org/Lorenzo.ru.g-guest/anacron/pipelines/69420

The second one, compared to the previuos version, adds the following:
 * bump dh-runit version to 2.8.14 in Build-depends
 * add presubj option for dh-runit
 * slightly reword the echo messages in run and finish files

Thanks,
Lorenzo


-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.20.3-van (SMP w/4 CPU cores; PREEMPT)
Kernel taint flags: TAINT_OOT_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     11.1.0

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+b1
ii  powermgmt-base                  1.36
ii  socklog [system-log-daemon]     2.1.0+repack-1

-- no debconf information
>From 7b21cdaa7e71ccb4ebe684a333a090f7e82369a1 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.ru.g@gmail.com>
Date: Wed, 4 Sep 2019 18:30:06 +0200
Subject: [PATCH 1/2] Add gitlab CI

---
 debian/.gitlab-ci.yml | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 debian/.gitlab-ci.yml

diff --git a/debian/.gitlab-ci.yml b/debian/.gitlab-ci.yml
new file mode 100644
index 0000000..8ca3a45
--- /dev/null
+++ b/debian/.gitlab-ci.yml
@@ -0,0 +1,6 @@
+include:
+  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
+  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml
+  - https://salsa.debian.org/kaction/daemons/raw/master/pipeline.yml
+variables:
+  RELEASE: unstable 
-- 
2.23.0

>From 0969d723daa71cd8d2cb26e44edebe27c4306c9f 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 2/2] 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..b41198a
--- /dev/null
+++ b/debian/anacron.runit
@@ -0,0 +1 @@
+debian/anacron.runscript logscript,name=anacron,since=2.3-30,presubj
diff --git a/debian/anacron.runscript/finish b/debian/anacron.runscript/finish
new file mode 100644
index 0000000..45a5ef2
--- /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 "runsv: $NAME stopped " 
diff --git a/debian/anacron.runscript/run b/debian/anacron.runscript/run
new file mode 100644
index 0000000..dcfb16d
--- /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 "runsv: starting $NAME..."
+exec /usr/sbin/anacron -d $ANACRON_ARGS
diff --git a/debian/control b/debian/control
index 9a38b23..fc5e3ed 100644
--- a/debian/control
+++ b/debian/control
@@ -3,6 +3,7 @@ Section: admin
 Priority: optional
 Build-Depends:
  debhelper-compat (= 12),
+ dh-runit(>=2.8.14),
 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


Reply to: