4

I'm trying to create a list of only the security updates available to an Ubuntu system using apt-get.

I'm very aware of this post How do I check only security updates from the command-line? but that only seems to work if there aren't any source lists present in /etc/apt/sources.list.d/

So far my code looks like this

#!/bin/bash
set -x

setup(){
        APTSRC="/etc/apt/sources.list"
        SECSRC="/etc/apt/secsource.list"
}

cleanup(){
        rm ${SECSRC}
}

get_updates(){
    grep trusty-security ${APTSRC} > ${SECSRC}
    apt-get -o Dir::Etc::sourcelist="${SECSRC##/*/}" -o Dir::Etc:sourceparts="." update &&  apt-get --assume-no upgrade
}

setup
get_updates
cleanup

It works for the most part, but because I have a few source lists present in /etc/apt/sources.list.d/ and it pulls those in. Is there a way I can avoid that via command line options?

I would like to add that we won't set up automatic updates. We just want a list of the updates.

  • I'm sure you can hack something together using this answer: askubuntu.com/a/443891/1736. It gives you the links of all installed packages that have updates available. Go through the result in a for loop and check if $(apt-cache policy $PACKAGE | grep trusty-security) is not empty. – mniess Dec 4 '14 at 1:39
2

Install the package apt-show-versions and run

apt-show-versions | grep upgradeable | grep security

to get a listing like this:

firefox:amd64/trusty-security 33.0+build2-0ubuntu0.14.04.1 upgradeable to 34.0+build2-0ubuntu0.14.04.1
firefox-locale-en:amd64/trusty-security 33.0+build2-0ubuntu0.14.04.1 upgradeable to 34.0+build2-0ubuntu0.14.04.1
0

To perform only security updates, I may recommend you to use a special tool - unattended-upgrades. Also, you may automate that process with the following wiki page: https://help.ubuntu.com/community/AutomaticSecurityUpdates

  • We won't want automatic updates – Matthew Dec 2 '14 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.