openwrt icon indicating copy to clipboard operation
openwrt copied to clipboard

imagebuilder: add hostpkgs to imagebuilder

Open lemoer opened this issue 4 years ago • 8 comments

Before this commit, host packages were not installed into the imagebuilder. This made it impossible to make use of hostpkgs in opkg postinstall scripts in combination with the imagebuilder.

This commit changes this and ensures, that

  • staging_dir/hostpkg/bin/* is installed to the imagebuilder.
  • staging_dir/hostpkg/lib/lua is installed into the imagebuilder (if existing).
  • Dependencies of lua libraries are installed into staging_dir/hostpkg/lib using bundle-libraries.sh.

After this commit, we are able to use hostpkgs (like lua) in opkg postinstall scripts in combination with the imagebuilder, assuming that those packages built as hostpkgs anyways.

With default OpenWrt configuration for x86-64, the unpacked imagebuilder becomes this much larger:

1.5M	staging_dir/hostpkg/bin
3.6M	staging_dir/hostpkg/lib

Signed-off-by: Leonardo Mörlein [email protected]

(EDIT: Updated to new commit message.)


A test of (the newest version of) this PR is still compiling. I'll inform you when this is finished.

CC: @aparcar

lemoer avatar Aug 15 '21 15:08 lemoer

Hi, @lemoer, thanks for your contribution. Could you please provide an example package which uses Lua postinstall scripts?

aparcar avatar Aug 20 '21 19:08 aparcar

Hi @aparcar,

thank you for picking this up.

Packages that use Lua postinstall scripts exist within gluon (for quite some time).

Explanation: To make it short, we have an additional build configuration file (called site.conf), where users of the build framework can customize the created router images. To ensure the creation of valid router images, this config has to be verified. The verification is done in a opkg postinstall script, since the validity of this config depends on the installed packages. Some packages require options in the config, which others do not. Therefore, we put a (lua) config verification script into the postinstall section of each package, which then checks the site.conf options it relies on.

If desired, I can share additional information about this approach.

lemoer avatar Aug 21 '21 09:08 lemoer

Do you have an estimation how much bigger the imagebuilder becomes?

aparcar avatar Aug 24 '21 07:08 aparcar

With default OpenWrt configuration for x86-64:

~/d/f/i/2/openwrt-imagebuilder-x86-64.Linux-x86_64> du -sh staging_dir/hostpkg/{bin,lib}
1.5M	staging_dir/hostpkg/bin
3.6M	staging_dir/hostpkg/lib

lemoer avatar Aug 26 '21 21:08 lemoer

I updated this patch once more. Now *.so dependencies of lua libraries are also bundled correctly in the imagebuilder.

lemoer avatar Aug 29 '21 21:08 lemoer

@aparcar is the size increase acceptable?

Ansuel avatar Jul 05 '22 23:07 Ansuel

this seems sensible.

neheb avatar Aug 11 '22 21:08 neheb

Please explain the need to change bundle-libraries.sh.

jow- avatar Aug 11 '22 22:08 jow-