[opkg-utils PATCH] opkg-feed: Fix adding feeds with same name as architecture

21 views
Skip to first unread message

Petar Koynov

unread,
May 17, 2023, 2:07:03 PM5/17/23
to opkg-...@googlegroups.com, yo...@lists.yoctoproject.org, Petar Koynov
Attempting to add feeds with some special names was returning an error:
"5 The named feed already exists"
This is because the feed name matched with a configured architecture.
Add a second grep to feedExists to ignore lines starting with "arch".

Signed-off-by: Petar Koynov <petar....@ni.com>
---
opkg-feed | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opkg-feed b/opkg-feed
index 25ef879..98850fa 100755
--- a/opkg-feed
+++ b/opkg-feed
@@ -300,7 +300,7 @@ feedExists()
fi

local feedRegex="$( createFeedLineRegex "$1" )"
- grep -Eoh "$feedRegex" "${ARGS[confDir]}"/*.conf &>/dev/null
+ grep -Eoh "$feedRegex" "${ARGS[confDir]}"/*.conf | grep -vE "^arch\s" &>/dev/null
if [[ "$?" == "$IE_GREP_MATCH" ]] ; then
return $S_OK
fi
--
2.32.0

Petar Koynov

unread,
May 17, 2023, 2:15:30 PM5/17/23
to opkg-...@googlegroups.com, yo...@lists.yoctoproject.org, Petar Koynov

Alex Stewart

unread,
May 18, 2023, 5:20:54 PM5/18/23
to Petar Koynov, opkg-...@googlegroups.com
Hey Petar,

Could you give some more detail as to what config lines were causing the
error?

I'm guessing that the `opkg-feed` script is checking for any config line
which has a "name" field matching the name of the new feed you're trying
to add. And this is erroneously matching against `arch $arch_name
$arch_priority` config lines where arch_name is the same as the feed
name you're trying to add. Is that a correct guess?

In that case, I would think a more direct solution would be to modify
the `sourceTypePattern` [1] to only match source-type config lines. eg,
lines beginning with one of: `dist`, `dist/gz`, `src`, or `src/gz`. [2]

What do you think?


[1] https://git.yoctoproject.org/opkg-utils/tree/opkg-feed#n174

[2] https://git.yoctoproject.org/opkg/tree/libopkg/opkg_conf.c#n403

Thanks,
Alex Stewart
Software Engineer - NI Real-Time OS
NI (National Instruments)

alex.s...@ni.com

Petar Koynov

unread,
May 18, 2023, 7:08:07 PM5/18/23
to Alex Stewart, opkg-...@googlegroups.com
I was running `opkg-feed add cRIO --uri=http://some_url/` and was getting error code 5 "The named feed already exists". In my config I did not have a line `src/gz cRIO ...`, but I did have a line `arch cRIO 13`.

Changing the value of `sourceTypePattern` is better because there may be other lines in the config files that do not specify feeds but run into the same issue colliding with feed names. My change would only ignore `arch` lines.

What should be the value of `sourceTypePattern` ? In my limited use case `sourceTypePattern='("([^"](src|dist)(/gz)?)"|(src|dist)(/gz)?)\s+';` works for me, but I can't vouch for the correctness of any of the regular expressions. I barely understand what they are trying to do. `(src|dist)(/gz)?` was used somewhere else in the file [1].

[1] https://git.yoctoproject.org/opkg-utils/tree/opkg-feed#n252
> +"^arch\s" &>/dev/null
> if [[ "$?" == "$IE_GREP_MATCH" ]] ; then
> return $S_OK
> fi

--
Alex Stewart
Software Engineer - NI Real-Time OS
NI (National Instruments)

alex.s...@ni.com


INTERNAL - NI CONFIDENTIAL

Alex Stewart

unread,
May 19, 2023, 1:58:17 PM5/19/23
to Petar Koynov, opkg-...@googlegroups.com


On 5/18/23 18:08, Petar Koynov wrote:
> I was running `opkg-feed add cRIO --uri=http://some_url/` and was getting error code 5 "The named feed already exists". In my config I did not have a line `src/gz cRIO ...`, but I did have a line `arch cRIO 13`.
>
> Changing the value of `sourceTypePattern` is better because there may be other lines in the config files that do not specify feeds but run into the same issue colliding with feed names. My change would only ignore `arch` lines.
>
> What should be the value of `sourceTypePattern` ? In my limited use case `sourceTypePattern='("([^"](src|dist)(/gz)?)"|(src|dist)(/gz)?)\s+';` works for me, but I can't vouch for the correctness of any of the regular expressions. I barely understand what they are trying to do. `(src|dist)(/gz)?` was used somewhere else in the file [1].

That seems fine to me. I would just plug it into a regex checker with
some test lines and confirm that it matches as you would expect. And I
would also expect `opkg-feed list` to still work. That should be enough
validation, I think.

Petar Koynov

unread,
May 22, 2023, 1:51:28 PM5/22/23
to opkg-...@googlegroups.com, yo...@lists.yoctoproject.org, alex.s...@ni.com, Petar Koynov
Attempting to add feeds with some special names that match
architecture names was returning an error:
"5 The named feed already exists"
Make sourceTypePattern in createFeedLineRegex only match
feed configuration lines src or dist

Signed-off-by: Petar Koynov <petar....@ni.com>
---
opkg-feed | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opkg-feed b/opkg-feed
index 25ef879..36d4463 100755
--- a/opkg-feed
+++ b/opkg-feed
@@ -171,7 +171,7 @@ createFeedLineRegex()
# 1 = full source type with any quotes
# 2 = source type without quotes if quoted
# 3 = source type if unquoted
- sourceTypePattern='("([^"]*)"|(\S+))\s+';
+ sourceTypePattern='("([^"](src|dist)(/gz)?)"|(src|dist)(/gz)?)\s+';

# Feed name capture groups (4, 5, 6)
# 4 = full feed name with any quotes
--
2.32.0

Alex Stewart

unread,
May 22, 2023, 2:35:22 PM5/22/23
to Petar Koynov, opkg-...@googlegroups.com, yo...@lists.yoctoproject.org
ACK; looks good to me.

I'll pull this tomorrow, if there are no objections.

Alex Stewart

unread,
May 24, 2023, 12:01:51 PM5/24/23
to Petar Koynov, opkg-...@googlegroups.com, yo...@lists.yoctoproject.org
Pulled to opkg-utils as 67994e62dc598282830385da75ba9b1abbbda941 [1].

[1]
https://git.yoctoproject.org/opkg-utils/commit/?id=67994e62dc598282830385da75ba9b1abbbda941

Thanks!

On 5/22/23 12:48, Petar Koynov wrote:
Reply all
Reply to author
Forward
0 new messages