APT Scripts – Generate App List from Old Installation

aptinstallationscripts

I want to shift from ubuntu-desktop 10.10 to ubuntu netbook edition 10.10 on my netbook. Currently, the moment I ssh into ubuntu from my ad-hoc network, ubuntu freezes. It always requires a cold shutdown. So hoping that netbook edition may not have this issue. I have custom installed many applications on the desktop edition. So I want save the app list into a script and run the script on the new installation, so that all apps will be downloaded and installed. I need suggestions as to the best way to achieve this.

Best Answer

Run this monster on your existing install, replace 12.04 your Ubuntu version and i386 with the architecture (i386 or amd64):

release_num='12.04'
arch='i386'

comm -23 \
    <(sort <(aptitude search '~i!~E' --disable-columns | grep -v "i A " | cut -d " " -f 3)) \
    <(sort <(wget -q -O- http://releases.ubuntu.com/maverick/ubuntu-${release_num}-desktop-${arch}.manifest | grep -E -o '^[^ ]+')) \
| sed 's/$/ install/g' > packages

It will generate a file called packages. Copy this to somewhere in your new install and then run:

sudo apt-get update
sudo bash -c "cat packages | xargs apt-get -y install"

Note: This compares the packages used on the LiveCD with the current ones. At the moment there are a few packages (gparted, btrfs-tools, etc) that are on the CD that aren't installed. If you installed gparted manually, you'll need to reinstall it on the new machine manually too. Thankfully this only applies to a few packages, all of which are simple to install if/when you realise you need it.

Also if you use any PPAs or other repositories, make sure you set them up on the new machine before you run this.