diff options
author | Alan Jenkins <alan.christopher.jenkins@gmail.com> | 2017-05-14 18:11:59 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2017-05-19 11:23:14 +0200 |
commit | f06527a0fe17a6780f7a4a483a8226a6e795e3d6 (patch) | |
tree | c4936c5bedfe5486b80c4f0943414f32c6dbc860 | |
parent | a90a6f585030f768e01bd38cd0788a14551b52a2 (diff) |
apt.systemd.daily: fix error from locking code
Error:
pkgs that look like they should be upgraded:
Error in function stop
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apt/progress/text.py", line 240,
in stop
apt_pkg.size_to_str(self.current_cps))).rstrip("\n"))
File "/usr/lib/python3/dist-packages/apt/progress/text.py", line 51,
in _write
self._file.write("\r")
AttributeError: 'NoneType' object has no attribute 'write'
fetch.run() result: 0
Caused by:
LOCKFD=3
unattended_upgrades $LOCKFD>&-
Unfortunately this code does not work, it is equivalent to
unattended_upgrades 3 >&-
I.e. it left fd 3 open, but closed stdout!
Closes: #862567
(cherry picked from commit 7b4581cbe8fcf6e2bd56a27c5a7a1e6ea33d2973)
(cherry picked from commit 3310f862cba0b997ede8fc4e2d270ab0f6b49e73)
-rw-r--r-- | debian/apt.systemd.daily | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily index 22cbbded6..d2a0bfbed 100644 --- a/debian/apt.systemd.daily +++ b/debian/apt.systemd.daily @@ -294,12 +294,22 @@ debug_echo() # 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 + +if [ "$1" = "lock_is_held" ]; then + shift +else + 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 + + # We hold the lock. Rerun this script as a child process, which + # can run without propagating an extra fd to all of its children. + "$0" lock_is_held "$@" 3>&- + exit $? fi if test -r /var/lib/apt/extended_states; then @@ -433,9 +443,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 $LOCKFD>&- || true + debdelta-upgrade >/dev/null 2>&1 || true fi - if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR $LOCKFD>&-; then + if eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR; then update_stamp $DOWNLOAD_UPGRADEABLE_STAMP debug_echo "download upgradable (success)" else @@ -446,7 +456,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 $LOCKFD>&-; then + if unattended-upgrade -d $XUUPOPT; then update_stamp $DOWNLOAD_UPGRADEABLE_STAMP debug_echo "unattended-upgrade -d (success)" else @@ -461,7 +471,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 $LOCKFD>&-; then + if unattended-upgrade $XUUPOPT; then update_stamp $UPGRADE_STAMP debug_echo "unattended-upgrade (success)" else |