~ubuntu-branches/debian/experimental/apt/experimental

« back to all changes in this revision

Viewing changes to debian/apt.cron.daily

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-02-18 22:07:23 UTC
  • mfrom: (9.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100218220723-zb7zdh6fmsmp30tr
Tags: 0.7.26~exp2
fix crash when LANGUAGE is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
 
#
3
 
 
4
2
#set -e
5
3
#
6
4
# This file understands the following apt configuration variables:
7
 
#
8
 
#  "APT::Periodic::Update-Package-Lists=1"
 
5
# Values here are the default.
 
6
# Create /etc/apt/apt.conf.d/02periodic file to set your preference.
 
7
#
 
8
#  Dir "/";
 
9
#  - RootDir for all configuration files
 
10
#
 
11
#  Dir::Cache "var/apt/cache/";
 
12
#  - Set apt package cache directory
 
13
#
 
14
#  Dir::Cache::Archive "archives/";
 
15
#  - Set package archive directory
 
16
#
 
17
#  APT::Periodic::Enable "1";
 
18
#  - Enable the update/upgrade script (0=disable)
 
19
#
 
20
#  APT::Periodic::BackupArchiveInterval "0";
 
21
#  - Backup after n-days if archive contents changed.(0=disable)
 
22
#
 
23
#  APT::Periodic::BackupLevel "3";
 
24
#  - Backup level.(0=disable), 1 is invalid.
 
25
#
 
26
#  Dir::Cache::Backup "backup/";
 
27
#  - Set periodic package backup directory
 
28
#
 
29
#  APT::Archives::MaxAge "0"; (old, deprecated)
 
30
#  APT::Periodic::MaxAge "0"; (new)
 
31
#  - Set maximum allowed age of a cache package file. If a cache 
 
32
#    package file is older it is deleted (0=disable)
 
33
#
 
34
#  APT::Archives::MinAge "2"; (old, deprecated)
 
35
#  APT::Periodic::MinAge "2"; (new)
 
36
#  - Set minimum age of a package file. If a file is younger it
 
37
#    will not be deleted (0=disable). Usefull to prevent races 
 
38
#    and to keep backups of the packages for emergency.
 
39
#
 
40
#  APT::Archives::MaxSize "0"; (old, deprecated)
 
41
#  APT::Periodic::MaxSize "0"; (new)
 
42
#  - Set maximum size of the cache in MB (0=disable). If the cache
 
43
#    is bigger, cached package files are deleted until the size
 
44
#    requirement is met (the biggest packages will be deleted 
 
45
#    first).
 
46
#
 
47
#  APT::Periodic::Update-Package-Lists "0";
9
48
#  - Do "apt-get update" automatically every n-days (0=disable)
10
49
#    
11
 
#  "APT::Periodic::Download-Upgradeable-Packages=0",
 
50
#  APT::Periodic::Download-Upgradeable-Packages "0";
12
51
#  - Do "apt-get upgrade --download-only" every n-days (0=disable)
13
 
14
 
#  "APT::Periodic::AutocleanInterval"
15
 
#  - Do "apt-get autoclean" every n-days (0=disable)
16
 
#
17
 
#  "APT::Periodic::Unattended-Upgrade"
 
52
#
 
53
#  APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";
 
54
#  - Use debdelta-upgrade to download updates if available (0=disable)
 
55
#
 
56
#  APT::Periodic::Unattended-Upgrade "0";
18
57
#  - Run the "unattended-upgrade" security upgrade script 
19
58
#    every n-days (0=disabled)
20
59
#    Requires the package "unattended-upgrades" and will write
21
60
#    a log in /var/log/unattended-upgrades
22
61
23
 
#  "APT::Archives::MaxAge",
24
 
#  - Set maximum allowed age of a cache package file. If a cache 
25
 
#    package file is older it is deleted (0=disable)
26
 
#
27
 
#  "APT::Archives::MaxSize",
28
 
#  - Set maximum size of the cache in MB (0=disable). If the cache
29
 
#    is bigger, cached package files are deleted until the size
30
 
#    requirement is met (the biggest packages will be deleted 
31
 
#    first).
32
 
#
33
 
#  "APT::Archives::MinAge"
34
 
#  - Set minimum age of a package file. If a file is younger it
35
 
#    will not be deleted (0=disable). Usefull to prevent races 
36
 
#    and to keep backups of the packages for emergency.
37
 
 
62
#  APT::Periodic::AutocleanInterval "0";
 
63
#  - Do "apt-get autoclean" every n-days (0=disable)
 
64
#
 
65
#  APT::Periodic::Verbose "0";
 
66
#  - Send report mail to root
 
67
#      0:  no report             (or null string)
 
68
#      1:  progress report       (actually any string)
 
69
#      2:  + command outputs     (remove -qq, remove 2>/dev/null, add -d)
 
70
#      3:  + trace on            
38
71
 
39
72
check_stamp()
40
73
{
42
75
    interval="$2"
43
76
 
44
77
    if [ $interval -eq 0 ]; then
 
78
        debug_echo "check_stamp: interval=0"
 
79
        # treat as no time has passed
45
80
        return 1
46
81
    fi
47
82
 
48
83
    if [ ! -f $stamp ]; then
 
84
        debug_echo "check_stamp: missing time stamp file: $stamp."
 
85
        # treat as enough time has passed
49
86
        return 0
50
87
    fi
51
88
 
52
89
    # compare midnight today to midnight the day the stamp was updated
53
 
    stamp=$(date --date=$(date -r $stamp --iso-8601) +%s)
54
 
    now=$(date --date=$(date --iso-8601) +%s)
 
90
    stamp_file="$stamp"
 
91
    stamp=$(date --date=$(date -r $stamp_file --iso-8601) +%s 2>/dev/null)
 
92
    if [ "$?" != "0" ]; then
 
93
        # Due to some timezones returning 'invalid date' for midnight on
 
94
        # certain dates (eg America/Sao_Paulo), if date returns with error
 
95
        # remove the stamp file and return 0. See coreutils bug:
 
96
        # http://lists.gnu.org/archive/html/bug-coreutils/2007-09/msg00176.html
 
97
        rm -f "$stamp_file"
 
98
        return 0
 
99
    fi
 
100
 
 
101
    now=$(date --date=$(date --iso-8601) +%s 2>/dev/null)
 
102
    if [ "$?" != "0" ]; then
 
103
        # As above, due to some timezones returning 'invalid date' for midnight
 
104
        # on certain dates (eg America/Sao_Paulo), if date returns with error
 
105
        # return 0.
 
106
        return 0
 
107
    fi
 
108
 
55
109
    delta=$(($now-$stamp))
56
110
 
57
 
    # intervall is in days,
 
111
    # intervall is in days, convert to sec.
58
112
    interval=$(($interval*60*60*24))
59
 
    #echo "stampfile: $1"
60
 
    #echo "interval=$interval, now=$now, stamp=$stamp, delta=$delta"
 
113
    debug_echo "check_stamp: interval=$interval, now=$now, stamp=$stamp, delta=$delta (sec)"
 
114
 
 
115
    # remove timestamps a day (or more) in the future and force re-check
 
116
    if [ $stamp -gt $(($now+86400)) ]; then
 
117
         echo "WARNING: file $stamp_file has a timestamp in the future: $stamp"
 
118
         rm -f "$stamp_file"
 
119
         return 0
 
120
    fi
61
121
 
62
122
    if [ $delta -ge $interval ]; then
63
123
        return 0
69
129
update_stamp()
70
130
{
71
131
    stamp="$1"
72
 
 
73
132
    touch $stamp
74
133
}
75
134
 
76
 
 
77
 
 
78
135
# we check here if autoclean was enough sizewise
79
136
check_size_constraints()
80
137
{
81
 
    # min-age in days
82
138
    MaxAge=0
 
139
    eval $(apt-config shell MaxAge APT::Archives::MaxAge)
 
140
    eval $(apt-config shell MaxAge APT::Periodic::MaxAge)
 
141
 
83
142
    MinAge=2
 
143
    eval $(apt-config shell MinAge APT::Archives::MinAge)
 
144
    eval $(apt-config shell MinAge APT::Periodic::MinAge)
 
145
 
84
146
    MaxSize=0
85
 
    CacheDir="var/cache/apt"
86
 
    CacheArchive="archives/"
87
 
    eval $(apt-config shell MaxAge APT::Archives::MaxAge)
88
 
    eval $(apt-config shell MinAge APT::Archives::MinAge)
89
147
    eval $(apt-config shell MaxSize APT::Archives::MaxSize)
90
 
    eval $(apt-config shell Dir Dir)
 
148
    eval $(apt-config shell MaxSize APT::Periodic::MaxSize)
 
149
 
 
150
    CacheDir="var/cache/apt/"
91
151
    eval $(apt-config shell CacheDir Dir::Cache)
 
152
    CacheDir=${CacheDir%/}
 
153
 
 
154
    CacheArchive="archives/"
92
155
    eval $(apt-config shell CacheArchive Dir::Cache::archives)
 
156
    CacheArchive=${CacheArchive%/}
93
157
 
94
158
    # sanity check
95
159
    if [ -z "$CacheDir" -o -z "$CacheArchive" ]; then
101
165
 
102
166
    # check age
103
167
    if [ ! $MaxAge -eq 0 ] && [ ! $MinAge -eq 0 ]; then
 
168
        debug_echo "aged: ctime <$MaxAge and mtime <$MaxAge and ctime>$MinAge and mtime>$MinAge"
104
169
        find $Cache -name "*.deb"  \( -mtime +$MaxAge -and -ctime +$MaxAge \) -and -not \( -mtime -$MinAge -or -ctime -$MinAge \) -print0 | xargs -r -0 rm -f
105
170
    elif [ ! $MaxAge -eq 0 ]; then
 
171
        debug_echo "aged: ctime <$MaxAge and mtime <$MaxAge only"
106
172
        find $Cache -name "*.deb"  -ctime +$MaxAge -and -mtime +$MaxAge -print0 | xargs -r -0 rm -f
 
173
    else
 
174
        debug_echo "skip aging since MaxAge is 0"
107
175
    fi
108
176
    
109
177
    # check size
121
189
            size=${du%%/*}
122
190
            # check if the cache is small enough
123
191
            if [ $size -lt $MaxSize ]; then
 
192
                debug_echo "end remove by archive size:  size=$size < $MaxSize"
124
193
                break
125
194
            fi
126
195
 
127
196
            # check for MinAge of the file
128
 
            if [ ! $MinAge -eq 0 ]; then 
 
197
            if [ $MinAge -ne 0 ]; then 
129
198
                # check both ctime and mtime 
130
199
                mtime=$(stat -c %Y $file)
131
200
                ctime=$(stat -c %Z $file)
134
203
                else
135
204
                    delta=$(($now-$ctime))
136
205
                fi
137
 
                #echo "$file ($delta), $MinAge"
138
206
                if [ $delta -le $MinAge ]; then
139
 
                    #echo "Skiping $file (delta=$delta)"
 
207
                    debug_echo "skip remove by archive size:  $file, delta=$delta < $MinAgeSec"
140
208
                    break
 
209
                else
 
210
                    # delete oldest file
 
211
                    debug_echo "remove by archive size: $file, delta=$delta >= $MinAgeSec (sec), size=$size >= $MaxSize"
 
212
                    rm -f $file
141
213
                fi
142
214
            fi
143
 
 
144
 
            # delete oldest file
145
 
            rm -f $file
146
215
        done
147
216
    fi
148
217
}
149
218
 
 
219
# deal with the Apt::Periodic::BackupArchiveInterval
 
220
do_cache_backup()
 
221
{
 
222
    BackupArchiveInterval="$1"
 
223
    if [ $BackupArchiveInterval -eq 0 ]; then
 
224
        return
 
225
    fi
 
226
 
 
227
    # Set default values and normalize
 
228
    Dir="/"
 
229
    eval $(apt-config shell Dir Dir)
 
230
    Dir=${Dir%/}
 
231
 
 
232
    CacheDir="var/cache/apt/"
 
233
    eval $(apt-config shell CacheDir Dir::Cache)
 
234
    CacheDir=${CacheDir%/}
 
235
    if [ -z "$CacheDir" ]; then
 
236
        debug_echo "practically empty Dir::Cache, exiting"
 
237
        return 0
 
238
    fi
 
239
 
 
240
    CacheArchive="archives/"
 
241
    eval $(apt-config shell CacheArchive Dir::Cache::Archives)
 
242
    CacheArchive=${CacheArchive%/}
 
243
    if [ -z "$CacheArchive" ]; then
 
244
        debug_echo "practically empty Dir::Cache::archives, exiting"
 
245
        return 0
 
246
    fi
 
247
 
 
248
    BackupLevel=3
 
249
    eval $(apt-config shell BackupLevel APT::Periodic::BackupLevel)
 
250
    if [ $BackupLevel -le 1 ]; then 
 
251
        BackupLevel=2 ; 
 
252
    fi
 
253
    
 
254
    CacheBackup="backup/"
 
255
    eval $(apt-config shell CacheBackup Dir::Cache::Backup)
 
256
    CacheBackup=${CacheBackup%/}
 
257
    if [ -z "$CacheBackup" ]; then
 
258
        echo "practically empty Dir::Cache::Backup, exiting" 1>&2
 
259
        return
 
260
    fi
 
261
 
 
262
    Cache="${Dir}/${CacheDir}/${CacheArchive}/"
 
263
    Back="${Dir}/${CacheDir}/${CacheBackup}/"
 
264
    BackX="${Back}${CacheArchive}/"
 
265
    for x in $(seq 0 1 $((${BackupLevel}-1))); do 
 
266
        eval "Back${x}=${Back}${x}/"
 
267
    done
 
268
    
 
269
    # backup after n-days if archive contents changed.
 
270
    # (This uses hardlink to save disk space)
 
271
    BACKUP_ARCHIVE_STAMP=/var/lib/apt/periodic/backup-archive-stamp
 
272
    if check_stamp $BACKUP_ARCHIVE_STAMP $BackupArchiveInterval; then
 
273
        if [ $({(cd $Cache 2>/dev/null; find . -name "*.deb"); (cd $Back0 2>/dev/null;find . -name "*.deb") ;}| sort|uniq -u|wc -l) -ne 0 ]; then
 
274
            mkdir -p $Back
 
275
            rm -rf $Back$((${BackupLevel}-1))
 
276
            for y in $(seq $((${BackupLevel}-1)) -1 1); do 
 
277
                eval BackY=${Back}$y
 
278
                eval BackZ=${Back}$(($y-1))
 
279
                if [ -e $BackZ ]; then 
 
280
                    mv -f $BackZ $BackY ; 
 
281
                fi
 
282
            done
 
283
            cp -la $Cache $Back ; mv -f $BackX $Back0
 
284
            update_stamp $BACKUP_ARCHIVE_STAMP
 
285
            debug_echo "backup with hardlinks. (success)"
 
286
        else
 
287
            debug_echo "skip backup since same content."
 
288
        fi
 
289
    else
 
290
        debug_echo "skip backup since too new."
 
291
    fi
 
292
}
 
293
 
150
294
# sleep for a random interval of time (default 30min)
151
295
# (some code taken from cron-apt, thanks)
152
296
random_sleep()
161
305
        RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
162
306
    fi
163
307
    TIME=$(($RANDOM % $RandomSleep))
 
308
    debug_echo "sleeping for $TIME seconds"
164
309
    sleep $TIME
165
310
}
166
311
 
167
 
# main
168
 
 
169
 
if ! which apt-config >/dev/null; then
170
 
        exit 0
171
 
fi
 
312
 
 
313
debug_echo()
 
314
{
 
315
    # Display message if $VERBOSE >= 1
 
316
    if [ "$VERBOSE" -ge 1 ]; then
 
317
        echo $1 1>&2
 
318
    fi
 
319
}
 
320
 
 
321
# ------------------------ main ----------------------------
 
322
 
 
323
# check apt-config exstance
 
324
if ! which apt-config >/dev/null ; then
 
325
        exit 0
 
326
fi
 
327
 
 
328
# check if the user really wants to do something
 
329
AutoAptEnable=1  # default is yes
 
330
eval $(apt-config shell AutoAptEnable APT::Periodic::Enable)
 
331
 
 
332
if [ $AutoAptEnable -eq 0 ]; then
 
333
    exit 0
 
334
fi
 
335
 
 
336
# Set VERBOSE mode from  apt-config (or inherit from environment)
 
337
VERBOSE=0
 
338
eval $(apt-config shell VERBOSE APT::Periodic::Verbose)
 
339
debug_echo "verbose level $VERBOSE"
 
340
if [ "$VERBOSE" -le 2 ]; then
 
341
    # quiet for 0,1,2
 
342
    XSTDOUT=">/dev/null"
 
343
    XSTDERR="2>/dev/null"
 
344
    XAPTOPT="-qq"
 
345
    XUUPOPT=""
 
346
else
 
347
    XSTDOUT=""
 
348
    XSTDERR=""
 
349
    XAPTOPT=""
 
350
    XUUPOPT="-d"
 
351
fi
 
352
if [ "$VERBOSE" -ge 3 ]; then
 
353
    # trace output
 
354
    set -x
 
355
fi
 
356
 
 
357
# laptop check, on_ac_power returns:
 
358
#       0 (true)    System is on main power
 
359
#       1 (false)   System is not on main power
 
360
#       255 (false) Power status could not be determined
 
361
# Desktop systems always return 255 it seems
 
362
if which on_ac_power >/dev/null; then
 
363
    on_ac_power
 
364
    POWER=$?
 
365
    if [ $POWER -eq 1 ]; then
 
366
        debug_echo "exit: system NOT on main power"
 
367
        exit 0
 
368
    elif [ $POWER -ne 0 ]; then
 
369
        debug_echo "power status ($POWER) undetermined, continuing"
 
370
    fi
 
371
    debug_echo "system is on main power."
 
372
fi
 
373
 
 
374
# check if we can lock the cache and if the cache is clean
 
375
if which apt-get >/dev/null && ! eval apt-get check -f $XAPTOPT $XSTDERR ; then
 
376
    debug_echo "error encountered in cron job with \"apt-get check\"."
 
377
    exit 0
 
378
fi
 
379
 
 
380
# Global current time in seconds since 1970-01-01 00:00:00 UTC
 
381
now=$(date +%s)
 
382
 
 
383
# Support old Archive for compatibility.
 
384
# Document only Periodic for all controling parameters of this script.
172
385
 
173
386
UpdateInterval=0
 
387
eval $(apt-config shell UpdateInterval APT::Periodic::Update-Package-Lists)
 
388
 
174
389
DownloadUpgradeableInterval=0
175
 
eval $(apt-config shell UpdateInterval APT::Periodic::Update-Package-Lists DownloadUpgradeableInterval APT::Periodic::Download-Upgradeable-Packages)
176
 
AutocleanInterval=$DownloadUpgradeableInterval
177
 
eval $(apt-config shell AutocleanInterval APT::Periodic::AutocleanInterval)
 
390
eval $(apt-config shell DownloadUpgradeableInterval APT::Periodic::Download-Upgradeable-Packages)
 
391
 
178
392
UnattendedUpgradeInterval=0
179
393
eval $(apt-config shell UnattendedUpgradeInterval APT::Periodic::Unattended-Upgrade)
180
394
 
181
 
# check if we actually have to do anything
 
395
AutocleanInterval=0
 
396
eval $(apt-config shell AutocleanInterval APT::Periodic::AutocleanInterval)
 
397
 
 
398
BackupArchiveInterval=0
 
399
eval $(apt-config shell BackupArchiveInterval APT::Periodic::BackupArchiveInterval)
 
400
 
 
401
Debdelta=1
 
402
eval $(apt-config shell Debdelta APT::Periodic::Download-Upgradeable-Packages-Debdelta)
 
403
 
 
404
# check if we actually have to do anything that requires locking the cache
182
405
if [ $UpdateInterval -eq 0 ] &&
183
406
   [ $DownloadUpgradeableInterval -eq 0 ] &&
184
407
   [ $UnattendedUpgradeInterval -eq 0 ] &&
 
408
   [ $BackupArchiveInterval -eq 0 ] &&
185
409
   [ $AutocleanInterval -eq 0 ]; then
 
410
 
 
411
    # check cache size
 
412
    check_size_constraints
 
413
 
186
414
    exit 0
187
415
fi
188
416
 
189
 
# laptop check, on_ac_power returns:
190
 
#       0 (true)    System is on mains power
191
 
#       1 (false)   System is not on mains power
192
 
#       255 (false) Power status could not be determined
193
 
# Desktop systems always return 255 it seems
194
 
if which on_ac_power >/dev/null; then
195
 
    on_ac_power
196
 
    if [ $? -eq 1 ]; then
197
 
        exit 0
198
 
    fi
199
 
fi
 
417
# deal with BackupArchiveInterval
 
418
do_cache_backup $BackupArchiveInterval
200
419
 
201
420
# sleep random amount of time to avoid hitting the 
202
421
# mirrors at the same time
203
422
random_sleep
204
423
 
205
 
# check if we can access the cache
206
 
if ! apt-get check -q -q 2>/dev/null; then
207
 
    # wait random amount of time before retrying
208
 
    random_sleep
209
 
    # check again
210
 
    if ! apt-get check -q -q 2>/dev/null; then
211
 
        echo "$0: could not lock the APT cache while performing daily cron job. "
212
 
        echo "Is another package manager working?"
213
 
        exit 1
214
 
    fi
215
 
fi
216
 
 
 
424
# update package lists
 
425
UPDATED=0
217
426
UPDATE_STAMP=/var/lib/apt/periodic/update-stamp
218
427
if check_stamp $UPDATE_STAMP $UpdateInterval; then
219
 
    if apt-get -qq update 2>/dev/null; then
220
 
        if which dbus-send >/dev/null && pidof dbus-daemon >/dev/null; then
221
 
            dbus-send --system / app.apt.dbus.updated boolean:true
222
 
        fi
223
 
        update_stamp $UPDATE_STAMP
 
428
    if eval apt-get $XAPTOPT -y update $XSTDERR; then
 
429
        debug_echo "download updated metadata (success)."
 
430
        if which dbus-send >/dev/null && pidof dbus-daemon >/dev/null; then
 
431
            if dbus-send --system / app.apt.dbus.updated boolean:true ; then
 
432
                debug_echo "send dbus signal (success)"
 
433
            else
 
434
                debug_echo "send dbus signal (error)"
 
435
            fi
 
436
        else
 
437
            debug_echo "dbus signal not send (command not available)"
 
438
        fi
 
439
        update_stamp $UPDATE_STAMP
 
440
        UPDATED=1
 
441
    else
 
442
        debug_echo "download updated metadata (error)"
224
443
    fi
 
444
else
 
445
    debug_echo "download updated metadata (not run)."
225
446
fi
226
 
 
 
447
        
 
448
# download all upgradeable packages (if it is requested)
227
449
DOWNLOAD_UPGRADEABLE_STAMP=/var/lib/apt/periodic/download-upgradeable-stamp
228
 
if check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
229
 
    apt-get -qq -d dist-upgrade 2>/dev/null
230
 
    update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
 
450
if [ $UPDATED -eq 1 ] && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
 
451
    if [ $Debdelta -eq 1 ]; then
 
452
        debdelta-upgrade >/dev/null 2>&1 || true
 
453
    fi
 
454
    if  eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR; then
 
455
        update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
 
456
        debug_echo "download upgradable (success)"
 
457
    else
 
458
        debug_echo "download upgradable (error)"
 
459
    fi
 
460
else
 
461
    debug_echo "download upgradable (not run)"
231
462
fi
232
463
 
 
464
# auto upgrade all upgradeable packages
233
465
UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
234
 
if check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
235
 
    unattended-upgrade
236
 
    update_stamp $UPGRADE_STAMP
 
466
if [ $UPDATED -eq 1 ] && which unattended-upgrade >/dev/null && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
 
467
    if unattended-upgrade $XUUPOPT; then
 
468
        update_stamp $UPGRADE_STAMP
 
469
        debug_echo "unattended-upgrade (success)"
 
470
    else
 
471
        debug_echo "unattended-upgrade (error)"
 
472
    fi
 
473
else
 
474
    debug_echo "unattended-upgrade (not run)"
237
475
fi
238
476
 
 
477
# autoclean package archive
239
478
AUTOCLEAN_STAMP=/var/lib/apt/periodic/autoclean-stamp
240
479
if check_stamp $AUTOCLEAN_STAMP $AutocleanInterval; then
241
 
    apt-get -qq autoclean
242
 
    update_stamp $AUTOCLEAN_STAMP
 
480
    if  eval apt-get $XAPTOPT -y autoclean $XSTDERR; then
 
481
        debug_echo "autoclean (success)."
 
482
        update_stamp $AUTOCLEAN_STAMP
 
483
    else
 
484
        debug_echo "autoclean (error)"
 
485
    fi
 
486
else
 
487
    debug_echo "autoclean (not run)"
243
488
fi
244
489
 
245
490
# check cache size 
246
491
check_size_constraints
 
492
 
 
493
#
 
494
#     vim: set sts=4 ai :
 
495
#
 
496