Doodle3D/doodle3d-firmware

post-install.sh - combine duplicate code

woutgg opened this issue · 0 comments

The post-install script - executed from the 'postinst' target in the package Makefile - has to deal with two ways of package installation. It can be installed as part of an image (i.e., package set to 'yes' in menuconfig), or it can be installed on a live system using opkg.

Which case is at hand can be determined in the script by looking at the variable $IPKG_INSTROOTas we do here. More information on the openwrt wiki and in a post linked from there.

Currently the code inside the if-branch is almost equal to that in the else-branch. The main difference is that on a live box the commands are directly executed, whereas in buildroot they are written to a uci-defaults script which is then run on the system's first boot.

For easier maintenance, that code should be extracted so it does not have to be duplicated. One way of accomplishing this could be to store the commands in a here document which is then either written out to a file, or sourced/eval'ed.