OpenWRT Package Manager Tutorial

Home / OpenWRT Package Manager Tutorial

OpenWRT Package Manager Tutorial

December 9, 2015 | Article | 1 Comment

In PC’s Linux Distribution, managing package such as installing, updating, and removing package is so easy. Many distribution offers simplified package management using their way such as: apt for debian based, rpm for red-hat based, etc. Although diversity occurs, the purpose is same: managing package / software on Linux.

Being embedded system, OpenWRT offers similar feature. It has its own package manager, named OPKG Package Manager.

In this article we will discuss about opkg, how to use it for our needs.

Overview and History

Opkg is a fork from ipkg package manager. It is lightweight and used to download and install OpenWRT packages form local package repositories or one located in the internet. This function is similar to other package managers. As package manager for small and embedded system, of course Opkg should be as fast as possible.

Opkg attempts to resolve dependencies with packages in the repositories – if this fails, it will report an error, and abort the installation of that package.

Missing dependencies with third-party packages are probably available from the source of the package.
To ignore dependency errors, pass the –force-depends flag.

Syntax

Invoking opkg is simple.

opkg [options...] sub-command [arguments...]

Where options are option for manipulating packages. The manipulation / options available are:

update
Update list of available packages. This operation will download file(s) with list of available packages.
upgrade <pkgs>
Upgrade packages. It can also be used for upgrading group of package:
List of upgradeable packages can be obtained with the opkg list-upgradable.
install <pkgs|FQDN>
Install package(s). Usage sample:
opkg install hiawatha
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar7ixx.ipk
opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk
configure <pkgs>
Configure packages.
remove <pkgs|regexp>
Removes package(s)

Configuring Repositories

Repository is a server / machine which packages stored. When an OpenWRT device need / want to install a packages, it will retrieves the needed package from repository.

When configuring a packages, make sure the repository used is correct with the target OpenWRT device. What you need to look is the correct architecture (processor and other chips compatibility).

Adjust Repositories

OPKG configuration is stored as /etc/opkg.conf. The content could be like this:

src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /
dest ram /tmp
lists_dir ext /var/opkg.lists
option overlay_root /overlay

In above example, we use chip from atheros therefore we install package from atheros ar71xx branches. Root folder is on / and ram is on /tmp. The list or package list is stored as /var/opkg.lists and overlay directory is on /overlay.

For fetching packages locally, adjust to this line:

src/gz local file:////path/to/packagesDirectory

Adjust Architectures

By default opkg only allows packages with the architecture all (= architecture independant) and the architecture of the installed target. In order to source packages from a foreign but compatible target, the list of allowed architectures can be overrided in opkg.conf, something like this:

arch all 100
arch brcm4716 200
arch brcm47xx 300

The architectures are written in specific order. All of the packages architecture defines there has priority and ease opkg for determining which package to prefer in case multiple architectures available.

Proxy Support

If  OpenWRT box is behind proxy, add following to /etc/opkg.conf:

option http_proxy http://proxy.example.org:8080/
option ftp_proxy ftp://proxy.example.org:2121/

Adjust the address and port yourself. If the proxy need authentication, add following:

option proxy_username xxx
option proxy_password xxx

Another way is combining authentication with proxy address, which gives us:

option http_proxy http://username:[email protected]:8080/
option ftp_proxy http://username:[email protected]:2121/

,

About Author

about author

xathrya

A man who is obsessed to low level technology.

1 Comment
  1. Installing WebUI: LuCI - Xathrya.ID

    […] proceeding, at least you know how to use opkg. If not, please refer to this, or this page for detail […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial