Sometimes when you move from one server to another, you need to keep a list of programs you need. One simple way to get this list is:
dpkg --list |egrep -o '^ii\W+(\w+)'|egrep -o '\w+$' >> installed_programs.lstxargs aptitude install < installed_programs.lstThis will work for initializing new systems. However, if you want to sync two installation, you will need to uninstall and install de right things. Fro this you can just create a selection listing:
dpkg --get-selections > program_selection.lstdpkg --set-selections < program_selection.lst Of course a better way of handling this is also keeping a list of patched files: you would like to keep your own configuration. So, you want to backup everything that is not part of a package: everything that is not yours or downloaded. If you combine this with debsums you can even find a list of files you don't need to backup to keep:
xargs -n1 debsums < installed_programs.lst |grep OK > deletable_files.txtIt would be best to script this all into a program, but somebody probably already did that.
Comments
Intresting, thanks for the
Intresting, thanks for the tip.
How does it handle packages dependent on the version number such as kernels which are updated quiet often?
Does "dpkg --get-selections > program_selection.lst" uninstall programs too? the list contains only packages to be installed.
fluo
Not completely sure actually ;-)
Most kernel packages have their kernel version in the package name. Because the name is stored, the version should be ok.
For other packages, the available version will be installed. The dpkg --get-selections may uninstall some packages but it doesn't list all packages in the whole repo. Run the following command for a list of "not install" packages in --get-selections:
dpkg --get-selections |egrep --invert '\Winstall'