Package: runit
Version: 2.1.2-31
Severity: wishlist
Tags: patch


-- System Information:
Debian Release: 10.0
  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 runit depends on:
ii  libc6           2.28-10
ii  runit-helper    2.8.10
ii  sysuser-helper  1.3.3

Versions of packages runit recommends:
ii  runit-init  2.1.2-30

runit suggests no packages.

-- Configuration Files:
/etc/runit/3 changed [not included]

-- no debconf information

Hi,

while experimenting with autopkgtest i manage to write a small test
that, starting from a systemd qemu machine, installs runit-init and reboot into
it, checking if there is a working getty to login with and if essential 
services (syslog, udev ..) are up.
While the test is very simple it could be useful to have something like
this around to make sure that the compat layer in /run/initctl will not 
get broken (by systemd) and that some future development in stage1/2 will not
break the runit-init boot.
I have tested it on my pc, the last attach is the output of the test

Lorenzo
>From d02fbb0e7e3a66ca463bf96b9f5fb1057856fe60 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Thu, 20 Jun 2019 00:47:17 +0200
Subject: [PATCH 1/3] Provide a service for a getty on serial tty

Provide a getty-ttyS0 service; this is needed by autopkgtest
for connecting with the testbed (qemu), otherwise a reboot into
a runit-init VM will fail the test.
---
 debian/getty-ttyS0/run | 8 ++++++++
 debian/runit.install   | 1 +
 2 files changed, 9 insertions(+)
 create mode 100755 debian/getty-ttyS0/run

diff --git a/debian/getty-ttyS0/run b/debian/getty-ttyS0/run
new file mode 100755
index 0000000..31dccf6
--- /dev/null
+++ b/debian/getty-ttyS0/run
@@ -0,0 +1,8 @@
+#!/bin/sh
+NAME=getty-ttyS0
+if pgrep -x agetty -t ttyS0; then
+    sv d getty-ttyS0
+    echo "already another getty on ttyS0"
+fi
+exec 2>&1
+exec chpst -P fgetty /dev/ttyS0
diff --git a/debian/runit.install b/debian/runit.install
index 40a9466..a9a72fe 100644
--- a/debian/runit.install
+++ b/debian/runit.install
@@ -21,5 +21,6 @@ runit-2.1.2/src/runit               /sbin
 debian/contrib/shutdown             /lib/runit
 debian/contrib/runlevel             /lib/runit
 debian/sulogin/run                  /etc/runit/runsvdir/single/sulogin
+debian/getty-ttyS0/run                  /etc/sv/getty-ttyS0
 debian/contrib/lib/async-timeout    /lib/runit
 debian/contrib/lib/run_sysv_scripts /lib/runit
-- 
2.20.1

>From 374b79ae1c811b668668f22f57e77a6d352670a4 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Mon, 17 Jun 2019 14:43:55 +0200
Subject: [PATCH 2/3] Prepare source for autopkgtest

Add a stanza in debian/control and a debian/tests directory
needed for autopkgtest
---
 debian/control       | 1 +
 debian/tests/control | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 debian/tests/control

diff --git a/debian/control b/debian/control
index 23300e5..0764231 100644
--- a/debian/control
+++ b/debian/control
@@ -13,6 +13,7 @@ Build-Depends: bash-completion,
                doc-base,
 Vcs-Browser: https://salsa.debian.org/debian/runit
 Vcs-Git: https://salsa.debian.org/debian/runit.git
+Testsuite: autopkgtest
 
 Package: runit
 Architecture: any
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1 @@
+ 
-- 
2.20.1

>From b37238455025ca36c7795c96d934205016cde026 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Mon, 17 Jun 2019 16:05:00 +0200
Subject: [PATCH 3/3] add a test for switching to runit-init

Add a smoke test for the switch systemd --> runit-init
---
 debian/tests/control     |  8 +++++-
 debian/tests/init-switch | 60 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100755 debian/tests/init-switch

diff --git a/debian/tests/control b/debian/tests/control
index 8d1c8b6..02565b5 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1 +1,7 @@
- 
+Tests: init-switch
+Depends: runit,
+  runit-init,
+  getty-run,
+  fgetty,
+  psmisc,
+Restrictions: needs-root, isolation-machine, breaks-testbed
diff --git a/debian/tests/init-switch b/debian/tests/init-switch
new file mode 100755
index 0000000..1e09238
--- /dev/null
+++ b/debian/tests/init-switch
@@ -0,0 +1,60 @@
+ #!/bin/sh
+ set -e
+ 
+ 
+ if [ -z "$AUTOPKGTEST_REBOOT_MARK" ]; then
+    if [ -d /run/systemd/system ]; then
+        init=systemd
+    elif [ -e /run/initctl ]; then
+        init=sysv
+    else
+        init=unknown-init
+    fi
+    echo "testbed is running with $init"
+    
+    if [ -e /tmp/autopkgtest-reboot ]; then
+        echo "enabling the serial getty"
+        ln -s /etc/sv/getty-ttyS0 /etc/service/
+        echo "Done"
+        /tmp/autopkgtest-reboot-prepare runit
+        echo "reboot"
+        reboot
+    else
+        echo "testbed does not support reboot"
+        echo "can't perform this test"
+        exit 1
+    fi
+ else
+    echo "detecting runit-init"
+    if [ -e /run/runit.stopit ]; then
+        echo "OK"
+    else
+        echo "init is not runit" && exit 1
+    fi
+    # searching for runsvdir is pointless, since autopkgtest use serial getty
+    #to connect with the qemu-system, and getty-S0 starts only after runsvdir..
+    #echo "detecting runsvdir"
+    #if pidof runsvdir; then
+    #    echo "OK"
+    #else
+    #    echo "stage 2 failed to start runsvdir" && exit 1
+    #fi
+    echo "detecting gettys"
+    if pidof fgetty; then
+        echo "OK"
+    else
+        echo " no getty to perform login with " && exit 1
+    fi
+    echo "Detecting active services.."
+    sv status /etc/service/*
+    service udev status
+    service rsyslog status
+    service cron status
+    service dbus status
+    #service --status-all # not usable since some services will exit nonzero 
with [?]
+    # we can test also ssh-server here if runit-init will recommend it
+    echo "OK"
+    echo "switching to runit init complete"
+ fi
+ echo "test done"
+ 
-- 
2.20.1

$ autopkgtest ./runit-init_2.1.2-32_all.deb ./runit_2.1.2-32_amd64.deb 
./getty-run_2.1.2-32_all.deb  ./runit -- qemu ./debian-unstable.img 
autopkgtest [01:29:40]: version 5.10
autopkgtest [01:29:40]: host lorenz; command line: /usr/bin/autopkgtest 
./runit-init_2.1.2-32_all.deb ./runit_2.1.2-32_amd64.deb 
./getty-run_2.1.2-32_all.deb ./runit -- qemu ./debian-unstable.img              
                                                                                
 
autopkgtest [01:29:55]: testbed dpkg architecture: amd64                        
                                                                 
autopkgtest [01:29:58]: testbed running kernel: Linux 4.19.0-5-amd64 #1 SMP 
Debian 4.19.37-3 (2019-05-15)                                        
autopkgtest [01:29:58]: @@@@@@@@@@@@@@@@@@@@ built-tree ./runit                 
                                                                 
autopkgtest [01:29:58]: testing package runit version 2.1.2-32                  
                                                                 
autopkgtest [01:29:58]: test init-switch: preparing testbed                     
                                                                 
Get:1 file:/tmp/autopkgtest.OMXnlL/binaries  InRelease
Ign:1 file:/tmp/autopkgtest.OMXnlL/binaries  InRelease
Get:2 file:/tmp/autopkgtest.OMXnlL/binaries  Release [816 B]
Get:2 file:/tmp/autopkgtest.OMXnlL/binaries  Release [816 B]
Get:3 file:/tmp/autopkgtest.OMXnlL/binaries  Release.gpg
Ign:3 file:/tmp/autopkgtest.OMXnlL/binaries  Release.gpg
Get:4 file:/tmp/autopkgtest.OMXnlL/binaries  Packages [3921 B]
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Correcting dependencies...Starting pkgProblemResolver with broken count: 1
Starting 2 pkgProblemResolver with broken count: 1
Investigating (0) libpam-systemd:amd64 < 241-5 @ii mK Ib >
Broken libpam-systemd:amd64 Depends on systemd-sysv:amd64 < 241-5 @ii mR >
  Considering systemd-sysv:amd64 3 as a solution to libpam-systemd:amd64 7
  Added systemd-sysv:amd64 to the remove list
  Fixing libpam-systemd:amd64 via keep of systemd-sysv:amd64
Investigating (1) runit-init:amd64 < none -> 2.1.2-32 @un uN Ib >
Broken runit-init:amd64 Conflicts on systemd-sysv:amd64 < 241-5 @ii mK >
  Considering systemd-sysv:amd64 3 as a solution to runit-init:amd64 106
  Added systemd-sysv:amd64 to the remove list
  Fixing runit-init:amd64 via remove of systemd-sysv:amd64
Investigating (1) libpam-systemd:amd64 < 241-5 @ii mK Ib >
Broken libpam-systemd:amd64 Depends on systemd-sysv:amd64 < 241-5 @ii mR >
  Considering systemd-sysv:amd64 3 as a solution to libpam-systemd:amd64 7
  Added systemd-sysv:amd64 to the remove list
  Fixing libpam-systemd:amd64 via keep of systemd-sysv:amd64
Investigating (2) runit-init:amd64 < none -> 2.1.2-32 @un uN Ib >
Broken runit-init:amd64 Conflicts on systemd-sysv:amd64 < 241-5 @ii mK >
  Considering systemd-sysv:amd64 3 as a solution to runit-init:amd64 106
  Added systemd-sysv:amd64 to the remove list
  Fixing runit-init:amd64 via remove of systemd-sysv:amd64
Investigating (2) libpam-systemd:amd64 < 241-5 @ii mK Ib >
Broken libpam-systemd:amd64 Depends on systemd-sysv:amd64 < 241-5 @ii mR >
  Considering systemd-sysv:amd64 106 as a solution to libpam-systemd:amd64 7
  Removing libpam-systemd:amd64 rather than change systemd-sysv:amd64
Done
 Done
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following additional packages will be installed:
  fgetty getty-run initscripts insserv psmisc runit runit-helper runit-init
  startpar sysuser-helper sysv-rc
Suggested packages:
  bootchart2
The following packages will be REMOVED:
  libpam-systemd systemd-sysv
The following NEW packages will be installed:
  fgetty getty-run initscripts insserv psmisc runit runit-helper runit-init
  startpar sysuser-helper sysv-rc
0 upgraded, 11 newly installed, 2 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 408 kB/578 kB of archives.
After this operation, 1403 kB of additional disk space will be used.
Get:1 file:/tmp/autopkgtest.OMXnlL/binaries  runit 2.1.2-32 [124 kB]
Get:2 file:/tmp/autopkgtest.OMXnlL/binaries  runit-init 2.1.2-32 [27.3 kB]
Get:3 file:/tmp/autopkgtest.OMXnlL/binaries  getty-run 2.1.2-32 [19.0 kB]
Get:4 http://deb.debian.org/debian unstable/main amd64 runit-helper all 2.8.6 
[4900 B]
Get:5 http://deb.debian.org/debian unstable/main amd64 sysuser-helper all 1.3.3 
[3844 B]
Get:6 http://deb.debian.org/debian unstable/main amd64 insserv amd64 1.18.0-2 
[64.8 kB]
Get:7 http://deb.debian.org/debian unstable/main amd64 startpar amd64 0.61-1 
[20.7 kB]
Get:8 http://deb.debian.org/debian unstable/main amd64 sysv-rc all 2.93-8 [71.0 
kB]
Get:9 http://deb.debian.org/debian unstable/main amd64 initscripts amd64 2.93-8 
[93.8 kB]
Get:10 http://deb.debian.org/debian unstable/main amd64 fgetty amd64 0.7-6 
[22.8 kB]
Get:11 http://deb.debian.org/debian unstable/main amd64 psmisc amd64 23.2-1 
[126 kB]
Fetched 408 kB in 1s (624 kB/s)
Selecting previously unselected package runit-helper.
(Reading database ... 18667 files and directories currently installed.)
Preparing to unpack .../runit-helper_2.8.6_all.deb ...
Unpacking runit-helper (2.8.6) ...
Selecting previously unselected package sysuser-helper.
Preparing to unpack .../sysuser-helper_1.3.3_all.deb ...
Unpacking sysuser-helper (1.3.3) ...
Selecting previously unselected package runit.
Preparing to unpack .../binaries/./runit.deb ...
runit: setting up for runsvchdir
runit: current symlink succesfully created
Unpacking runit (2.1.2-32) ...
(Reading database ... 18745 files and directories currently installed.)
Removing libpam-systemd:amd64 (241-5) ...
dpkg: systemd-sysv: dependency problems, but removing anyway as you requested:
 init depends on systemd-sysv | sysvinit-core | runit-init; however:
  Package systemd-sysv is to be removed.
  Package sysvinit-core is not installed.
  Package runit-init is not installed.

Removing systemd-sysv (241-5) ...
Selecting previously unselected package runit-init.
(Reading database ... 18722 files and directories currently installed.)
Preparing to unpack .../0-runit-init.deb ...
Unpacking runit-init (2.1.2-32) ...
Selecting previously unselected package getty-run.
Preparing to unpack .../1-getty-run.deb ...
Unpacking getty-run (2.1.2-32) ...
Selecting previously unselected package insserv.
Preparing to unpack .../2-insserv_1.18.0-2_amd64.deb ...
Unpacking insserv (1.18.0-2) ...
Selecting previously unselected package startpar.
Preparing to unpack .../3-startpar_0.61-1_amd64.deb ...
Unpacking startpar (0.61-1) ...
Selecting previously unselected package sysv-rc.
Preparing to unpack .../4-sysv-rc_2.93-8_all.deb ...
Unpacking sysv-rc (2.93-8) ...
Selecting previously unselected package initscripts.
Preparing to unpack .../5-initscripts_2.93-8_amd64.deb ...
Unpacking initscripts (2.93-8) ...
Selecting previously unselected package fgetty.
Preparing to unpack .../6-fgetty_0.7-6_amd64.deb ...
Unpacking fgetty (0.7-6) ...
Selecting previously unselected package psmisc.
Preparing to unpack .../7-psmisc_23.2-1_amd64.deb ...
Unpacking psmisc (23.2-1) ...
Setting up runit-helper (2.8.6) ...
Setting up psmisc (23.2-1) ...
Setting up startpar (0.61-1) ...
Setting up insserv (1.18.0-2) ...
insserv: FATAL: service mountkernfs has to exists for service udev
insserv: FATAL: service urandom has to exists for service networking
insserv: FATAL: service mountdevsubfs has to exists for service hwclock
insserv: exiting now!
Setting up sysuser-helper (1.3.3) ...
Setting up getty-run (2.1.2-32) ...
Setting up sysv-rc (2.93-8) ...
Setting up fgetty (0.7-6) ...
Setting up initscripts (2.93-8) ...
Setting up runit (2.1.2-32) ...
Setting up runit-init (2.1.2-32) ...
Setting up autopkgtest-satdep (0) ...
Processing triggers for systemd (241-5) ...
(Reading database ... 18938 files and directories currently installed.)
Removing autopkgtest-satdep (0) ...
autopkgtest [01:30:16]: test init-switch: [-----------------------
Killed
testbed is running with systemd
enabling the serial getty
Done
autopkgtest [01:30:17]: test process requested preparation for reboot with 
marker runit
autopkgtest-virt-qemu [01:30:18]: state saved, waiting for testbed to reboot...
detecting runit-init
OK
detecting gettys
1348 1339 1338 1337 1336 1335 1334
OK
Detecting active services..
run: /etc/service/getty-tty1: (pid 1337) 5s
run: /etc/service/getty-tty2: (pid 1339) 5s
run: /etc/service/getty-tty3: (pid 1334) 5s
run: /etc/service/getty-tty4: (pid 1348) 5s
run: /etc/service/getty-tty5: (pid 1335) 5s
run: /etc/service/getty-tty6: (pid 1336) 5s
run: /etc/service/getty-ttyS0: (pid 1338) 5s
systemd-udevd is running.
rsyslogd is running.
cron is running.
dbus is running.
OK
switching to runit init complete
test done
autopkgtest [01:30:34]: test init-switch: -----------------------]
autopkgtest [01:30:35]: test init-switch:  - - - - - - - - - - results - - - - 
- - - - - -
init-switch          PASS
autopkgtest [01:30:36]: @@@@@@@@@@@@@@@@@@@@ summary
init-switch          PASS
qemu-system-x86_64: terminating on signal 15 from pid 26125 (/usr/bin/python3)

Reply via email to