Seemingly simple question, related to overwriting default configuration of dnsmasq.conf file provided by the dnsmasq package. Question has two facets:
during compilation - I put in Makefile that package is dependent on the dnsmasq package, and the default configuration file is being overwritten by my package's file into the image. No warnings or errors. I am not sure what I do is correct, but it works.
during installation - obvious is to say --force-overwrite to the opkg, but is there a better way, because it is clear upfront that my package is going to replace existing file from another package. Is there any way to tell within the package to throw warning instead of error and proceed with installation? Why I am bothering with it instead of just headlessly use force overwriting: in case there're some other files coming from another package (or I just made a mistake in the package) and then those files will be replaced too - instead of allowing replacement of dnsmasq.conf file only and then terminate on any other replacement file.
Very good point! In case of dnsmasq.conf it comes with no active options (everything is commented), therefore I can parse it and see if required options are in there and if not, add them. But for this I need to design parser script, this file seems to be not manageable through luci. Copy file is simple and dirty way with predefined effect, editing file may involve seeing and analyzing of what else is in there.
Edit: elaborating on your suggestion - why not just put my required text into the file in the postinst script, instead of trying to install the new file...
You might look into uci-defaults scripts, which can be used for one-time run at installation (or first boot after flash). They are used to changes config via UCI commands.
It is bad practice to forcibly overwrite other packages' files...
And that's why I decided to ask question as do not like it too. I anyway have additional custom package right now (described it in another thread copying files on sysupgrade) which does specific things to u-boot at first startup, I will just add update to the dnsmasq.conf file in there.
Not knowing the details about the package in question, it's impossible to answer what the best solution is, but pretty much anything (running sed on the conf-file, adding your own conf file, etc) is better than overwriting the dnsmasq.conf.
I (again) decided going the non-recommended way. I reverted back to the code where I install the platform.sh file and dnsmasq.conf files with my package at the time of compilation with predefined result of erasing the overlay/root will restore them back into the operation, as well as anything sourced from the rom will be the version I need.