The OPKG package management system provides a suite of tools which can be used to perform a variety of useful tasks on OPKG packages. With these tools, you may:
- List files belonging to a package, along with their install locations.
- Find out which package provided a specific file on your filesystem.
- Read the metadata of a package.
- Display the status for packages.
- Find out what depends on a specific package.
- Reinstall packages.
All of these topics are covered within.
- 1 Background
- 2 General Information
- 3 OPKG: Working With Installed Packages
- 4 Examples
- 5 Conclusion
- 6 Further Information
Package management is more than installing and removing software. Package management involves managing dependencies between packages, tracking which packages provide which files, and providing information about a package, such as licensing, a package description, and a homepage for the software. A package management system addresses these needs and provides capabilities to assist a user in managing the software installed on a machine.
The capabilities described in this article are often used both individually and together to decide what to do when:
- Considering updating software.
- Determining what software will need to be installed on another system to provide the same functionality as found on the current system.
- Determining whether a certain package is really needed on a filesystem.
- Determining what version of software is installed.
- Determining where to find the main project for some particular software.
- Seeking to read a description of a software package in order to learn more about it.
- and more
These capabilities bring OPKG beyond being a simplistic software installation tool; they're the reason it's called a package management system. Learning to take advantage of these capabilities is highly beneficial to anyone doing anything more than just the most basic of tasks with an embedded Linux system.
opkg package management tool has many uses. This article is one of a series of articles covering the capabilities of the
opkg package management tool. See the last section of this document, Further Information, for other articles in this series.
OPKG: Working With Installed Packages
The capabilities described in this article are all sub-commands of the
opkg command. Not all of these commands require root privileges to run, but they do all require the
files sub-command lists all of the files which belong to a package. Using it is simple:
|Often times, you will want to pipe the output of this command to |
Sometimes you need to know where a file on your filesystem came from. Often times this is because you want to know what project maintains the file so that you can turn to its source code. Other times, you will need to know what packages to require when creating your own custom package so that your application will have the dependencies it needs. Perhaps you find a tool useful and want to use it on another project, but since you didn't install it, you don't know where it came from; in this case, you will need to use a tool to find out what package provides it. Regardless of the reason, the
search sub-command can give you this information.
Using this sub-command isn't always as straight forward as other sub-commands. Here are some rules to follow in order to have success with this sub-command:
- You must remember to provide the full path to the file in question, or you will get no results.
- You must use the
searchcommand on a file, not a directory, or you will get no results.
- You must remember to ensure that you're running the
searchsub-command on an actual file, rather than a symbolic link to a file, or the search will fail.
If you need to know the origin of a symbolic link, you need to determine where the link ultimately points, then run
readlink command is useful for quickly determining the path to the actual file to which a symlink ultimately resolves. If you have a symlink named,
mysymlink, you may invoke the
readlink command like this:
|Where the symbolic link ultimately points means the actual file it translates to. Some symlinks point to other symlinks, which themselves may point to other symlinks, and so on until the link list finally points to an actual file. This actual file is where the symbolic link ultimately points.|
See the examples in the next section for more information.
info sub-command allows you to view some very useful metadata that's contained in OPKG files. A package name or a glob can be passed to this sub-command:
The examples section contains a few examples which clarify this.
The OPKG status of a package will tell you a subset of the information provided by the
info sub-command. The information it provides is more targeted towards displaying information about how the package is relevant to the current machine, rather than information that is relevant to the package itself. This command is used like the
Again, the examples show more information about this.
Often times, you need to know what depends upon a package, in order to determine whether you can safely remove the package or not. The
whatdepends sub-command comes in handy for this task.
|This sub-command only works for packages that are currently installed. If you run this on a package that isn't installed, or if you misspell the package name, you will see no output from this command at all.|
Sometimes packages need to be reinstalled in order to repair damage which was done to them accidentally, whether it was caused by something as simple as mistakes made when tweaking the configuration file, or it was caused by accidentally deleting or overwriting important files that are part of the package. The reinstall command will often fix problems which were caused by these and other mistakes (but not always).
To reinstall a package, run:
Listing Files in a Package
To list all the files belonging to the
Listing Only Executable Files in a Package
To list only the executable files in the
| The above method of listing only the executable files in a package is the short, easy way, but it can miss files if they're not located in a |
The much more complex command above does the following:
Finding Out Which Package Provides a File
To search for the package which contains a file, you must provide the full path to the file:
Getting Metadata About a Package
To get the metadata for the
Note the list of files shown as thefor the package. This list shows the source code tarball which was used to compile the package, and the list of patches which were applied to the source code tarball before compiling the package.
Getting Status Information for a Package
To get the status information for the
Note that this is a subset of the information which was provided by the
Viewing the Dependents of a Package
To see what depends upon the
Reinstalling a Package
To reinstall the
The OPKG package management system provides a variety of tools for finding out information about the packages it manages. These tools provide insight into what is provided by a package, what other packages a certain package will pull in, the install status of a package, what other packages depend upon a given package, what packages are installed on a system, what packages are available to install on a system, and the available metadata about any given package. The insight provided by these tools is often essential when customizing a machine to an application.