Summary: | =app-portage/gentoolkit-0.5.1-r1: euse parses net-wireless/wpa_supplicant wrongly | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Olivier Huber <oli.huber> |
Component: | Unclassified | Assignee: | Portage Tools Team <tools-portage> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Olivier Huber
2022-03-17 11:45:05 UTC
(In reply to Olivier Huber from comment #0) > Limited knowledge of the extended regexp here, but adding "_" in the first > group as follow > > PACKAGE=net-wireless/wpa_supplicant > atom_re="^[<>]?=?([a-z][_0-9a-z/-]+[0-9a-z])(-[0-9pr._*-]+)?" > pkg=$(echo "${PACKAGE}" | sed -re "s/${atom_re}/\1/") > V=$(echo "${PACKAGE}" | sed -re "s/${atom_re}/\2/") That's an improvement, but still not entirely correct. PMS <https://projects.gentoo.org/pms/8/pms.html#x1-150003> says about package names: "A package name may contain any of the characters [A-Za-z0-9+_-]. It must not begin with a hyphen or a plus sign, and must not end in a hyphen followed by anything matching the version syntax described in section 3.2." So the first matching group should be: ([A-Za-z0-9_][A-Za-z0-9+_-]*) For the version, a regexp can be found in eapi7-ver.eclass (function _ver_compare): re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9 ]+)?$" Some of the parentheses can be omitted, but this has been tested and is also used in Portage in EAPI 7 and later. (In reply to Ulrich Müller from comment #1) Thanks for looking into this and providing useful pieces of advice. After looking at the PMS, I'm now using atom_re="^[<>]?=?([A-Za-z0-9_][A-Za-z0-9+_.-]*/[A-Za-z0-9_][A-Za-z0-9+_-]*)(-([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?)?" pkg=$(echo "${PACKAGE}" | sed -re "s:${atom_re}:\1:") V=$(echo "${PACKAGE}" | sed -re "s:${atom_re}:\2:") echo "pkg=$pkg" echo "V=$V" However, if I test that with PACKAGE=virtual/man-0-r4 it fails to split the version out. To my very limited regexp knowledge, the first group can capture the whole variable. I'm unsure how to handle this case. Would it be right to detect if a version is present in PACKAGE and only in this case to split it into pkg and V? I've got working regular expressions here: https://github.com/mattst88/dep-parsing |