[OpenWrt-Devel] cyclic dependency for /lib/functions.sh and /lib/functions/system.sh in special case

mans0n mans0n at gorani.run
Fri Mar 13 09:35:07 EDT 2020

Hi Adrian,

On 2020-03-13 03:38, mail at adrianschmutzler.de (Adrian Schmutzler) wrote:
 > Hi,
 > I just wanted to source /lib/functions.sh in /lib/functions/system.sh
 > (base-files package), as several functions in the latter require the 
former and
 > it's annoying (and untidy) to have to include both files in several 
 > However, I realized that currently /lib/functions/system.sh is sourced in
 > /lib/functions.sh, function default_postinst():
 > /package/base-files/files/lib/functions.sh#L257
 > So, currently effectively both files depend on each other in at least 
one case.
 > However, in default_postinst(), it looks to me like no function from 
 > is actually used directly, but it's merely put there as an "external 
 > for the /etc/uci-defaults/* files processed there.
 > I'd like to resolve this, both as I think the sourcing of 
/lib/functions.sh in
 > /lib/functions/system.sh is helpful and tidy and because I think the 
 > dependency is quite undesirable.
 > I see two solutions to that problem:
 > 1. Remove the sourcing of /lib/functions/system.sh in 
default_postinst(). That
 > would be the tidiest way IMO, as dependencies used in a uci-default 
 > should just be put there. But it might break things if people relied 
on it. It
 > would be relatively easy to fix uci-default scripts in openwrt repos, but
 > downstream might complain. Still, I'd prefer this solution.

I like your first solution. It seems there's only one uci-defaults file 
in OpenWrt
repo which really uses /lib/functions/system.sh. I guess downstream 
projects can
handle it relatively easily.

And if we are going to break things, I'd also like to create something like
/lib/functions/mtd.sh and move all mtd functions to there (and rename 
to macaddr.sh if possible). I don't feel there's no good reason to keep 
in functions.sh and find_mtd_chardev() in system.sh.
Then we might even don't need to source /lib/functions.sh in 
at the first place. (I think /lib/functions.sh is too big to be sourced 
But that would really break things heavily, so it's just my thought.


 > 2. A second option would be to keep the include, but just move the 
 > default_postinst() out of /lib/functions.sh (from my perspective, it 
 > really match there anyway) into a different library file (which?). 
This would
 > still resolve my "dependency problem".
 > Any opinions?
 > Best
 > Adrian

openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list