saving package list

Sundar Nagarajan sundar.personal at gmail.com
Sat Aug 30 01:21:26 UTC 2008


Willy K. Hamra wrote:
> i cleaned my system from almost all the packages i don't want, digging
> through the installed packages for more unnecessary ones, which i guess
> is a good enough punishment for my lack of organization, random apt-get
> sprees, and installing loads of packages at once without bothering to
> read through them, just because some website suggested so :-P

Willy,

I don't think there is anything to worry about. Even if you don't use 
aptitude, you should be able to achieve what you want. For some reason, 
I only use apt-get and not aptitude ('cos I am familiar with it), and I 
like to achieve exactly what you are looking for.

Declaratively, what you want is:
You want to move from version A to version B (could be, that for a fresh 
re-install, A = B).

You want to:
-----------

- Start with a clean install of version B
- NOT remove any packages that are part of the default install of 
version B (safety)

- Know what additional packages you installed in version A - List1

- Derive the "top-level" packages that you asked for and not list all 
the new packages include those installed as dependencies - List2

- Use either List1 or List2 to quickly get Version B as close as 
possible to the current state of Version A

Declaratively this becomes:
--------------------------

Amongst the packages currently installed, select those that are not part 
of the default install - List 1

Amongst List 1, select those that are "orphans" (top-level packages) - List2

To do this, all you need are the standard tools (dpkg, grep cut etc) and 
deborphan. From the man page: "deborphan finds  packages that have no 
packages depending on them. The default operation is to search only 
within the libs  and  oldlibs  sections to hunt down unused libraries".
If it's not installed you should install deborphan.

On the clean install (even if it is a new distro), run
dpkg --get-selections | cut -f1 -d '    '> default-list

Note that the character between single quotes after cut -d is a TAB 
(enter it using CRTL-V, CTRL-TAB on the command line)

You can do this e.g. by booting the LiveCD of your current (or new) 
distro. If you use the live-cd, copy default-list to some place on your 
currently installed version and reboot into your current version.

In the current version run
dpkg --get-selections | cut -f1 -d '    '> current-list

Note that the character between single quotes after cut -d is a TAB 
(enter it using CRTL-V, CTRL-TAB on the command line)

In the current version run
deborphan --no-show-section -a > current-top-level

cat current-list | grep -vFx -f default-list > new-packages
This (new-packages) is List1

cat new-packages| grep -Fx -f current-top-level > packages-to-install
This (packages-to-install) is List2

If you want to just install Version B and get it as close to your 
current state of version A as possible, I would recommend you do the 
default install, and then install everything in List1 (can also use 
List2 if you want).

If you want to peruse the list of top-level packages you have asked for 
and installed, that is List2 - you MUST have asked for all these, since 
they are top-level packages. Note that there MAY be other packages that 
you had asked for and installed that are not in List2 but are in List1, 
but do not appear in List2 because they are no longer top-level 
"orphans" because since then you installed another package that depends 
on these.

Hope this helps.

Sundar Nagarajan








More information about the kubuntu-users mailing list