How to pre-install an ipk

Recently I'm studying to build my own image, but some requirements bother me.

  1. If I have an pre-compiled ipk, how can I install it during the openwrt compile process
  2. How to init something after the first time startup, but these init script will NOT run second time. My solution now is that writting a script file and call it by rc.local, and delete the call at the end of the script. But I think there should be another way provided by openwrt.

You can't install an .ipk in the main compilation process, it compiles everything from sources.

One option is to just included the necessary binaries as "custom files" into the build. Just unpack the .ipk and place files correctly in /files/usr/bin, /files/etc and so on.
https://wiki.openwrt.org/doc/howto/build#custom_files

There is: uci-defaults
A script placed in /etc/uci-defaults runs once at boot and gets automatically deleted if it succeeds (exit status 0). If it fails (exit status non-zero), then it tries again at the next boot.
https://openwrt.org/docs/guide-developer/uci-defaults

Thanks !:grinning: That's want I need!