Skip to content
Snippets Groups Projects

[3.21] community/libgpiod: add kludgy compat with libgpiod 1.x tools

Merged Dominique Martinet requested to merge martinetd/aports:libgpiod into 3.21-stable
All threads resolved!

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.

Link: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/commit/?id=8ffb6489286fc9cd68bc5fa283f99b1fa1e05f9d


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!

Edited by Dominique Martinet

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading