Every modern operating system is expected to host a variety of software applications and libraries. Managing their installation, upgrade, and removal has become more complex as software has become more sophisticated. Additionally, the pervasive presence of the Internet has driven an expectation by users of an ability to perform OS updates and upgrades via the Internet. This page describes the tool used by EMAC OE to cater to these needs and expectations.
- 1 Background
- 2 General Information
- 3 OPKG
- 3.1 Updating the List of Available Packages
- 3.2 Upgrading the System
- 3.3 Finding Packages to Install
- 3.4 Installing New Packages
- 3.5 Removing Packages
- 4 Examples
- 5 Conclusion
- 6 Further Information
There are many package managers used for Linux systems. You may already be familiar with the ones most popularly used in desktop and server distributions of Linux:
yum. You may even be familiar with some of the less popular ones, such as
emerge (from gentoo's
portage), the Mac OS X GNU tools package manager
brew, and the BSD package manager,
ports. The package manager used by EMAC OE is similar to these tools, but is the popular choice for embedded Linux:
opkg. If you're already familiar with any of the desktop/server package managers listed here,
opkg should be very easy to learn since it is quite similar to all of those tools. If not, it should still be easy to learn because it has a well designed interface.
The basic capabilities of
opkg are available in OE 4.0 and earlier, but no packages are available online for these older versions. EMAC OE 5.0 adds an online package repository complete with important updates for packages during the support window for each release. EMAC creates and hosts packages for all of our standard offerings, and may add updated packages as needed. EMAC recommends checking for and installing any updates available for your OE 5.x system prior to creating the final image which will be used to deploy your systems to ensure your image contains the latest bug fixes and security patches. It is important to remember to retest your application after an update to ensure that everything still works as expected, just as you would have to do for a desktop application.
Should your application require the ability to be updated/upgraded remotely, EMAC is able to provide assistance and services for creating custom packages for your application and hosting these packages for a modest fee. We will also assist you with configuring the systems to check for and install these updates. Please contact EMAC support should you need more information about this extra level of support.
opkg tool is used to work with the OPKG package management system. This tool provides the user with many different capabilities. In this document, only the basic capabilities are described. More information can be found in the last section of this page.
The following basic capabilities are shown in this document:
- Updating the list of available packages.
- Upgrading the system.
- Finding packages to install.
- Installing new packages.
- Removing packages.
Updating the List of Available Packages
The OPKG Package Manager keeps a local cache of the list of available packages so that it doesn't have to reach out to the Internet every time the user wishes to use this list in any way. This list is updated on demand, rather than periodically, so it's important to update this list before attempting to search for or install any new packages, or attempting to upgrade the system.
To update the cached list of available packages, run:
Note that you must be root in order to update this list.
Upgrading the System
You can use
opkg to upgrade the system by selectively telling it which packages to upgrade. You first need to obtain a list of available packages to upgrade with the following command:
You can then upgrade a package with this command:
Finding Packages to Install
There is more than one way to look through packages to see what's available to be installed. The first is the
list command by itself:
This provides a complete list of all available packages. If you're already comfortable with the Linux command line, you may now wish to skip to the section entitled, "Installing New Pacakges." If not, the following content shows how to more easily work with this output.
Browsing the Package List
As usual on the Linux command line, this long list can be made much easier to peruse by piping the output of the
opkg list command into the
less command, like so:
|Unlike the |
Filtering the Package List
Often times, you will wish to search for something more specific. The
grep command is very useful for this task. The most basic use of grep looks like this:
If you're not sure of the full package name, you can put in just a part of the name, since grep doesn't match against whole words by default.
Matching Whole Words
If, on the other hand, you want it to match against a whole word, you can enclose the word with escaped angle brackets:
grep to only match against the full word represented by packagename. Use only the opening angle bracket if you only want it to look for a word that starts with packagename, and likewise, only use the closing angle bracket at the end if you only want it to search for a word that ends with packagename.
More Stringent Filtering
If the search is returning too many results because the word you're looking for is found in package descriptions, you may want to try using the beginning of line glob character, the caret:
This will cause only lines which begin with packagename to be displayed.
More Information about Filtering the Package List
There are many more advanced regular expressions which can be used with grep. These will allow you to do things like match wildcards from the beginning of the line up to the characters you specify after the wildcard (which you might do if you know the package name contains a word, but doesn't start with that word, yet the word is too common to allow it to search through all of the text), but this should be enough to get you started. There are many in depth resources for the usage of
grep available online.
Installing New Packages
Once you have found a package or list of packages you wish to install, the
opkg command makes installation simple:
This will download and install packagename and all of its dependencies for you.
If you would like to install more than one at a time, you can do so by specifying them as a space-separated list:
As before, all of the dependencies for the packages specified will be automatically downloaded and installed by
opkg as well.
When you have installed a package that you no longer want to have on your system,
opkg provides the
remove command for removal of the package:
If there is anything that depends on it,
opkg will output an error message indicating that packages depend on it.
You can add the
--force-removal-of-dependent-packages to force it to remove the package and everything that depends on it:
|The very verbose argument name is required because this can be a dangerous way to remove packages. The length of the argument's name (
Removing a Package which has Dependencies
Updating a Package
If you've forgotten to remount your root filesystem as rw, you'll see output similar to that shown above. Remount the filesystem rw and try again:
libssl1.0.0 package and the
openssl-conf package were both upgraded simultaneously by specifying them to
opkg upgrade as a space delimited list.
Installing a New Package
If you try to install a package which is already installed, it will check to see if it's up to date:
This article demonstrated the basic usage of
opkg, but did not cover any of the more advanced topics. Topics covered in this article include installing software, updating software, removing software, and searching for available packages.
More advanced topics are covered in other articles, such as configuring
opkg, inspecting package metadata and package contents, and creating packages. Look to the last section of this article if you need more information on these topics.
The EMAC opkg package repository contains a wealth of software you can install to customize and enhance the environment of your EMAC OE Linux machine. While a great deal of additional functionality is provided with the standard EMAC opkg repository, you may not be able to find a particular package you need. If you encounter this situation, you may contact EMAC support to request the creation of a custom package for you. EMAC is able to provide custom packages for most opensource software, and can recommend good alternatives in cases where a specific software package has been found to work or perform poorly (or not at all) in an embedded environment. EMAC charges a nominal fee to provide this package, but this fee includes support for the package as well.
The EMAC opkg repository is a great source of additional functionality for your machine, but even more importantly, the EMAC opkg repository is a source of updates for the software installed on your machine. Taking advantage of the EMAC opkg repository to update your systems helps to ensure that your systems will be protected from the latest threats, such as the Heartbleed OpenSSL vulnerability that made a big splash in the recent past.