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

« back to all changes in this revision

Viewing changes to data/apt-cdrom-check

  • Committer: Julian Andres Klode
  • Date: 2019-04-29 19:38:51 UTC
  • Revision ID: juliank@ubuntu.com-20190429193851-501astod6vchq39j
Tags: 3.192.20
releasing package update-notifier version 3.192.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
# 0 - no ubuntu CD
7
7
# 1 - CD with packages 
8
8
# 2 - dist-upgrader CD
9
 
# 3 - addon CD
10
 
# 4 - aptoncd media
11
 
# (if the returncodes change, make sure to update src/gdu.c)
 
9
# 3 - aptoncd media
 
10
# (if the returncodes change, make sure to update src/cdroms.c)
12
11
13
12
 
14
13
mount_point="$1"
15
 
upgrader_dir="$mount_point/dists/stable/main/dist-upgrader/binary-all/"
16
 
addon_dir="$mount_point/app-install/"
17
14
aptoncd_file="$mount_point/aptoncd.info"
18
15
 
19
16
# sanity checks
22
19
fi
23
20
 
24
21
if [ -f "$aptoncd_file" ]; then
25
 
    exit 4
 
22
    exit 3
26
23
fi
27
24
 
28
 
if [ ! -d "$mount_point/ubuntu" ]; then
 
25
if [ ! -d "$mount_point/ubuntu" ] && [ ! -f "$mount_point/cdromupgrade" ]; then
29
26
    exit 0
30
27
fi
31
28
 
65
62
    return 1
66
63
fi
67
64
 
68
 
# we always return ADDON cd regardless if we know it already or not
69
 
# the rationale is that it easier for people this way and less 
70
 
# confusing
71
 
if [ -d "$addon_dir" ] && [ -x /usr/bin/gnome-app-install ]; then
72
 
    exit 3
73
 
fi
74
 
 
75
65
# [cdrom-id] -> cdrom-id  
76
66
if grep -s -q "$cdrom_id"  $apt_dir$apt_state_dir$apt_cdrom_list; then
77
67
    # already in sources.list, ignore
79
69
fi
80
70
 
81
71
# so this is a CD we don't know yet and it has packages. good!
 
72
THIS_VERSION=$(lsb_release -sr)
 
73
VERSION_ON_MEDIA=$(awk {'print $2'} "$mount_point/.disk/info")
82
74
 
83
75
# now check if it contains a signed dist-upgrader
84
 
if [ -d "$upgrader_dir" ]; then
85
 
    # ok, we have one, now check the authentication 
86
 
    GPG="gpgv --ignore-time-conflict --keyring /etc/apt/trusted.gpg"
87
 
    if $GPG "$upgrader_dir"/*.tar.gz.gpg "$upgrader_dir"/*.tar.gz; then
 
76
for d in "$mount_point"/dists/*/main/dist-upgrader/binary-all/; do
 
77
    if [ -d "$d" ]; then
 
78
        # ok, we have one, now check the authentication 
 
79
        GPG="gpgv --ignore-time-conflict --keyring /etc/apt/trusted.gpg"
 
80
        if $GPG "$d/"*.tar.gz.gpg "$d"/*.tar.gz; then
88
81
        # verified ok, we have a valid upgrader, if it was not ok, the
89
82
        # fallback to the end is ok because we still have packages on it
90
 
        exit 2
 
83
            if dpkg --compare-versions "$THIS_VERSION" lt "$VERSION_ON_MEDIA"; then
 
84
                exit 2
 
85
            fi
 
86
        fi
91
87
    fi
92
 
fi
 
88
done
93
89
 
94
90
# we got an ubuntu CD with packages
95
 
exit 1
 
91
if dpkg --compare-versions "$THIS_VERSION" lt "$VERSION_ON_MEDIA"; then
 
92
    exit 1
 
93
fi