Making a list of everything you've installed with apt-get



As a clean install of ubuntu is often the only reliable way to upgrade, it's useful to know everything that you've installed manually. You could get a list of everything that's marked in for installation with something like:

dpkg -get-selections | grep -v deinstall > my-selections

but that list tends to be very long and it includes all the dependencies. So if you install a meta package which depends on a specific version of some other package you'll be trying to install that specific version after upgrade, which is not what we want. In that case all we want is the meta package.

Luckly, apt-get keeps a history of every time it is called. These history files are in /var/log/apt/history.log.(\d).gz. Each entry in that list contains a "Commandline: …" line which lists the command line that was executed. Thus we can get a list of everything we've installed by grepping through these files.

The first script is a perl script which parses "Commandline: …" entries:

#!/usr/bin/perl
# parse_apt_log.pl
while(<>)
{
    if(/^Commandline: apt-get install(.+)/)
    {
        unless(/-reinstall/)
        {
            print join("\n", split(/\s+/, $1) );
        }
    }
}

and the second is a bash script which pipes the contents of those history files to the perl script

#!/bin/bash

outfile="$(mktemp)"

gunzip -c /var/log/apt/history.log.*.gz | ./parse_apt_log.pl > $outfile

sort "$outfile"
rm "$outfile"

Which gives an output like:

josh@Nadie:~/Desktop$ ./make_pkg_list.sh
astyle
bitcoin-qt
debathena-pharos-support
dhex
digikam
docbook2x
docbook5-xml
docbook-xsl-ns
firefox
flip
fontforge
fop
gdm
git-svn
gnucash
gyp
icedtea6-plugin
icedtea-7-plugin
jhead
latexml
libapache2-mod-fastcgi
libavcodec-extra-53
libav-dbg
libavdevice-extra-53
libavfilter-extra-2
libavformat-extra-53
libavutil-extra-51
libcairo2-dbg
libcrypto++-dev
libcurl4-gnutls-dev
libfcgi-dev
libgdal1-dev
libglade2.0-cil
libgnome-desktop-dev
libgtkglext1-dev
libjpeg-turbo-progs
libjson0-dev
libmosquitto0
libpcre3-dev
libqtsysteminfo1
libtelepathy-qt4-2
libtidy-dev
libusb-0.1-4
libusb-1.0-0-dev
libusb-dev
libxml2-dev
libxml2-utils
linux-generic
markdown
meld
mtpfs
mtp-tools
network-manager-openvpn
okular
openjdk-7-jre
owncloud-client
pcsxr
pcsxr
pdfedit
python-rosinstall
qt-sdk
qtsixa
ragel
ros-fuerte-desktop-full
ros-fuerte-pr2-*
ros-fuerte-pr2-simulator
ros-fuerte-rqt
rtmpdump
sixad
smplayer
sound-juicer
spawn-fcgi
sqlitebrowser
synapse
ufraw
ufraw-batch
uncrustify
universalindentgui
untex
vlc-dbg
xdotool
xmlstarlet
xmlto
xsltproc

You can reinstall this list on the new system with sudo apt-get installtr '\n' ' ' < package-list.txt``, where tr will remove the newlines.

Other install notes for upgrading to ubuntu 13.04:

To install deb packages from the command line along with their dependencies install gdebi-core from the repositories. Then run, for instance sudo gdebi google-chrome-stable-current_amd64.deb.

To remove overlay scrollbars: gsettings set com.canonical.desktop.interface scrollbar-mode normal

To allow rawdisk vmdk's in Virtualbox the user must be a member of the disk group: sudo usermod -a -G disk user

Comments


Comments powered by Disqus