Package creation - config files and external libs


Since, I've become ready to deploy my solution for OpenWrt/Rutos device, I've got two issues related to creating production package:

  1. I've got couple of external packages which are needed to be installed before my software can be used - libmosquitto, libmodbus, libconfig, etc. At this moment I install it manually using opkg install command. Can I somehow install them together when I install my package?

  2. Installer moves built binaries to indicated place and that's it, while the software needs some additional text files to work. Is it possible copy those configuration files during package install?

Thanks in advance


You can (and need to) define them as dependencies for your package, and thus opkg should install them automatically when you install your own package.

I've got the following dependencies defined in the makefile:

define Package/xxxx
	TITLE:=Some title
	DEPENDS:= +libcurl +libjson-c +libmosquitto +libmodbus +libconfig

but when I try to install it, I've got the message:

Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for xxxx:
 * 	libmodbus
 * 	libconfig
 * opkg_install_cmd: Cannot install package xxxx.

both do exist as opkg downloads for the current OpenWrt branches.
Have you done "opkg update" to refresh the list of downloadable packages?

And you are doing this for a surrently supported version of OpenWrt? (Instead of some ancient off-tree derivative?)

(I have no idea if Rutos offers the current package selection, or if it is limited to something from 2015 etc..)

well, opkg update helped. thanks.


1 Like

Well, expect for one little thing.

To fulfil dependency package manager installed latest libconfig package which is a totally new version of it - libconfig11 - version 1.7.2, while I'm using original libconfig 1.5.1. And obviously my program does not work on the newer libraries. Is there a way to explicitly define which package is needed?


Each branch has just one version, the current one.

To my knowledge there has never been libconfig 1.5.1 in OpenWrt.

It was bumped from 1.5 to 1.7.2 in year 2018.

OK, For some reason I had a makefile for 1.5 version in my SDK. Probably because the newest deb package for libconfig is 1.5 and I'm using it for development. I've replaced Makefile and it works fine, thanks.

And what about other installation actions?

How should I add config files, changing init.d to start my service, etc?

You could populate those files in your firmware through your package Makefile. An alternative is to place those files in your <buildroot>/files for example:

/home/openwrt/files/etc/init.d/my init script

Thanks, it would do the job.

One question - is it possible to have a script executed after package installation?

You can ship init scripts and config files along with your package, simply install them from your Makefile. Assuming a directory hierarchy like:

 + mypackage/
    + Makefile
    + files/
       + myservice.init
       + myservice.conf

Your package Makefile would contain an install section similar to (tab indentation is crucial here):

define Package/mypackage/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/myexecutable $(1)/usr/sbin/
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/myservice.init $(1)/etc/init.d/myservice
	$(INSTALL_DIR) $(1)/etc/myservice
	$(INSTALL_DATA) ./files/myservice.conf $(1)/etc/myservice/myservice.conf

Post installation actions to be executed by the package manager after install can be defined in the postinstall section of the Makefile:

define Package/mypackage/postinst

echo "This is a postinstall action"

if [ -n "$${IPKG_INSTROOT}" ]; then
    echo "I am executing on the build system"
    echo "I am executing on the target system"

Further information at


Thanks, one short question - is it possible to include condition, that installer will copy additional (config) files only if they do not exist on target filesystem?

The thing is, that I'm copying basic config files and the scripts are doing the rest of configuration by writing additional lines to the config file. This includes authentication code, which can be downloaded only once unless unlocked in the database.

In case of totally fresh installation I'd like to have all the files copied and script run, otherwise I'd like to have only binaries updated. I've tried to change the version of the package and run update, but it does exactly the same thing as in case of fresh installation.


Sure, it's a normal shell script. However opkg also will take care of this if the file is properly marked as conffile. In this case opkg will not overwrite it but place the defualt copy with a backup extension next to it, similar to dpkg.

I marked it like that:

	$(INSTALL_DIR) $(1)/etc/vtscd
	$(INSTALL_CONF) ./files/vtscd.conf $(1)/etc/vtscd/vtscd.conf

and it behaved exactly in the same way - overwritten my existing config with default one.

You did not "mark it".
You just added an install (copy) command.

You should explicitly declare that file as a config file with a separate "conffiles" section.

See example in

Ps. no indentation to that section.

Well it worked after all - thank you guys for your support!!!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.