[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Install matching set of software while preserving aptitude auto/manual install info



On Wed, 2008.11.05, 310, Brian McKee wrote:
> I'd like to 'clone' the installed software on a machine.   I can find
> lots of references to this procedure
> > Backup installed package list on current machine
> > dpkg --get-selections > selections.txt
> > move selections.txt to the new machine Set package list on new machine and install packages
> > dpkg --set-selections < selections.txt
> > apt-get update
> > apt-get upgrade
> 
> What I can't find, but I know I've seen, is a way to do it using
> aptitude that preserves aptitude's knowledge of what was installed
> manually vs automatically.
> Can someone throw me a link (or a cluestick)

If you want to preserve auto-install information, use aptitude only, not dpkg 
or apt-get.

Note that I have almost never actually restored the package selections using 
the commands under [restore] but the [save] ones are run with each backup.  
Understand what the [restore] commands do before you use them.  And if this 
works, maybe someone could put it on the wiki.

[save]
# Save a list of all installed packages
aptitude -F "%?p" --disable-columns search \~i >| installed-all
# Save a list of all installed packages with their versions
aptitude -F "%?p=%?V" --disable-columns search \~i >| installed-all-ver
# Save a list of all automatically installed packages
aptitude -F "%?p" --disable-columns search \~i\~M >| installed-auto

[restore]
# Install all essential, important, required, or standard packages
aptitude -R --schedule-only install $( aptitude -F "%?p" search \!\~i?or(\~E,\~pimportant,\~prequired,\~pstandard) )
# Mark as manually installed all essential, important, required, or standard priority packages
aptitude -R --schedule-only unmarkauto $( aptitude -F "%?p" search \~i?or(\~E,\~pimportant,\~prequired,\~pstandard) )
# Mark as automatically installed all packages that are not essential, important, required, or standard priority
aptitude --schedule-only markauto $( aptitude -F "%?p" search \~i\!\~E\!\~pimportant\!\~prequired\!\~pstandard )
# Install all the packages in the installed package list (manual + automatic)
aptitude -R --schedule-only install $( cat installed-all )
# Mark as automatically installed all packages in that list
aptitude --schedule-only markauto $( cat installed-auto )

The version of aptitude I am using (0.4.11.10-1lenny1.1) does not seem to 
correctly handle repeated scheduling, so you may need to not use the 
'--schedule-only' option (inconvenient but will accomplish the same thing).

Note that any changes in the available packages since the time you saved the 
package selections will affect how well this procedure works and again: this is 
only minimally tested.

Please let us know whether it works.

Attachment: signature.asc
Description: Digital signature


Reply to: