Doodle3D / doodle3d-firmware

The API of the Doodle3D WiFi box. This can for example talk to print3d, save settings, update the firmware etc.
www.doodle3d.com
GNU General Public License v2.0
13 stars 9 forks source link

post-install.sh - combine duplicate code #59

Open woutgg opened 8 years ago

woutgg commented 8 years ago

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.