Opkg Basics

_images/opkg.png

Opkg (Open PacKaGe Management) is a lightweight package management system. It is written in C and resembles apt/dpkg in operation. It is intended for use on embedded Linux devices and is used in this capacity in the OpenEmbedded and OpenWrt projects.


Useful commands:

  • command to know what packages are installed on the file system:
  Board    select
opkg list-installed
  • show where are the files installed of the packet:
  Board    select
opkg search name_packet
  • show what packets depend on the “name_packet” package:
  Board    select
opkg whatdepends name_packet
  • remove packages:
  Board    select
opkg remove name_packet

for this command there are important options:

  1. This option will force the removal of the package but will leave any packages that depend on this package installed:
-force-depends
  1. This option will go up the dependency list and remove all packages in the dependency chain:
-force-removal-of-dependent-packages
  • install the packages:
  Board    select
opkg install name_packet

How to add a repository

Install a web server in the virtual machine, e.g.:

  Host    select
sudo apt-get install apache2

Copy the built packages inside the web server directory, e.g.:

  Host    select
sudo cp -r /home/architech/architech_sdk/pengwyn/yocto/build/tmp/deploy/ipk /var/www

Create a file named <something>.conf (e.g. mine-repositories.conf) under /etc/opkg/ of the Pengwyn file system and fill it with the following lines:

  Board    select
src/gz arm     http://192.168.0.100/ipk/armv7a-vfp-neon
src/gz all     http://192.168.0.100/ipk/all
src/gz pengwyn http://192.168.0.100/ipk/pengwyn

Note

192.168.0.100 is the server IP where there is the web server with repository

after that run the following command from Pengwyn’s shell:

  Board    select
opkg update

Now you are ready to download and install the packages from the network.

Tip

With “opkg list | wc -l” you can know approximately how many packets there are in repository

  Board    select
opkg list | wc -l
opkg update
opkg list | wc -l

If the updating got success with the last command you see the number of packets incremented.

How to update the repository in the vm

Once you have builded a package by Hob, do you need update package index. To do this, run the following command from Pengwyn’s shell.
  Host    select
cd /home/architech/architech_sdk/architech/pengwyn/yocto
source yocto/oe-init-build-env
bitbake package-index
opkg update