diff options
Diffstat (limited to 'debian')
-rw-r--r-- | debian/apt.systemd.daily | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily index a8d98494b..22cbbded6 100644 --- 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 @@ -423,9 +433,9 @@ if [ "$1" = "update" -o -z "$1" ] ; then 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 + debdelta-upgrade >/dev/null 2>&1 $LOCKFD>&- || true fi - if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR; then + if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR $LOCKFD>&-; then update_stamp $DOWNLOAD_UPGRADEABLE_STAMP debug_echo "download upgradable (success)" else @@ -436,7 +446,7 @@ if [ "$1" = "update" -o -z "$1" ] ; then fi if which unattended-upgrade >/dev/null 2>&1 && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $UnattendedUpgradeInterval; then - if unattended-upgrade -d $XUUPOPT; then + if unattended-upgrade -d $XUUPOPT $LOCKFD>&-; then update_stamp $DOWNLOAD_UPGRADEABLE_STAMP debug_echo "unattended-upgrade -d (success)" else @@ -451,7 +461,7 @@ 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; then + if unattended-upgrade $XUUPOPT $LOCKFD>&-; then update_stamp $UPGRADE_STAMP debug_echo "unattended-upgrade (success)" else |