[3.21] community/libgpiod: add kludgy compat with libgpiod 1.x tools
This is a compatibility patch for alpine 3.21 only that should not make it to master, where we can keep the pristine libgpiod and so we can forget about this patch as soon as 3.22 is out and rolling.
The commit message has all the rationale, that I had originally brought up in the 2.1.2 update MR: !44760 (comment 466384)
libgpiod 2.0 broke all tools CLI interface abruptly with no partial transition possible (no syntax working with both the old and new version that could allow migrating scripts that depend on these tools one at a time)
This patch introduces a rough (and hopefully safe) heuristic to keep the old syntax alive in the new tool, just for alpine 3.21 (this will NOT be submitted to master)
Folks on 3.21 that have scripts depending on this will hopefully see the warning and fix their scripts, at which point this patch will not matter at all and upgrading will keep working.
The logic is as follow, if --chip
was not specified and either of:
- the first argument is a gpiochip (/dev/gpiochip* or gpiochip*) then there is no doubt it was intended as an 1.x chip argument
- the first argument is a single digit, then it could technically also be a gpio "named" as per that single digit, but as far as I'm aware name are more likely to be something like "gpio3" so this should not happen? then the first argument is considered to be a chip and gpioget/set will enable compatibility options (--numeric for get, unreachable option to exit immediately for set) and a warning will be printed on stderr.
scripts using gpioget would hopefully only be reading stdin so the stderr warning can be displayed to users without breaking the scripts; even if that warning is lost or otherwise badly interpretted then this is no worse than failing because chip was not set anyway.
For people using the new syntax, either by specifying the chip or by using named gpios by names, then this check will be ignored and the tools will work as expected.
I'm interested in having this in alpine itself and not just a local build because we have customers using the alpine repos directly and their scripts broke, so I'm between a rock and a hard place telling people to fix their syntax, and having this workaround downstream would give me some respite that just keeping it in our repo wouldn't provide.
I also intend to ask/send a patch upstream to have an option to exit gpioset immediately, as currently there is no immediate replacement by just fixing the syntax of scripts; once that's settled upstream I'll backport this here as well so we can have a smooth upgrade path working with new syntax on alpine 3.21 before upgrading to 3.22/edge.
Cc @lucaweiss (libgpiod package maintainer)
Thanks!
Merge request reports
Activity
assigned to @lucaweiss
@lucaweiss one last ping now holiday season has passed -- would appreciate your opinion on this.
If no answer by the end of the month I'll just deal with it in our repo and close this MR.
added v3.21 label
- Resolved by Natanael Copa
Sorry for the late response.
I trust you've tested this that it doesn't break the new usage? Other than that, with my limited regular C skills this looks fine, though I'm generally not a fan of adding some non-upstream patches to the package, but if it's a temporary crutch then it's fine imo. But not sure what the Alpine policy would be here?
added 251 commits
-
7e4a44de...be64c52e - 250 commits from branch
alpine:3.21-stable
- 1350cd3f - community/libgpiod: add kludgy compat with libgpiod 1.x tools
-
7e4a44de...be64c52e - 250 commits from branch