Let's say you want to do a fresh install of Ubuntu (or Debian) and you want to install all the packages you currently have installed on the fresh installation.
The first method of doing this is very easy:
a) Create a text file with all the currently installed applications:
Then save the "installed-applications.txt" file somewhere.
b) To install all the packages from the "installed-applications.txt" to the fresh Ubuntu installation (or another computer), you have to run this:
(don't forget to copy the "installed-applications.txt" to the new fresh installation / other computer or whatever)
For a more advanced way of doing this (creating a .deb file of just a few kb in size with all the packages you currently have installed on your computer as dependencies, which can then be used on multiple computers, etc.), read on!
The first method of doing this is very easy:
a) Create a text file with all the currently installed applications:
sudo dpkg --get-selections > installed-applications.txt
Then save the "installed-applications.txt" file somewhere.
b) To install all the packages from the "installed-applications.txt" to the fresh Ubuntu installation (or another computer), you have to run this:
(don't forget to copy the "installed-applications.txt" to the new fresh installation / other computer or whatever)
sudo dpkg --set-selections < installed-applications.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade
For a more advanced way of doing this (creating a .deb file of just a few kb in size with all the packages you currently have installed on your computer as dependencies, which can then be used on multiple computers, etc.), read on!
This second method of reinstalling all of your current installed packages on a fresh Ubuntu installation is basically a simplified method of creating a .deb file and it only requires editing one file to actually create the .deb file, as opposed to the official way which we've talked about HERE.
1. Preparations
This step involves installing a package called equivs, creating a folder with our package name (can be whatever you want, but make sure there is no package in the repositories under the same name) and creating the "control" file for our .deb package.
sudo apt-get install equivs
cd && mkdir webupd8package
cd webupd8package/
mkdir debian
cd debian/
equivs-control control
The last command will create a file called "control" in the ~/webupd8package/debian folder. This is basically a template of the control file and it looks like this:
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
Standards-Version: 3.6.2
Package: <package name; defaults to equivs-dummy>
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
Description: <short description; defaults to some wise words>
long description and info
.
second paragraph
2. Editing the control file.
Our .deb file will be basically the same as the project called "Ubuntu b-sides", but with all the packages you currently have installed (you can of course modify the package list with any packages you want). It will only have a few kb as it is a meta package which comes with all your currently installed packages as dependencies.
2.1 Very important: Before editing the control file, you need a list of the currently installed application. We're not going to use the command from the beginning of the post but this one:
cd
sudo aptitude search -F %p ~i --disable-columns libedataserver | sed 's/$/,/' | tr '\n\r' ' ' | sed 's/, $//' > installed-applications.txt
The reason for doing this is to have the applications separated by a comma so you can easily paste the list in the control file. Thanks to realubot for this.
2.2 Editing the control file.
If you don't know how to edit this on your own, you can simply paste the following text instead of all the contents in the control file (of course, edit your name and email).
Firstly open the control file (type the following command in a terminal):
gedit ~/webupd8package/debian/control
And replace the whole contents of the file with this (this is a very basic setup):
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
Standards-Version: 3.6.2
Package: webupd8package
Version: 1.0
Maintainer: Andrew < andrew@webupd8.org >
# Pre-Depends: <comma-separated list of packages>
Depends: paste here the entire contents of the file you got in step 2.1
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
Description: All my applications packed into a deb file
3. Creating the .deb file
Now all we have to do is run the command which will generate the .deb file. Firstly navigate to the "debian" folder:
cd
cd webupd8package/debian/
And finally run the command which will generate the .deb package:
equivs-build control
This second method may seem complicated at a first glance, but in fact it will only take you 3-4 minutes to complete!
Note for both methods: to also install the applications from PPAs, you will have to import your /etc/apt/sources.list file to the new installation (basically all the PPAs are in there). If you used multiple sources files, copy them all to the new installation (from /etc/apt/sources.list.d).
Thanks to littlejohn for the second method.