Your message dated Sun, 24 Jan 2010 13:26:13 +0100
with message-id <[email protected]>
and subject line Re: Bug#451259: nvram-wakeup: vdr shutdown script calculates 
wrong regular wake-up time
has caused the Debian Bug report #451259,
regarding nvram-wakeup: vdr shutdown script calculates wrong regular wake-up 
time
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
451259: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451259
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: nvram-wakeup
Version: 0.97-12
Severity: normal

The calculation of a regular wake-up time in 
/usr/share/vdr/shutdown-hooks/S90.nvram-wakeup is too simplistic and yields 
wake-up times too far ahead in the future potentially leading to missed 
recordings in VDR. The 
bug is triggered e.g. with REGULAR_TIME=08:00 and REGULAR_DAYS=1 when executed 
between 00:00 and 07:59, yielding a wake-up time at 08:00 the next day.

The following patch seems to fix this problem for me:

--- /tmp/S90.nvram-wakeup.org   2007-11-13 23:43:57.000000000 +0100
+++ /tmp/S90.nvram-wakeup.new   2007-11-13 23:43:12.000000000 +0100
@@ -43,8 +43,55 @@
 
 TIMER=$1
 
+# convert the time representation 'HH:MM' into seconds from midnight
+function hm2sec ()
+{
+       local HM=$1
+       # extract hours
+       local HOUR=${HM%:*}
+       # remove leading zero
+       HOUR=${HOUR#0}
+       # extract minutes
+       local MIN=${HM#*:}
+       # remove leading zero
+       MIN=${MIN#0}
+       if [ $HOUR -lt 0 ] || [ $HOUR -gt 23 ] || [ $MIN -lt 0 ] || [ $MIN -gt 
59 ]; then
+               echo "Invalid input for hm2sec: $HM" >&2
+               return 2
+       else
+               echo $[ $HOUR * 3600 + $MIN * 60 ]
+       fi
+}
+
+# convert the local time zone into an offset in seconds
+function tz2sec ()
+{
+       local TZ=$(date +%z)
+       local TZHM=${TZ:1:2}:${TZ:3:2}
+       local SEC=$(hm2sec $TZHM)
+       local SIGN=${TZ:0:1}
+       [ $SIGN == '-' ] && SEC=$(( $SEC * -1 ))
+       echo $SEC
+}
+
 if [ $REGULAR_DAYS -gt 0 ]; then
-    REGULAR_TIMER=$((`date -d "$REGULAR_TIME" +%s` + $REGULAR_DAYS * 24 * 60 * 
60))
+       # GMT epoch
+       NOW=$(date +%s)
+       # epoch offset by local TZ
+       TZNOW=$[ $NOW + `tz2sec` ]
+       # wake-up interval in seconds
+       STRIDE=$(($REGULAR_DAYS * 24 * 3600))
+       # rounddown (TZNOW, STRIDE) -> midnight of the most recent wake-up 
interval
+       INTERVAL_BASE=$((($TZNOW / $STRIDE) * $STRIDE))
+       # REGULAR_TIME configuration option in seconds: offset into each 
wake-up interval to match configured time of day
+       INTERVAL_OFFSET=`hm2sec $REGULAR_TIME`
+       # base + offset -> time to wake up at - due to the addition, this may 
lie in the past or the future
+       WAKEUP_TIME=$(($INTERVAL_BASE + $INTERVAL_OFFSET))
+       # convert wake-up time to GMT
+       WAKEUP_TIME=$(($WAKEUP_TIME - `tz2sec`))
+       # if in the past, this wake-up interval has truly expired and we need 
to wake up at the next one
+       [ $WAKEUP_TIME -lt $NOW ] && WAKEUP_TIME=$(($WAKEUP_TIME + $STRIDE))
+       REGULAR_TIMER=$WAKEUP_TIME
 
     # when no vdr timer is set or vdr timer starts later than regular timer:
     if [ $TIMER -eq 0 ] || [ $TIMER -gt 0 -a $REGULAR_TIMER -lt $TIMER ] ; then

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.23.1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages nvram-wakeup depends on:
ii  debconf [debconf-2.0]  1.5.11            Debian configuration management sy
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  makedev                2.3.1-83          creates device files in /dev

nvram-wakeup recommends no packages.

-- debconf information:
* nvram-wakeup/install_instruction:



--- End Message ---
--- Begin Message ---
Thanks for reporting this and sorry, for not answering this for such a
long time!

Stefan Goetz wrote:

> recordings in VDR. The
> bug is triggered e.g. with REGULAR_TIME=08:00 and REGULAR_DAYS=1 when
> executed between 00:00 and 07:59, yielding a wake-up time at 08:00 the
> next day.

This is the expected behaviour. The intention of REGULAR_TIME is to wake
up VDR at least once a day, if no timer triggers a wakeup. This is to
make sure, the EPG data gets updated and EpgSearch can create new timers.

In your example, if you shut down VDR at 00:01, there's no need to wake it
up at 8:00 again, because the EPG data already is up-to-date. And if no
other timer is set, it will wake up the next day at 8:00.

I'm not going to make any major changes to this anymore. It would be
better to invest some time in a completely independent wake up tool, which
 uses nvram-wakeup or ACPI and can be used by other applications as well.

Tobias

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

Reply via email to