2007-08-13
Migrating aptitudes knowledge about auto-installed packages
Jonathan McDowell wonders how to take aptitude’s knowledge about auto-installed packages from one computer to the other. Well, I looked into the issue for a few minutes and I found a solution though it doesn’t look nice.
for i in
# grep installed package names
`COLUMNS=200 dpkg -l | grep -E '^ii'| awk '{print $2};' `
do
# find package in /var/lib/aptitude/pkgstates
# check for the right state (1 seems to mean
# auto-installed, 3 manually installed)
if
grep-available -s Package,State \
-F Package \
-X $i /var/lib/aptitude/pkgstates \
| grep -q 'State: 1'
then
echo $i
fi
done
Results in a list of auto-installed packages AFAICT. If you change the “State: 1″ into “State: 3″, it seems you get only manually installed packages. So if you take the latter and feed it to “aptitude install”, your database should be right. If you take the former, you feed the list to “aptitude markauto”. A cleaner solution (which works even if /var/lib/aptitude/pkgstates changes formats) would involve checking “aptitude show” output, evaluating the “Automatically installed:” field. However, simply feeding “aptitude show” output to grep-dctrl (or any equivalent) resultes in the rather irritating error message “grep-dctrl: -:14: expected a colon.”, with the 14 changing to a different line in the packages description (usually a line directly following an empty line). So I’m just giving you an idea here.
See also No related posts
Permalink
7 Comments
