[2019-01-11 07:41] Aleksi Suhonen <debian-reportbug-2...@ssd.axu.tm>
> part       text/plain                 828
> Package: initscripts
> Severity: wishlist
> Version: 2.93-3
> 
> After upgrading and rebooting a virtual machine that has only a virtual
> serial console, I get this message:
> 
> /etc/init.d/brightness: 36: /etc/init.d/brightness: cannot create 
> /sys/class/backlight/acpi_video0/brightness: Directory nonexistent

> It's not critical, but I'm wondering if desktop features could be 
> separated from this package. Or if there was a debconf knob to turn them 
> all on and off easily?

I understand your concern about desktop feature, but since it quite
simple shell script, I believe, there is no better place for it. If you
have idea, where `brightness' script suits better to, you are welcome!

> Also, the error message could be avoided with some more checking:
> 
> if [ -d /sys/class/backlight/acpi_video0 ]; then
>       readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness
>       readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness
> else
>       readonly SYS_CONTROL=/dev/null
>       readonly SYS_MAXIMUM=/dev/null
> fi

I like this approach the best. Here is pending patch. Feedback is
welcome, in wording in particular.

From 97e33ff24c857bf20f6d73a2d75c2d200acd0693 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <kact...@debian.org>
Date: Fri, 11 Jan 2019 13:31:21 +0000
Subject: [PATCH] Check in `brightness' initscript for backlight presence

Check for presence of backlight-related virtual files in `brightness'
initscript before trying to set values in them, since they can be
missing on systems with only a serial console. (Closes: #918966)
---
 debian/changelog                             | 2 ++
 debian/src/initscripts/etc/init.d/brightness | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a8336299..db5b0443 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ sysvinit (2.93-4) UNRELEASED; urgency=medium
   * Drop unneeded `40_multiarch_libcrypt.patch': upstream Makefile
     correctly supplies -lcrypt flag by itself.
   * Make debian/upstream/signing-key.asc minimal
+  * Check for presence of backlight-related virtual files in `brightness'
+    initscript (Closes: #918966)
 
  -- Dmitry Bogatov <kact...@debian.org>  Thu, 10 Jan 2019 19:45:28 +0000
 
diff --git a/debian/src/initscripts/etc/init.d/brightness 
b/debian/src/initscripts/etc/init.d/brightness
index 3e22bff8..93c1cb8a 100755
--- a/debian/src/initscripts/etc/init.d/brightness
+++ b/debian/src/initscripts/etc/init.d/brightness
@@ -9,13 +9,18 @@
 # Description:       This script saves the brightness level between restarts.
 #                    It is called from the boot, halt and reboot scripts.
 ### END INIT INFO
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
 readonly SAVEDFILE=/var/lib/initscripts/brightness
 readonly DEFAULT_LEVEL=4
 readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness
 readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness
 
-. /lib/init/vars.sh
-. /lib/lsb/init-functions
+if ! test -f "${SYS_CONTROL}" ; then
+       log_success_msg "Brightness control not supported: no backlight"
+       exit 0
+fi
 
 do_status () {
        MSG="Current brightness level is $(cat ${SYS_CONTROL})"

Reply via email to