Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 941200 - app-portage/gentoolkit-0.6.7: euse claims that an unversioned atom with capital letters is invalid
Summary: app-portage/gentoolkit-0.6.7: euse claims that an unversioned atom with capit...
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: AMD64 Linux
: Normal major
Assignee: Portage team
URL: https://github.com/gentoo/gentoolkit/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-09 12:15 UTC by Sviatoslav @webknjaz Sydorenko #StandWithUkraine
Modified: 2024-10-09 12:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sviatoslav @webknjaz Sydorenko #StandWithUkraine 2024-10-09 12:15:50 UTC
Basically, this is what's happening:
```
$ euse -p x11-libs/wxGTK -E webkit
ERROR: Invalid package atom. Did you forget the leading '='?
$ euse -E static-libs -p media-libs/qhull
Adding "media-libs/qhull[static-libs]" use flag in "/etc/portage/package.use/qhull"
```

Since it's failing consistently and only for the first atom and none others, I decided to investigate and stick a few print statements into `euse`. I've found out that the internal `${V}` is set to "GTK", which is what triggered that error handling code path.

Having stared into that function long enough, I realized that the underlying issue is the regex using `a-z` to separate the name from the version. And since no capital letters matching this class, they end up in the version group.

Reproducible: Always

Steps to Reproduce:
sudo euse -p x11-libs/wxGTK -E webkit
Actual Results:  
ERROR: Invalid package atom. Did you forget the leading '='?

Expected Results:  
Adding "x11-libs/wxGTK[webkit]" use flag in "/etc/portage/package.use/wxGTK"

I must note that I copied all the names from the `emerge freecad` output, which added to the confusion because I *knew* it exists, but still, `euse` was gaslighting me.

Here's my patch that addresses the issue to the extent it affects me. I'll send a PR on GH.
```
--- /usr/bin/euse	2024-09-10 11:15:42.000000000 +0200
+++ euse	2024-10-09 14:00:49.033925301 +0200
@@ -294,7 +294,7 @@
 	# Flip signs of use.mask (it's interpreted oppositely),
 	ACTIVE_FLAGS[6]=$(reduce_incrementals_trump \
 		$(cat $(traverse_profile "use.mask") | sed -re "/^#.*$/{d}") \
-			| sed -re "s/(^| )-[^ ]*//g" -e "s/(^| )([a-z0-9])/ -\2/g")
+			| sed -re "s/(^| )-[^ ]*//g" -e "s/(^| )([a-zA-Z0-9])/ -\2/g")
 	ACTIVE_FLAGS[7]=$(reduce_incrementals \
 		$(cat $(traverse_profile "use.force") \
 			| sed -re "/^#.*$/ {d}"))
@@ -1024,7 +1024,7 @@
 modify_package() {
 	get_useflags
 
-	local atom_re="^[<>]?=?([a-z][0-9a-z/-]+[0-9a-z])(-[0-9pr._*-]+)?"
+	local atom_re="^[<>]?=?([a-zA-Z][0-9a-zA-Z/-]+[0-9a-zA-Z])(-[0-9pr._*-]+)?"
 	local pkg=$(echo "${PACKAGE}" | sed -re "s/${atom_re}/\1/")
 	local V=$(echo "${PACKAGE}" | sed -re "s/${atom_re}/\2/")
 	local pkg_re="[<>]?=?${pkg}(-[\dpr._*-]+)?"
```