summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-05-04 22:52:01 +0200
committerJulian Andres Klode <jak@debian.org>2017-05-04 22:52:01 +0200
commit6bc40ffd444affd870e0053fa349575faa4d586f (patch)
tree13646d56868729ca730c1a4c674859de028de0f2 /debian
parent6ff527b4f8c88ac406effb1d88fdb3c9ab42967b (diff)
parent496313fb8e83af2ba71f6ce3d729be687c293dfd (diff)
Merge branch 'lp1686470'
Diffstat (limited to 'debian')
-rw-r--r--debian/apt-daily-upgrade.service9
-rw-r--r--debian/apt-daily-upgrade.timer11
-rw-r--r--debian/apt-daily.service4
-rw-r--r--debian/apt-daily.timer6
-rwxr-xr-xdebian/apt.systemd.daily163
-rwxr-xr-xdebian/rules2
6 files changed, 120 insertions, 75 deletions
diff --git a/debian/apt-daily-upgrade.service b/debian/apt-daily-upgrade.service
new file mode 100644
index 000000000..bf2776ac8
--- /dev/null
+++ b/debian/apt-daily-upgrade.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Daily apt upgrade and clean activities
+Documentation=man:apt(8)
+ConditionACPower=true
+After=apt-daily.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/lib/apt/apt.systemd.daily install
diff --git a/debian/apt-daily-upgrade.timer b/debian/apt-daily-upgrade.timer
new file mode 100644
index 000000000..79caf3b5c
--- /dev/null
+++ b/debian/apt-daily-upgrade.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Daily apt upgrade and clean activities
+After=apt-daily.timer
+
+[Timer]
+OnCalendar=*-*-* 6:00
+RandomizedDelaySec=60m
+Persistent=true
+
+[Install]
+WantedBy=timers.target
diff --git a/debian/apt-daily.service b/debian/apt-daily.service
index 904ed5d51..4a946afdd 100644
--- a/debian/apt-daily.service
+++ b/debian/apt-daily.service
@@ -1,9 +1,9 @@
[Unit]
-Description=Daily apt activities
+Description=Daily apt download activities
Documentation=man:apt(8)
ConditionACPower=true
[Service]
Type=oneshot
-ExecStart=/usr/lib/apt/apt.systemd.daily
+ExecStart=/usr/lib/apt/apt.systemd.daily update
diff --git a/debian/apt-daily.timer b/debian/apt-daily.timer
index 8ac13b0e9..735da2440 100644
--- a/debian/apt-daily.timer
+++ b/debian/apt-daily.timer
@@ -1,11 +1,11 @@
[Unit]
-Description=Daily apt activities
+Description=Daily apt download activities
After=network-online.target
Wants=network-online.target
[Timer]
-OnCalendar=*-*-* 6:00
-RandomizedDelaySec=60m
+OnCalendar=*-*-* 6,18:00
+RandomizedDelaySec=12h
Persistent=true
[Install]
diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily
index 03d41bae5..22cbbded6 100755
--- a/debian/apt.systemd.daily
+++ b/debian/apt.systemd.daily
@@ -292,6 +292,16 @@ debug_echo()
# ------------------------ main ----------------------------
+# Maintain a lock on fd 3, so we can't run the script twice at the same
+# time.
+LOCKFD=3
+eval $(apt-config shell StateDir Dir::State/d)
+exec 3>${StateDir}/daily_lock
+if ! flock -w 3600 $LOCKFD; then
+ echo "E: Could not acquire lock" >&2
+ exit 1
+fi
+
if test -r /var/lib/apt/extended_states; then
# Backup the 7 last versions of APT's extended_states file
# shameless copy from dpkg cron
@@ -384,97 +394,112 @@ if [ $UpdateInterval -eq 0 ] &&
exit 0
fi
-# deal with BackupArchiveInterval
-do_cache_backup $BackupArchiveInterval
+if [ "$1" = "update" -o -z "$1" ] ; then
+ # deal with BackupArchiveInterval
+ do_cache_backup $BackupArchiveInterval
-# include default system language so that "apt-get update" will
-# fetch the right translated package descriptions
-if [ -r /etc/default/locale ]; then
- . /etc/default/locale
- export LANG LANGUAGE LC_MESSAGES LC_ALL
-fi
+ # include default system language so that "apt-get update" will
+ # fetch the right translated package descriptions
+ if [ -r /etc/default/locale ]; then
+ . /etc/default/locale
+ export LANG LANGUAGE LC_MESSAGES LC_ALL
+ fi
-# update package lists
-UPDATED=0
-UPDATE_STAMP=/var/lib/apt/periodic/update-stamp
-if check_stamp $UPDATE_STAMP $UpdateInterval; then
- if eval apt-get $XAPTOPT -y update $XSTDERR; then
- debug_echo "download updated metadata (success)."
- if which dbus-send >/dev/null 2>&1 && pidof dbus-daemon >/dev/null 2>&1; then
- if dbus-send --system / app.apt.dbus.updated boolean:true ; then
- debug_echo "send dbus signal (success)"
+ # update package lists
+ UPDATED=0
+ UPDATE_STAMP=/var/lib/apt/periodic/update-stamp
+ if check_stamp $UPDATE_STAMP $UpdateInterval; then
+ if eval apt-get $XAPTOPT -y update $XSTDERR; then
+ debug_echo "download updated metadata (success)."
+ if which dbus-send >/dev/null 2>&1 && pidof dbus-daemon >/dev/null 2>&1; then
+ if dbus-send --system / app.apt.dbus.updated boolean:true ; then
+ debug_echo "send dbus signal (success)"
+ else
+ debug_echo "send dbus signal (error)"
+ fi
else
- debug_echo "send dbus signal (error)"
+ debug_echo "dbus signal not send (command not available)"
fi
+ update_stamp $UPDATE_STAMP
+ UPDATED=1
else
- debug_echo "dbus signal not send (command not available)"
+ debug_echo "download updated metadata (error)"
fi
- update_stamp $UPDATE_STAMP
- UPDATED=1
else
- debug_echo "download updated metadata (error)"
+ debug_echo "download updated metadata (not run)."
fi
-else
- debug_echo "download updated metadata (not run)."
-fi
-
-# download all upgradeable packages (if it is requested)
-DOWNLOAD_UPGRADEABLE_STAMP=/var/lib/apt/periodic/download-upgradeable-stamp
-if [ $UPDATED -eq 1 ] && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
- if [ $Debdelta -eq 1 ]; then
- debdelta-upgrade >/dev/null 2>&1 || true
+
+ # download all upgradeable packages (if it is requested)
+ DOWNLOAD_UPGRADEABLE_STAMP=/var/lib/apt/periodic/download-upgradeable-stamp
+ if [ $UPDATED -eq 1 ] && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
+ if [ $Debdelta -eq 1 ]; then
+ debdelta-upgrade >/dev/null 2>&1 $LOCKFD>&- || true
+ fi
+ if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR $LOCKFD>&-; then
+ update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
+ debug_echo "download upgradable (success)"
+ else
+ debug_echo "download upgradable (error)"
+ fi
+ else
+ debug_echo "download upgradable (not run)"
fi
- if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR; then
- update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
- debug_echo "download upgradable (success)"
+
+ if which unattended-upgrade >/dev/null 2>&1 && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $UnattendedUpgradeInterval; then
+ if unattended-upgrade -d $XUUPOPT $LOCKFD>&-; then
+ update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
+ debug_echo "unattended-upgrade -d (success)"
+ else
+ debug_echo "unattended-upgrade -d (error)"
+ fi
else
- debug_echo "download upgradable (error)"
+ debug_echo "unattended-upgrade -d (not run)"
fi
-else
- debug_echo "download upgradable (not run)"
fi
-# auto upgrade all upgradeable packages
-UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
-if which unattended-upgrade >/dev/null 2>&1 && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
- if unattended-upgrade $XUUPOPT; then
- update_stamp $UPGRADE_STAMP
- debug_echo "unattended-upgrade (success)"
+if [ "$1" = "install" -o -z "$1" ] ; then
+ # auto upgrade all upgradeable packages
+ UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
+ if which unattended-upgrade >/dev/null 2>&1 && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
+ if unattended-upgrade $XUUPOPT $LOCKFD>&-; then
+ update_stamp $UPGRADE_STAMP
+ debug_echo "unattended-upgrade (success)"
+ else
+ debug_echo "unattended-upgrade (error)"
+ fi
else
- debug_echo "unattended-upgrade (error)"
+ debug_echo "unattended-upgrade (not run)"
fi
-else
- debug_echo "unattended-upgrade (not run)"
-fi
-# clean package archive
-CLEAN_STAMP=/var/lib/apt/periodic/clean-stamp
-if check_stamp $CLEAN_STAMP $CleanInterval; then
- if eval apt-get $XAPTOPT -y clean $XSTDERR; then
- debug_echo "clean (success)."
- update_stamp $CLEAN_STAMP
+ # clean package archive
+ CLEAN_STAMP=/var/lib/apt/periodic/clean-stamp
+ if check_stamp $CLEAN_STAMP $CleanInterval; then
+ if eval apt-get $XAPTOPT -y clean $XSTDERR; then
+ debug_echo "clean (success)."
+ update_stamp $CLEAN_STAMP
+ else
+ debug_echo "clean (error)"
+ fi
else
- debug_echo "clean (error)"
+ debug_echo "clean (not run)"
fi
-else
- debug_echo "clean (not run)"
-fi
-# autoclean package archive
-AUTOCLEAN_STAMP=/var/lib/apt/periodic/autoclean-stamp
-if check_stamp $AUTOCLEAN_STAMP $AutocleanInterval; then
- if eval apt-get $XAPTOPT -y autoclean $XSTDERR; then
- debug_echo "autoclean (success)."
- update_stamp $AUTOCLEAN_STAMP
+ # autoclean package archive
+ AUTOCLEAN_STAMP=/var/lib/apt/periodic/autoclean-stamp
+ if check_stamp $AUTOCLEAN_STAMP $AutocleanInterval; then
+ if eval apt-get $XAPTOPT -y autoclean $XSTDERR; then
+ debug_echo "autoclean (success)."
+ update_stamp $AUTOCLEAN_STAMP
+ else
+ debug_echo "autoclean (error)"
+ fi
else
- debug_echo "autoclean (error)"
+ debug_echo "autoclean (not run)"
fi
-else
- debug_echo "autoclean (not run)"
-fi
-# check cache size
-check_size_constraints
+ # check cache size
+ check_size_constraints
+fi
#
# vim: set sts=4 ai :
diff --git a/debian/rules b/debian/rules
index 5f990c72e..247022398 100755
--- a/debian/rules
+++ b/debian/rules
@@ -37,7 +37,7 @@ override_dh_systemd_start:
# Do not restart "apt-daily.service" because this script runs
# unattended-upgrades. So if apt itself is upgraded as part of
# an unattended-upgrades run it would kill itself
- dh_systemd_start apt-daily.timer
+ dh_systemd_start apt-daily.timer apt-daily-upgrade.timer
override_dh_auto_configure-arch: flags=-DWITH_DOC=OFF
override_dh_auto_configure-indep: flags=-DWITH_DOC=ON