View dependencies of .ipk files

Embedded Linux platforms frequently use .ipk package files. I have had a need to install specific packages (usually from a Yocto build) during development and testing. It is helpful to know all the dependencies of a package in advance, making it easier to copy all the needed packages to the test environment at one time.

tl;dr

ar p <file>.ipk control.tar.gz | tar Oxz | grep Depends

Example:

ar p qtdeclarative_5.11.3+git0+e3c0bb7811-r0_armv7at2hf-neon.ipk control.tar.gz | tar Oxz | grep Depends

Results in:

Depends: libc6 (>= 2.28), libgcc1 (>= 8.2.0), libstdc++6 (>= 8.2.0), qtbase (>= 5.11.3+git0+08de243eaa)

In my case, libc6, libgcc1, and libstdc++6 are already installed on the target platform, so I know I need to grab qtbase as well as qtdeclarative. Yes, this is an obvious example, but it’s just an example. The real impetus for writing this was me getting the dependencies of my Qt based appliation.

Explanation

  • The ar tool is used to print the control.tar.gz file to stdout
  • Which is piped into tar command
  • The tar command prints the contents of control.tar.gz to stdout
  • control.tar.gz consists of one file, control, which contains the full package info, including the Depends line

The long version

List the contets of the .ipk using ar t <file>:

ar t qtdeclarative_5.11.3+git0+e3c0bb7811-r0_armv7at2hf-neon.ipk
debian-binary
control.tar.gz
data.tar.xz

Extract the contents of the .ipk:

ar x qtdeclarative_5.11.3+git0+e3c0bb7811-r0_armv7at2hf-neon.ipk

Use tar to list the contents of control.tar.gz:

tar xzvf control.tar.gz
./
./control

Use tar to print the contents of control in control.tar.gz

tar Ozfx control.tar.gz
Package: qt5test
Version: 1.0+git999-r0
Description: Qt5 test app
 Qt5 test app.
Section: base
Priority: optional
Maintainer: Toradex <yocto-patches@toradex.com>
License: MIT
Architecture: armv7at2hf-neon
OE: qt5test
Homepage: http://innovive.com/
Depends: libc6 (>= 2.28), libgcc1 (>= 8.2.0), libstdc++6 (>= 8.2.0), qtbase (>= 5.11.3+git0+08de243eaa), qtdeclarative (>= 5.11.3+git0+e3c0bb7811)
Source: qt5test_git.bb

This works because ./control is the only file in the archive. If there were additional files, list only the one file using:

tar Ozfx control.tar.gz ./control

The grep at the end of the original command eliminates the info irrelevant to dependencies. It can always be left off.

Tested on: Pop!_OS 22.04 LTS