0

I am creating a web application and I need to check if ia32-libs are installed. This needs be a non sudo command as it will be run by www-data. Could someone help me out? I have tried listing packages in both aptitude and dpkg with no luck.

PS: I am on Debian based distros.

2 Answers 2

0

You can query the status of the package with the following command line (no root privileges needed):

dpkg --get-selections ia32-libs

In case the package is installed you will get the following result (e.g. Ubuntu Precise):

ia32-libs                                       install

otherwise you will get something different (the actual response depending on your locale settings).

However, on recent Debians and Ubuntus ia32-libs has been made into a transitional package in favour of a true multiarch solution. You can query your current architecture with

dpkg-architecture

which on x64 will have a line

DEB_HOST_ARCH=amd64

and you can check if the i386 support has been enabled with the following command:

dpkg --print-foreign-architectures

The answer will include i386 if the required libs of the architecture are there.

To add an architecture one needs to run

dpkg --add-architecture i386
3
  • I did try this, I don't have have ia32-libs installed on my machine and I get a reply from that command saying it's not installed. Not sure how else my PC is running 32 bit applications. Is there a way to determine if a machine can execute x86 code?
    – Zinglish
    Commented Mar 25, 2014 at 16:50
  • You are right. Things keep changing, otherwise life would be too easy. In Ubuntu you still have ia32-libs, but in recent Debian it is an additional architecture. Added the relevant additions to my answer. You will probably need to accommodate several possible ways of checking for ia32 support into your application.
    – jpe
    Commented Mar 25, 2014 at 17:04
  • The dpkg --print-foreign-architectures command works on Ubuntu too, so that should be the safe way to achieve your goal.
    – jpe
    Commented Mar 25, 2014 at 17:17
0

Couple ways you can do this:

dpkg -l | grep ia32-libs

dpkg --get-selections | grep ia32-libs

You will get a list of packages installed against the request. If nothing is returned you don't have the package.

Source: Debian Wiki

5
  • I didn't mark this as an answer as I felt like the one I did mark gave a better answer, however this reply works too.
    – Zinglish
    Commented Mar 25, 2014 at 17:07
  • dpkg -l | grep ia32-libs returns nothing at all on a modern debian with i386 architecture installed and the transitional ia32-libs package removed. So it may lead to false conclusions.
    – jpe
    Commented Mar 25, 2014 at 17:10
  • @jpe | It returned nothing when you ran it against a package which doesn't exist on the system. That is the expected result as I indicated in my post. Commented Mar 25, 2014 at 18:54
  • @MatthewWilliams correct, but when the i386 architecture is installed, then the programs the OP needs to run will run even if the ia32-libs package is removed. Thus your solution can yield a false negative.
    – jpe
    Commented Mar 25, 2014 at 19:40
  • @jpe | Good to know. Thanks for the information. Commented Mar 25, 2014 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .