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

Bug#859757: apt.systemd.daily: support zero-delay and short-delay unattended-upgrades



Package: apt
Severity: wishlist
Version: 1.4
File: /usr/lib/apt/apt.systemd.daily
Tags: patch

Currently the shortest time period between apt.systemd.daily running
unattended-upgrades is one day. Debian testing is currently upgraded
twice per day so it would be nice to be able to set upgrades to happen
every 12h, but sometimes local or third-party repos can be updated on a
faster schedule so it would be nice to be able to always upgrade.
I've attached a sketch of how enabling those options might work, it
adds an 'always' option for each interval option and also accepts all
interval values with the time unit appended (only 1 unit allowed).

-- 
bye,
pabs

https://wiki.debian.org/PaulWise
From 1355ccd20a42c33c8349d3efb07b0f3879d43431 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs@debian.org>
Date: Fri, 7 Apr 2017 08:18:17 +0800
Subject: [PATCH 1/2] Support zero delay for the various APT::Periodic
 activities

---
 debian/apt.systemd.daily | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily
index 03d41bae5..5e9ee4a2d 100755
--- a/debian/apt.systemd.daily
+++ b/debian/apt.systemd.daily
@@ -90,6 +90,12 @@ check_stamp()
         return 0
     fi
 
+    if [ $interval = always ]; then
+	debug_echo "check_stamp: ignoring time stamp file, interval set to always"
+	# treat as enough time has passed
+        return 0
+    fi
+
     # compare midnight today to midnight the day the stamp was updated
     stamp_file="$stamp"
     stamp=$(date --date=$(date -r $stamp_file --iso-8601) +%s 2>/dev/null)
-- 
2.11.0

From 656cc1f631471cd78245b4d7600674b18c788521 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs@debian.org>
Date: Fri, 7 Apr 2017 08:19:59 +0800
Subject: [PATCH 2/2] Support seconds, minutes, hours and days for
 APT::Periodic intervals

---
 debian/apt.systemd.daily | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily
index 5e9ee4a2d..59fe4d8a5 100755
--- a/debian/apt.systemd.daily
+++ b/debian/apt.systemd.daily
@@ -118,8 +118,20 @@ check_stamp()
 
     delta=$(($now-$stamp))
 
-    # interval is in days, convert to sec.
-    interval=$(($interval*60*60*24))
+    # Calculate the interval in seconds depending on the unit specified
+    if [ "${interval%s}" != "$interval" ] ; then
+        interval="${interval%s}"
+    elif [ "${interval%m}" != "$interval" ] ; then
+        interval="${interval%m}"
+        interval=$((interval*60))
+    elif [ "${interval%h}" != "$interval" ] ; then
+        interval="${interval%h}"
+        interval=$((interval*60*60))
+    else
+        interval="${interval%d}"
+        interval=$((interval*60*60*24))
+    fi
+
     debug_echo "check_stamp: interval=$interval, now=$now, stamp=$stamp, delta=$delta (sec)"
 
     # remove timestamps a day (or more) in the future and force re-check
-- 
2.11.0

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: