Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I like to keep track of what's on my system and what is getting updated. However, there's a lot of tiny updates, e.g. gedit 3.6.2-1 to 3.6.2-2 that I don't want to think too much about.

Is there a simple way to make pacman highlight major updates, e.g. changes to the first or second segments in the version number? (Of course I realise that such a heuristic isn't very useful, but this seems like a problem that someone would have solved already.)

Here is an example with a lot of tiny updates:

automake            1.12.5-1      1.12.6-1     0.00 MiB                 
bison               2.6.5-1       2.7-1        0.03 MiB                 
cdrtools            3.01a09-1     3.01a10-1    0.00 MiB                 
cifs-utils          5.7-1         5.8-1        0.00 MiB                 
icu                 50.1-2        50.1.1-1     -0.04 MiB                
isl                 0.11-1        0.11.1-1     0.01 MiB                 
lib32-libpulse      2.1-1         3.0-1        0.03 MiB                 
lib32-sqlite        3.7.14.1-1    3.7.15-1     0.00 MiB                 
libpulse            2.1-1         3.0-2        0.16 MiB                 
libwbclient         3.6.9-1       3.6.10-1     0.00 MiB                 
linux               3.6.9-1       3.6.10-1     0.01 MiB                 
ntp                 4.2.6.p5-11   4.2.6.p5-13  -0.05 MiB                
pixman              0.28.0-1      0.28.2-1     0.00 MiB                 
pulseaudio          2.1-1         3.0-2        -0.05 MiB                
python2-beaker      1.6.3-2       1.6.4-1      0.03 MiB                 
python2-distribute  0.6.30-1      0.6.32-1     0.02 MiB                 
python2-mako        0.7.2-2       0.7.3-1      0.00 MiB                 
python2-pyparsing   1.5.6-3       1.5.7-1      0.00 MiB                 
python2-xdg         0.23-2        0.25-1       0.02 MiB                 
samba               3.6.9-1       3.6.10-1     0.02 MiB                 
sbc                               1.0-1        0.24 MiB                 
smbclient           3.6.9-1       3.6.10-1     0.00 MiB                 
sqlite              3.7.14.1-1    3.7.15-1     0.01 MiB                 
vlc                 2.0.4-5       2.0.5-1      -1.42 MiB                
wesnoth-data        1.10.5-1      1.10.5-2     98.07 MiB                
xorg-server         1.13.0.902-2  1.13.1-1     0.00 MiB                 
xorg-server-common  1.13.0.902-2  1.13.1-1     0.00 MiB   

Pulse Audio 2.1 -> 3.0 and a kernel update are hidden in there, and I'd like them to stand out more.

share|improve this question
    
The kernel update is actually a minor update, according to your definition. –  ire_and_curses Dec 19 '12 at 19:47
    
Well, I immediately conceded that such a heuristic is simplistic. I'd be happy with whatever solution gave me more useful output than I'm currently getting. –  Anna Dec 19 '12 at 19:53
add comment

1 Answer 1

I don't have pacman, but I tested this against your provided input sample, saved to a file and passed to standard in like this:

cat versioninfo.dat | python highlight_major_versions.py

You should be able to pipe the output of your pacman command to the code in the same way. The output on my machine looks like this:

enter image description here

Blue indicates a major version update (i.e. 1st segment). Yellow indicates a minor version update (2nd segment). Red indicates missing version info, in this case because the library is new in this update. I don't do anything clever with - versioning - the - counts as part of the relevant dot-delimited segment.

#!/usr/bin/env python    
import fileinput

# ANSI escape codes for some colours
BLUE   = '\033[94m'
YELLOW = '\033[93m'
RED    = '\033[91m'
ENDC   = '\033[0m'

def colourise_by_version_change(line, prev_v, new_v):
    ''' Colourise the input line based on major/minor version change.'''
    prev_segments = prev_v.split('.')
    new_segments  = new_v.split('.')

    coloured_line = line
    if new_segments[0] > prev_segments[0]:
        coloured_line = BLUE + line + ENDC   
    elif new_segments[1] > prev_segments[1]:
        coloured_line = YELLOW + line + ENDC

    return coloured_line

if __name__ == '__main__':   
    for line in fileinput.input():
        line     = line.strip()
        elements = line.split()
        if len(elements) == 5:
            name, prev_v, new_v, size, size_unit = elements[:5]
            line = colourise_by_version_change(line, prev_v, new_v)

        # There's something missing, so point it out (e.g. a new version)
        else:
            line = RED + line + ENDC

        print line
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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