Search code examples
linuxversioningpackageapt-getaptitude

How to compare installed Linux packages between two machines


I need to display a list of Linux software packages that differ in version between a ‘build machine’ and various ‘developer machines’ that can diverge over time from the build VM.

I can get quite far by doing a “dpkg –l” to obtain a text dump of the packages installed on the gold VM versus other boxes, and then doing things like a "diff" or “awk grep” on the two lists, but I wondered if there was already a tool that does a better job than me writing a script for the job.

How do you guys do this?

Jean-Pierre


Solution

  • I just coded this script, which compares also package versions:

    https://github.com/lepe/scripts/blob/master/compare_ubuntu_apt.pl

    Usage:

    1) Generate package list in both computers, like:

    apt --installed list | tail -n+2 > that_server.lst
    

    2) Execute the perl script:

    ./compare_ubuntu_apt.pl this_server.lst that_server.lst
    

    Results: (example)

    ----------------------------------
     DIFFERENCES 
    ----------------------------------
     @ apparmor : 2.8.95~2430-0ubuntu5.2 -> 2.8.95~2430-0ubuntu5.3
     @ apt : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
     @ apt-transport-https : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
     @ apt-utils : 1.0.1ubuntu2.8 -> 1.0.1ubuntu2.10
     @ base-files : 7.2ubuntu5.2 -> 7.2ubuntu5.3
     @ bash-completion : 1:2.1-4 -> 1:2.1-4ubuntu0.1
    ----------------------------------
     MISSING IN this_server.lst
    ----------------------------------
     + acl : 2.2.52-1
     + acpid : 1:2.0.21-1ubuntu2
     + apport : 2.14.1-0ubuntu3.11
     + apport-symptoms : 0.20
     + at : 3.1.14-1ubuntu1
     + at-spi2-core : 2.10.2.is.2.10.1-0ubuntu1
     + attr : 1:2.4.47-1ubuntu1
     + autotools-dev : 20130810.1
    ----------------------------------
     MISSING IN that_server.lst
    ----------------------------------
     - apcupsd : 3.14.10-2build1
     - apcupsd-doc : 3.14.10-2build1
     - beep : 1.3-3
     - btrfs-tools : 3.12-1
     - discover : 2.1.2-5.2ubuntu1