Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have been using a virtual machine (Xubuntu 12.10, with VMWare on a windows host) for all my programming work, which I am trying to transition from a 32-bit install to a 64-bit install. I am hoping to be able to automatically re-install all the packages I have been using in the 32-bit VM in my new 64-bit VM.

Reading these instructions, I ran sudo dpkg --get-selections to get a list of installed packages, but many of the packages have an :i386 suffix.

Is there an easy way to install the corresponding 64-bit packages? Am I safe to replace :i386 with :x86_64 or something similar in my package listing before trying to install them?

share|improve this question
    
It seems the suffix I would need is :amd64. –  Ben Apr 3 '13 at 11:40
    
:i386 "should" mean that it's not the native architecture. So your VM would actually have been x64 and the question is a moot point. –  hbdgaf Apr 3 '13 at 12:49
    
Would that be the same if I have an x64 CPU in the VM but I used the x86 install disk and so I have a 32-bit kernel? –  Ben Apr 3 '13 at 13:52

2 Answers 2

up vote 1 down vote accepted

The first answer to this question uses what you suggest, and handles missing packages afterwards. Among the answers some people suggest this is a bad idea. Note as well that if the selection adds a :i386 it may be because some other package explicitly requires a package for this architecture. If you want to check before, here is a suggestion.

In your system, you should find lists of available packages per repository in /var/lib/apt/lists. You could check the list of packages with a :i386 against these lists to ensure that they are present for both i386 and amd64 architectures. The following script is an example of what you could do

#!/bin/bash

#iterate on installed packages with a :something in their names
for package in $(
                   dpkg --get-selections | 
                   grep ":" | #comment to check all the selection
                   grep -v deinstall | 
                   cut -f1 |
                   sed s/:.*// | 
                   sort -u
                )
do
  #find all occurences in repository package lists
  grep "Package: $package$" /var/lib/apt/lists/*  2>/dev/null |
    #translation and sources are not usefull
    grep -v Translation |
    grep -v Sources |
    #put the distribution as a prefix
    sed 's/^\(.*\)_dists_\([^_]*\)\(.*\)/\2  \1\3/' |
    #put the architecture difference in the repository file name as a prefix
    sed 's/^\(.*\)-\(amd64\|i386\)_\(.*\)/\2  \1_\3/' |
    #count consecutive identical lines ignoring the architecture prefix
    uniq -c -f1 |
    #print architecture distribution and package if some line is not duplicated
    awk '$1!=2{print $2 " " $3 " " $5}'
done

On a lubuntu install this gives me nothing, and on a debian one, the packages libc6-i686, libwine-bin, libwine-alsa, libwine-gl are only for i386 architecture for instance

share|improve this answer
    
Thanks! To be clear: this displays a list of the packages installed where there is an i386 version but not amd64 installed [or available?], correct? I get over 500 lines of output (mostly big sets of library packages like Qt, but some "standard" stuff like openjdk). –  Ben Apr 3 '13 at 14:01
    
Nearly, it just doesn't check installed packages which don't have a specified architecture in dpkg --get-selections. You can check for all installed packages by removing the grep ":" | line in the filtering of the packages iterated on. –  Vincent Nivoliers Apr 3 '13 at 14:06
    
openjdk seems to exist for all of the architectures in my case. Maybe the versions you have come from non-standard repositories, or you don't have both i386 and amd64 repositories installed ? In the last awk line you could also print $4 which contains the address of the repository, and see whether the lines you get come from repositories you don't care about. –  Vincent Nivoliers Apr 3 '13 at 14:24

This generates a list of the installed packages:

aptitude search -F '%100p' '~i!~M' > softare-list

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.