Some feeds might need to set the source for their packages in a
different directory than the cloned one.
For example a feed "test" might be an entire repository and the relevant
packages that wants to be included are in the directory "foo".
In such scenario the source info in the package will result in something
like "feeds/test/foo/network/dnsmasq" instead of an expected entry like
"feeds/test/network/dnsmasq".
To give a more real-world example, this problem is currently present
with OpenWrt SDK where the SDK clone the entire OpenWrt core repository
as "base" feeds but the package are present in the "package" directory.
This cause every package to have the source entry set to
"feeds/base/package/..." conflicting with what a non-SDK build do with
setting the source entry to "feeds/base/..."
To solve this, actually enable support for "flags" in the feeds script
and implement a new option "--root" to set the root directory for the
defined feed to an inner directory.
The "flags" in the feed script are no more than argument option that can
be defined right after the "src-" type in the feed.conf file.
This feature was partially implemented but never actually used for
anything keeping it dormant with all the core piece there (the pattern
regex always accounted for these extra option but they were never passed
to the relevant functions)
An example of the "--root" flag is the following:
src-git --root=package base https://git.openwrt.org/openwrt/openwrt.git;main
With "--root" defined, the script will append "_root" to the feed name
clone directory and will create a symbolic link named with the feed name
and pointing to the feed name clone directory + the value in root.
From the previous example:
feed name: base -> clone directory: base_root
symbolic link: base -> base_root/package
The script internally reference the "_root" directory for every update
operation and OpenWrt build system transparently use the feed name
directory to reference feed packages producing consistent source info
entry.
Link: https://github.com/openwrt/openwrt/pull/20396
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>