Difference between revisions of "Opkg"

From wiki.emacinc.com
Jump to: navigation, search
m (Finding Packages to Install: Fixed missing end italics tag.)
 
(23 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{todo| NotStarted (11.12.2014-18:38->MD+)|Mike Dean| project=OE 5,MD }}
+
{{todo| Complete (11.12.2014-18:38->MD+);(11.05.2015-19:20->MD+);(11.06.2015-16:10->MD+);(11.06.2015-17:25->MD+);(11.13.2015-16:15->KY+);(11.13.2015-16:24->ER+)|Mike Dean| project=OE 5,MD,KY,ER,Complete}}
 
{{#seo:
 
{{#seo:
 
|title=OPKG
 
|title=OPKG
 
|titlemode=append
 
|titlemode=append
|keywords=
+
|keywords=opkg,yocto,openembedded
 
|description=Package Management with OPKG
 
|description=Package Management with OPKG
 
}}
 
}}
Line 14: Line 14:
  
 
{{:Templateimpl:bg | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
{{:Templateimpl:bg | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
There are many package managers used for Linux systems.  You may already be familiar with the most popularly used ones in desktop and server distributions of Linux: <code>apt</code> (<code>apt-get</code>, <code>aptitude</code>, etc), <code>rpm</code>, and <code>yum</code>.  You may even be familiar with some of the less popular ones, such as <code>emerge</code> (from gentoo's <code>portage</code>), the Mac OS X GNU tools package manager <code>brew</code>, and the BSD package manager, <code>ports</code>.  The package manager used by EMAC OE is similar to these tools, but is the popular choice for embedded Linux: <code>opkg</code>.  If you're already familiar with any of the desktop/server package managers listed here, <code>opkg</code> should be very easy to learn since it is very similar to all of those tools.  If not, it should still be straightforward to learn because it has a well designed interface.
+
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: <code>apt</code> (<code>apt-get</code>, <code>aptitude</code>, etc), <code>rpm</code>, and <code>yum</code>.  You may even be familiar with some of the less popular ones, such as <code>emerge</code> (from gentoo's <code>portage</code>), the Mac OS X GNU tools package manager <code>brew</code>, and the BSD package manager, <code>ports</code>.  The package manager used by EMAC OE is similar to these tools, but is the popular choice for embedded Linux: <code>opkg</code>.  If you're already familiar with any of the desktop/server package managers listed here, <code>opkg</code> 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.
  
 
{{:Templateimpl:geninfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
{{:Templateimpl:geninfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
The basic capabilities of <code>opkg</code> are available in OE 4.0 and earlier, but no packages are available online for these older versions.  OE 5.0 adds an online package repository complete with updates.  EMAC creates and hosts packages for all of our standard offerings, and may add updated packages when the need arises.  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.
+
The basic capabilities of <code>opkg</code> are available in OE 4.0 and earlier, but no packages are available online for these older versions.  EMAC OE 5.X 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.
 
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.
Line 33: Line 33:
 
=== Updating the List of Available 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.
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 to upgrade the system.
 
  
 
To update the cached list of available packages, run:
 
To update the cached list of available packages, run:
  
{{cli|cmd=opkg update}}
+
{{cli|opkg update}}
  
 
Note that you must be root in order to update this list.
 
Note that you must be root in order to update this list.
Line 44: Line 43:
 
=== Upgrading the System ===
 
=== Upgrading the System ===
  
 +
You can use <code>opkg</code> 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 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:
+
{{cli|opkg list-upgradable}}
 
 
{{cli|cmd=opkg list-upgradable}}
 
  
 
You can then upgrade a package with this command:
 
You can then upgrade a package with this command:
  
{{cli|cmd=opkg upgrade ''packagename''}}
+
{{cli|opkg upgrade ''packagename''}}
  
 
=== Finding Packages to Install ===
 
=== Finding Packages to Install ===
  
 +
==== Listing Packages ====
  
 
There is more than one way to look through packages to see what's available to be installed.  The first is the <code>list</code> command by itself:
 
There is more than one way to look through packages to see what's available to be installed.  The first is the <code>list</code> command by itself:
  
{{cli|cmd=opkg list}}
+
{{cli|opkg list}}
 +
 
 +
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.''
  
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, "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 <code>opkg list</code> command into the <code>less</code> command, like so:
 
As usual on the Linux command line, this long list can be made much easier to peruse by piping the output of the <code>opkg list</code> command into the <code>less</code> command, like so:
  
{{cli|cmd=opkg list {{!}} less}}
+
{{cli|opkg list {{!}} less}}
 +
 
 +
{{note|Unlike the <code>more</code> command, the <code>less</code> command allows you to scroll bidirectionally through a text file.  It also allows you to search through a document using regular expressions; press the <code>/</code> key followed by some text (or a basic regular expression) for which you would like to search.  This can be used to directly read a text file as well: {{icli|less some_text_file}}}}
 +
 
 +
==== Filtering the Package List ====
  
 
Often times, you will wish to search for something more specific.  The <code>grep</code> command is very useful for this task.  The most basic use of grep looks like this:
 
Often times, you will wish to search for something more specific.  The <code>grep</code> command is very useful for this task.  The most basic use of grep looks like this:
  
{{cli|cmd=opkg list {{!}} grep ''packagename''}}
+
{{cli|opkg list {{!}} grep ''packagename''}}
 +
 
 +
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 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.  If, on the other hand, you want it to match against a whole word, you can enclose the word with escaped angle brackets:
+
If, on the other hand, you want it to match against a whole word, you can enclose the word with escaped angle brackets:
  
{{cli|cmd=opkg list {{!}} grep \<''packagename''\>}}
+
{{cli|opkg list {{!}} grep \<''packagename''\>}}
  
 
This tells <code>grep</code> 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''.
 
This tells <code>grep</code> 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:
 
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:
  
{{cli|cmd=opkg list{{!}} grep ^''packagename''}}
+
{{cli|opkg list{{!}} grep ^''packagename''}}
 +
 
 +
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, which 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 <code>grep</code> available online.
+
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 <code>grep</code> available online.
  
 
=== Installing New Packages ===
 
=== Installing New Packages ===
  
 +
Once you have found a package or list of packages you wish to install, the <code>opkg</code> command makes installation simple:
 +
 +
{{cli|opkg install ''packagename''}}
  
Once you have found a package or list of packages you wish to install, the <code>opkg</code> command makes installation simple:
+
This will download and install ''packagename'' and all of its dependencies for you
  
{{cli|cmd=opkg install ''packagename''}}
 
  
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:
+
If you would like to install more than one at a time, you can do so by specifying them as a space-separated list:
  
{{cli|cmd=opkg install ''package1'' ''package2'' ''package3'' ''etc''}}
+
{{cli|opkg install ''package1'' ''package2'' ''package3'' ''etc''}}
  
 
As before, all of the dependencies for the packages specified will be automatically downloaded and installed by <code>opkg</code> as well.
 
As before, all of the dependencies for the packages specified will be automatically downloaded and installed by <code>opkg</code> as well.
 
  
 
=== Removing Packages ===
 
=== Removing Packages ===
  
 +
When you have installed a package that you no longer want to have on your system, <code>opkg</code> provides the <code>remove</code> command for removal of the package:
  
When you have installed a package that you no longer want to have on your system, <code>opkg</code> provides the <code>remove</code> command to remove the package:
+
{{cli|opkg remove ''packagename''}}
  
{{cli|cmd=opkg remove ''packagename''}}
+
If there is anything that depends on it, <code>opkg</code> will output an error message indicating that packages depend on it.
  
If there is anything that depends on it, <code>opkg</code> will output an error message indicating that packages depend on it.  You can add the <code>--force-removal-of-dependent-packages</code> to force it to remove the package and everything that depends on it:
+
You can add the <code>--force-removal-of-dependent-packages</code> to force it to remove the package and everything that depends on it:
  
{{cli|cmd=opkg remove --force-removal-of-dependent-packages ''packagename''}}
+
{{cli|opkg remove --force-removal-of-dependent-packages ''packagename''}}
  
: '''Caution:''' The very verbose argument name is required because this can be a dangerous way to remove packages, and the length of the name is intended to remind you of the danger.  You may find yourself with an unbootable system if you uninstall a package which was depended upon by important system packages.  It's generally wiser to use the less heavy handed version, <code>--force-depends</code>, which will only remove the package and a dependency one layer deep:
+
{{Caution|The very verbose argument name is required because this can be a dangerous way to remove packages.  The length of the argument's name (<code>--force-removal-of-dependent-packages</code>)is intended to remind you of the danger.  You may find yourself with an unbootable system if you uninstall a package which was depended upon by important system packages.  It's generally wiser to use the less heavy handed version, <code>--force-depends</code>, which will only remove the package and the dependencies which are one layer deep:
  
{{cli|cmd=opkg remove --force-depends ''packagename''}}
 
  
If more layers are required to be removed, you should use the <code>remove</code> command without either of these options on each dependency shown to see what depends on those dependencies, and continue this procedure recursively to ensure that nothing important will be removed before you attempt to remove a package with the heavy handed variant.
+
{{cli|opkg remove --force-depends ''packagename''}}
  
If you do render your system unbootable, contact EMAC, and we will help you get your system back into a usable state for a small fee.  If you would prefer to avoid this fee, please be very careful about what you remove, since misusing the above commands is not covered by the EMAC warranty.
 
  
 +
If more than one layer of dependencies needs to be removed, you should use the <code>remove</code> command without either of these options.  Use it on each dependency layer to see what depends upon those dependencies, and continue this procedure recursively to ensure that nothing important will be removed before you attempt to remove a package with the heavy handed variant.
 +
<br /><br />
 +
If you do render your system unbootable, you may contact EMAC, and we will help you get your system back into a usable state for a small fee.  If you would prefer to avoid this fee, please be very careful about what you remove since damage to the filesystem caused by misuse of the above commands is not covered under the EMAC warranty.
 +
}}
  
 +
<!-- /*********************************************************************************************************/ -->
 +
<!-- /*****************************************      Examples        *****************************************/ -->
 +
<!-- /*********************************************************************************************************/ -->
 
{{:Templateimpl:examples | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
{{:Templateimpl:examples | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
==== Removing a Package which has Dependencies ====
+
{{example|Removing a Package which has Dependencies}}
  
 
{{clo}}
 
{{clo}}
{{cli|cmd=opkg remove alsa-conf-base}}
+
{{clio|opkg remove alsa-conf-base}}
 
No packages removed.<br />
 
No packages removed.<br />
 
Collected errors:<br />
 
Collected errors:<br />
Line 129: Line 151:
 
&nbsp;* print_dependents_warning: Force removal of this package and its dependents<br />
 
&nbsp;* print_dependents_warning: Force removal of this package and its dependents<br />
 
&nbsp;* print_dependents_warning: with --force-removal-of-dependent-packages.<br />
 
&nbsp;* print_dependents_warning: with --force-removal-of-dependent-packages.<br />
{{cli|cmd=opkg remove --force-depends alsa-conf-base}}
+
{{clio|opkg remove --force-depends alsa-conf-base}}
 
Removing package alsa-conf-base from root...
 
Removing package alsa-conf-base from root...
 +
{{clio|}}
 
{{clos}}
 
{{clos}}
 +
 +
{{example|Updating a Package}}
 +
 +
{{clop}}
 +
{{cliop|opkg update}}<nowiki>
 +
 +
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Collected errors:
 +
* opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/all.
 +
* opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/ipac9x25.
 +
* opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/armv5e.
 +
</nowiki>{{closp}}
 +
 +
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:
 +
 +
{{cli|oemntrw}}
 +
 +
{{clop}}
 +
{{cliop|opkg update}}<nowiki>
 +
 +
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/all.
 +
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/ipac9x25.
 +
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/armv5e.
 +
 +
</nowiki>
 +
 +
{{cliop|opkg list-upgradable}}<nowiki>
 +
 +
u-boot-fw-utils - v2014.07+git0+91fbeacdf3-r0 - v2015.04+git0+5feae908fd-r0
 +
libssl1.0.0 - 1.0.2a-r0 - 1.0.2d-r0
 +
tzdata-pacific - 2015b-r0 - 2015d-r0
 +
tzdata - 2015b-r0 - 2015d-r0
 +
openssl-conf - 1.0.2a-r0 - 1.0.2d-r0
 +
libcrypto1.0.0 - 1.0.2a-r0 - 1.0.2d-r0
 +
tzdata-arctic - 2015b-r0 - 2015d-r0
 +
tzdata-africa - 2015b-r0 - 2015d-r0
 +
tzdata-europe - 2015b-r0 - 2015d-r0
 +
tzdata-americas - 2015b-r0 - 2015d-r0
 +
tzdata-atlantic - 2015b-r0 - 2015d-r0
 +
tzdata-australia - 2015b-r0 - 2015d-r0
 +
tzdata-antarctica - 2015b-r0 - 2015d-r0
 +
tzdata-asia - 2015b-r0 - 2015d-r0
 +
 +
</nowiki>
 +
 +
{{cliop|opkg upgrade libssl1.0.0 openssl-conf}}<nowiki>
 +
 +
Upgrading libssl1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root.
 +
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libssl1.0.0_1.0.2d-r0_armv5e.ipk.
 +
Upgrading libcrypto1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root.
 +
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libcrypto1.0.0_1.0.2d-r0_armv5e.ipk.
 +
Upgrading openssl-conf from 1.0.2a-r0 to 1.0.2d-r0 on root.
 +
Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/openssl-conf_1.0.2d-r0_armv5e.ipk.
 +
Configuring openssl-conf.
 +
Configuring libcrypto1.0.0.
 +
Configuring libssl1.0.0.
 +
 +
</nowiki>
 +
{{cliop|}}
 +
{{closp}}
 +
 +
Here, the <code>libssl1.0.0</code> package and the <code>openssl-conf</code> package were both upgraded simultaneously by specifying them to <code>opkg upgrade</code> as a space delimited list.
 +
 +
{{example|Installing a New Package}}
 +
 +
{{clop}}
 +
{{cliop|opkg update}}<nowiki>
 +
 +
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/all.
 +
Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/ipac9x25.
 +
Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz.
 +
Updated list of available packages in /var/lib/opkg/armv5e.
 +
 +
</nowiki>
 +
{{cliop|opkg list {{!}} grep iptables -A 2}}<nowiki>
 +
 +
iptables - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities  iptables is the
 +
userspace command line program used to configure and  control network
 +
packet filtering code in Linux.
 +
iptables-dbg - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Debugging files
 +
iptables is the userspace command line program used to configure and
 +
control network packet filtering code in Linux.  This package contains
 +
ELF symbols and related sources for debugging purposes.
 +
iptables-dev - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Development
 +
files  iptables is the userspace command line program used to configure
 +
and  control network packet filtering code in Linux.  This package
 +
contains  symbolic links, header files, and related items necessary for
 +
--
 +
iptables-doc - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Documentation
 +
files  iptables is the userspace command line program used to configure
 +
and  control network packet filtering code in Linux.  This package
 +
 +
</nowiki>
 +
{{cliop|opkg install iptables-doc}}<nowiki>
 +
 +
Installing iptables-doc (1.4.21-r0) on root.
 +
Downloading ftp://oe50@ftp.emacinc.com/armv5e/iptables-doc_1.4.21-r0_armv5e.ipk.
 +
Configuring iptables-doc.
 +
 +
</nowiki>
 +
{{cliop|}}
 +
{{closp}}
 +
 +
If you try to install a package which is already installed, it will check to see if it's up to date:
 +
 +
{{clop}}
 +
{{cliop |opkg install iptables}}<nowiki>
 +
 +
Package iptables (1.4.21-r0) installed in root is up to date.
 +
 +
</nowiki>
 +
{{cliop|}}
 +
{{closp}}
 +
  
 
{{:Templateimpl:conclusion | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
{{:Templateimpl:conclusion | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 +
This article demonstrated the basic usage of <code>opkg</code>, 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 <code>opkg</code>, 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.
 +
 
{{:Templateimpl:moreinfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
{{:Templateimpl:moreinfo | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
* Working with Installed Packages
+
* [[opkg:installedPkgs|Working with Installed Packages]]
* Configuring the Package Manager
+
* [[opkg:configuration|Configuring the Package Manager]]
* Advanced Package Management
+
* [[opkg::advanced|Advanced Package Management]]
 
 
{{:Templateimpl:whatnext | initials=MD | title=OPKG | desc=Package Management with OPKG | project=OE 5 }}
 
*
 

Latest revision as of 10:02, 11 March 2019

TODO: {{#todo: Complete (11.12.2014-18:38->MD+);(11.05.2015-19:20->MD+);(11.06.2015-16:10->MD+);(11.06.2015-17:25->MD+);(11.13.2015-16:15->KY+);(11.13.2015-16:24->ER+)|Mike Dean|OE 5,MD,KY,ER,Complete}}

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.

Background

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: apt (apt-get, aptitude, etc), rpm, and 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.

General Information

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.X 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.

The 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.

OPKG

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:

root@som9x25:~# opkg update

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:

root@som9x25:~# opkg list-upgradable

You can then upgrade a package with this command:

root@som9x25:~# opkg upgrade packagename

Finding Packages to Install

Listing Packages

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:

root@som9x25:~# opkg list

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:

root@som9x25:~# opkg list | less



NOTE
Unlike the more command, the less command allows you to scroll bidirectionally through a text file. It also allows you to search through a document using regular expressions; press the / key followed by some text (or a basic regular expression) for which you would like to search. This can be used to directly read a text file as well: root@som9x25:~# less some_text_file


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:

root@som9x25:~# opkg list | grep packagename

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:

root@som9x25:~# opkg list | grep \<packagename\>

This tells 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:

root@som9x25:~# opkg list| grep ^packagename

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:

root@som9x25:~# opkg install packagename

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:

root@som9x25:~# opkg install package1 package2 package3 etc

As before, all of the dependencies for the packages specified will be automatically downloaded and installed by opkg as well.

Removing Packages

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:

root@som9x25:~# opkg remove packagename

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:

root@som9x25:~# opkg remove --force-removal-of-dependent-packages packagename



CAUTION
The very verbose argument name is required because this can be a dangerous way to remove packages. The length of the argument's name (--force-removal-of-dependent-packages)is intended to remind you of the danger. You may find yourself with an unbootable system if you uninstall a package which was depended upon by important system packages. It's generally wiser to use the less heavy handed version, --force-depends, which will only remove the package and the dependencies which are one layer deep:


root@som9x25:~# opkg remove --force-depends packagename


If more than one layer of dependencies needs to be removed, you should use the remove command without either of these options. Use it on each dependency layer to see what depends upon those dependencies, and continue this procedure recursively to ensure that nothing important will be removed before you attempt to remove a package with the heavy handed variant.

If you do render your system unbootable, you may contact EMAC, and we will help you get your system back into a usable state for a small fee. If you would prefer to avoid this fee, please be very careful about what you remove since damage to the filesystem caused by misuse of the above commands is not covered under the EMAC warranty.


Examples

Removing a Package which has Dependencies

root@som9x25:~# opkg remove alsa-conf-base

No packages removed.
Collected errors:
 * print_dependents_warning: Package alsa-conf-base is depended upon by packages:
 * print_dependents_warning: libasound2
 * print_dependents_warning: These might cease to work if package alsa-conf-base is removed.
 * print_dependents_warning: Force removal of this package with --force-depends.
 * print_dependents_warning: Force removal of this package and its dependents
 * print_dependents_warning: with --force-removal-of-dependent-packages.

root@som9x25:~# opkg remove --force-depends alsa-conf-base

Removing package alsa-conf-base from root...

root@som9x25:~#


Updating a Package

root@som9x25:~# opkg update
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz. Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Collected errors: * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/all. * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/ipac9x25. * opkg_update_cmd: Not able to update list of packages in /var/lib/opkg/armv5e.

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:

root@som9x25:~# oemntrw
root@som9x25:~# opkg update
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz. Updated list of available packages in /var/lib/opkg/all. Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Updated list of available packages in /var/lib/opkg/ipac9x25. Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Updated list of available packages in /var/lib/opkg/armv5e.
root@som9x25:~# opkg list-upgradable
u-boot-fw-utils - v2014.07+git0+91fbeacdf3-r0 - v2015.04+git0+5feae908fd-r0 libssl1.0.0 - 1.0.2a-r0 - 1.0.2d-r0 tzdata-pacific - 2015b-r0 - 2015d-r0 tzdata - 2015b-r0 - 2015d-r0 openssl-conf - 1.0.2a-r0 - 1.0.2d-r0 libcrypto1.0.0 - 1.0.2a-r0 - 1.0.2d-r0 tzdata-arctic - 2015b-r0 - 2015d-r0 tzdata-africa - 2015b-r0 - 2015d-r0 tzdata-europe - 2015b-r0 - 2015d-r0 tzdata-americas - 2015b-r0 - 2015d-r0 tzdata-atlantic - 2015b-r0 - 2015d-r0 tzdata-australia - 2015b-r0 - 2015d-r0 tzdata-antarctica - 2015b-r0 - 2015d-r0 tzdata-asia - 2015b-r0 - 2015d-r0
root@som9x25:~# opkg upgrade libssl1.0.0 openssl-conf
Upgrading libssl1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root. Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libssl1.0.0_1.0.2d-r0_armv5e.ipk. Upgrading libcrypto1.0.0 from 1.0.2a-r0 to 1.0.2d-r0 on root. Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/libcrypto1.0.0_1.0.2d-r0_armv5e.ipk. Upgrading openssl-conf from 1.0.2a-r0 to 1.0.2d-r0 on root. Downloading ftp://oe50opkg:opkgoe50123@ftp.emacinc.com/armv5e/openssl-conf_1.0.2d-r0_armv5e.ipk. Configuring openssl-conf. Configuring libcrypto1.0.0. Configuring libssl1.0.0.
root@som9x25:~#

Here, the 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

root@som9x25:~# opkg update
Downloading ftp://oe50@ftp.emacinc.com/all/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/all/Packages.gz. Updated list of available packages in /var/lib/opkg/all. Downloading ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/ipac9x25/Packages.gz. Updated list of available packages in /var/lib/opkg/ipac9x25. Downloading ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Inflating ftp://oe50@ftp.emacinc.com/armv5e/Packages.gz. Updated list of available packages in /var/lib/opkg/armv5e.
root@som9x25:~# opkg list | grep iptables -A 2
iptables - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities iptables is the userspace command line program used to configure and control network packet filtering code in Linux. iptables-dbg - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Debugging files iptables is the userspace command line program used to configure and control network packet filtering code in Linux. This package contains ELF symbols and related sources for debugging purposes. iptables-dev - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Development files iptables is the userspace command line program used to configure and control network packet filtering code in Linux. This package contains symbolic links, header files, and related items necessary for -- iptables-doc - 1.4.21-r0 - Tools for managing kernel packet filtering capabilities - Documentation files iptables is the userspace command line program used to configure and control network packet filtering code in Linux. This package
root@som9x25:~# opkg install iptables-doc
Installing iptables-doc (1.4.21-r0) on root. Downloading ftp://oe50@ftp.emacinc.com/armv5e/iptables-doc_1.4.21-r0_armv5e.ipk. Configuring iptables-doc.
root@som9x25:~#

If you try to install a package which is already installed, it will check to see if it's up to date:

root@som9x25:~# opkg install iptables
Package iptables (1.4.21-r0) installed in root is up to date.
root@som9x25:~#


Conclusion

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.

Further Information

Where to Go Next