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

2019-09-24 Thread Lorenz
Il giorno dom 8 set 2019 alle ore 21:17 Dmitry Bogatov 
ha scritto:

> > +# don't restart anacron when it's done

> Why? Will it work correctly on machine that is up for 24/7?

When anacron is done with its jobs it exit and when restarted, if it
detects that
there are no job to run it exits again. For machines up 24/7 the package
ships
a cronjob, so it will work.

I think I have addressed (on salsa) other issues except the finish file: I
will open a bug with a
patch for that but i'm short on free time right now.

Lorenzo


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

2019-09-08 Thread Dmitry Bogatov


[2019-09-04 19:30] Lorenzo Puliti 
> Package: anacron
> Version: 2.3-29
> Followup-For: Bug #934231
>
> Hi,

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

I see all test jobs pass, not just `daemons'. Great!

>  create mode 100644 debian/anacron.runscript/finish

There is nothing in this script specific to anacron. I propose
following:

 * add this finish script into bin:runit as /lib/runit/finish-default or
   something like this.

 * document error codes (161, 160, -1, etc) in invoke-run manpage.

 * modify dh_runit to generate finish script with following content:

   #!/bin/sh
   /lib/runit/finish-default

   Not sure should it be default or yet-another option.

This is more work initially, but will make improvements to finish script
transparent (just upgrade bin:runit), should need appear and avoid
copy-paste work for future runscripts.

FWIW, every time I thought "there will be no need to change ", I
was wrong.

> diff --git a/debian/anacron.runscript/run b/debian/anacron.runscript/run
> new file mode 100644
> index 000..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

$ man test
advices aganist use of `-a` option:

NOTE:  Binary  -a  and -o are inherently ambiguous.  Use 'test EXPR1 &&
   test EXPR2' or 'test EXPR1 || test EXPR2' instead.

> +/usr/bin/on_ac_power || retval=$? 

Minor style issue. Trailing whitespace. You may want to enable default
git pre-commit hook, which catches such issues.

> +if [ x"$retval" = x1 ]; then
> +echo "deferred while on battery power" && exit 161
> +fi
> +fi
> +
> +# don't restart anacron when it's done

Why? Will it work correctly on machine that is up for 24/7?

> 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),

Minor style issue. Please keep spacing consistent, like

foo (>= 1.2.3-4~5)

-- 
Note, that I send and fetch email in batch, once in a few days.
Please, mention in body of your reply when you add or remove recepients.



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

2019-09-04 Thread Lorenzo Puliti
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  libc62.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 
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 000..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 
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 000..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 000..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 000..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 
 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



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

2019-08-08 Thread Lorenzo Puliti
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 
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 000..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 000..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 000..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 
 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