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

Adrian Schmutzler mail at adrianschmutzler.de
Thu Mar 12 14:38:10 EDT 2020


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 places.

However, I realized that currently /lib/functions/system.sh is sourced in
/lib/functions.sh, function default_postinst():


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 system.sh
is actually used directly, but it's merely put there as an "external include"
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 cross
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 script
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.

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

Any opinions?



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

More information about the openwrt-devel mailing list