Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

list all my installed packages for an easy reinstall?

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
User avatar
graysky
Posts: 495
Joined: 2008-10-10 20:58

list all my installed packages for an easy reinstall?

#1 Post by graysky »

Is it possible for me to list all my currently installed packages (that is those that didn't come with the base system) so that I can do a reinstall and make single '# aptitude install package-a package-b package-c ... package-x' to rapidly restore the old system? Doing a 'dpkg -l | less' will show all packages including those that came w/ the base system. Is there a way one can somehow sort the packages by installed date/time?

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

#2 Post by bugsbunny »

If you want to rapidly restore the old system why do you want individual packages?

Take a look at aptitude-create-state-bundle.

There's no way, that I know of, to easily sort by installed date/time (but I also haven't tried). But that also wouldn't solve the problem of initially installed packages since they could have been updated/replaced since then.

infinitycircuit
Posts: 1137
Joined: 2007-07-24 03:31
Location: California

#3 Post by infinitycircuit »

From #debian:

Code: Select all

<dpkg> One method of cloning debian installs is to take a current debian machine that is setup with the packages you want and run the command "dpkg --get-selections > ~/selectionfile". Then, after the base install on other machines use that file and do: "dpkg --set-selections < ./selectionfile && apt-get dselect-upgrade". Also ask me about <aptitude clone><reinstall><things to backup>
<dmoerner> aptitude clone
<dpkg> To clone a Debian machine using aptitude (or install your favourite packages) use aptitude search -F '%100p' '~i!~M' > package_list; on the reference machine; xargs aptitude --schedule-only install < package_list; aptitude install; on the other machine. This preserve information about "automatically installed" packages that other methods do not. See also <reinstall><things to backup>

User avatar
graysky
Posts: 495
Joined: 2008-10-10 20:58

#4 Post by graysky »

@infinitycircuit - thanks for the reply. I actually found that, but it generates a list of ALL packages installed, not just the ones the user asked for. I guess the only way to accomplish this is to keep a list of what you have as you install it.

infinitycircuit
Posts: 1137
Joined: 2007-07-24 03:31
Location: California

#5 Post by infinitycircuit »

I don't believe that's true for the second method using aptitude, as the factoid says, this method should preserve the difference between automatically and manually installed packages. That's why it has the '!~M' modifier on the '~i' search term.

User avatar
graysky
Posts: 495
Joined: 2008-10-10 20:58

#6 Post by graysky »

@ic - I gave it a try and got a huge list of packages - way more than I installed myself:

Code: Select all

$ aptitude search -F '%100p' '~i!~M'

User avatar
kabniel
Posts: 224
Joined: 2007-07-10 21:03
Location: Sweden

#7 Post by kabniel »

Maybe not a very serious suggestion (i am not even sure the logs are kept forever), but for a crude way to get a list of the packages you have manually installed with aptitude you can grep the logs with something like

Code: Select all

zcat /var/log/aptitude.* | grep INSTALL] && cat /var/log/aptitude| grep INSTALL]
I am sure someone can cook up a script that takes REMOVE actions into consideration and also filter out everything except the package names.

emariz
Posts: 2901
Joined: 2008-10-17 07:59

#8 Post by emariz »

graysky wrote:I gave it a try and got a huge list of packages - way more than I installed myself
Are you sure that the difference is not comprised by dependencies? You did install them, implicitly.

Penguin Skinner
Posts: 709
Joined: 2005-09-15 20:37
Location: North by Northwest

#9 Post by Penguin Skinner »

Perhaps I'm unclear what you're trying to accomplish, but having already installed packages in your package list really isn't going to hurt anything when you go to do this 'reinstall' of packages added since the initial, basic installation -- apt-get will simply skip over the ones already installed, unless newer versions are available.

So ... here's how I would do it. As root, run the following:

Code: Select all

# dpkg --get-selections | sed 's/install//' | expand | sed 's/ //g' > packages-list.txt
This will produce a nice, clean list of installed packages, perfect for 'cat'-ing to apt-get.

.

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

#10 Post by bugsbunny »

For an apt-get method (as opposed to aptitude-create-state-bundle) I have this in my notes:

To make a local copy of the package selection states:
$ dpkg --get-selections "*" >myselections

"*" makes myselections include package entries for "purge" too.

You transfer this file to another computer, and install it there with:
# apt-get update
# dpkg --clear-selections
# dpkg --set-selections <myselections
# apt-get -u dselect-upgrade


You can save the list of automatically installed packages on the old
system:

aptitude -F '%p' search '~M' > auto-packages.txt

Then this should work on the new system:

aptitude markauto $(cat auto-packages.txt)

Post Reply