~ubuntu-core-dev/update-notifier/ubuntu

883 by Brian Murray
add support for the HWE End-of-Life notification via
1
#!/bin/sh -e
2
#
3
# helper for update-motd
4
5
6
# poor mans force
7
if [ "$1" = "--force" ]; then
8
    NEED_EOL_CHECK=yes
9
else
10
    NEED_EOL_CHECK=no
11
fi
12
13
# check time when we did the last update check
14
stamp="/var/lib/update-notifier/hwe-eol"
15
16
# get list dir
17
StateDir="/var/lib/apt/"
18
ListDir="lists/"
19
eval "$(apt-config shell StateDir Dir::State)"
20
eval "$(apt-config shell ListDir Dir::State::Lists)"
21
22
# get dpkg status file
23
DpkgStatus="/var/lib/dpkg/status"
24
eval "$(apt-config shell DpkgStatus Dir::State::status)"
25
26
# get sources.list file
27
EtcDir="etc/apt/"
28
SourceList="sources.list"
29
eval "$(apt-config shell EtcDir Dir::Etc)"
30
eval "$(apt-config shell SourceList Dir::Etc::sourcelist)"
31
32
# let the actual update be asynchronous to avoid stalling apt-get
33
cleanup() { rm -f "$tmpfile"; }
34
35
# check if we have a list file or sources.list that needs checking
36
if [ -e "$stamp" ]; then
37
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" "/$DpkgStatus" -type f -newer "$stamp" -print -quit)" ]; then
38
        NEED_EOL_CHECK=yes
39
    fi
40
else
41
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" -type f -print -quit)" ]; then
42
        NEED_EOL_CHECK=yes
43
    fi
44
fi
45
46
tmpfile=""
47
trap cleanup EXIT
48
tmpfile=$(mktemp -p $(dirname "$stamp"))
49
50
# output something for update-motd
51
if [ "$NEED_EOL_CHECK" = "yes" ]; then
52
    {
53
        # the script may exit with status 10 when a HWE update is needed
54
        /usr/bin/hwe-support-status || true
55
    } > "$tmpfile"
56
    mv "$tmpfile" "$stamp"
57
fi
58
59
# output what we have (either cached or newly generated)
60
cat "$stamp"