{generic,git}Updater: allowed versions

The common-updater infrastructure supports an attribute for ignoredVersions to exclude versions from consideration, which is an extended regular expression. This is frequently used to ignore -dev suffixes and the like.

Occasionally, like with this update script, it’s used to require that a particular version prefix is present. Because EREs don’t support negative lookaheads or similar, the resulting expression is convoluted and non-obvious (this case isn’t as bad as it could be, but imagine matching a longer prefix). I recently recommended this pattern to someone asking about it in nixpkgs-update, and felt a little guilty about doing so for this reason.

I’m considering:

  • making generic-update-script.sh use grep -P instead of grep -E to interpret ignoredVersions as a PCRE instead, which would enable negative lookaheads
  • adding an allowedVersions attribute to the updaters, which would be a regular expression used as a positive prefilter on the tags

Any reasons to prefer one over the other?

1 Like

I have a better idea: what about accepting an arbitrary function that receives the version and returns true or false?
Regular Expressions are not the only valid method to indicate a valid or invalid string, after all.

Expressed in shell? Seems a bit awkward; what’s the non-RE-based case you have in mind?

I have no Type-2 (Chomsky hierarchy) example case in the wild.

Any case too complicated to be written as Type-1 regex can be evoked, like the infamous “reject non-multiples of 10”.

As far as I remember, Linux kernel used a complicated interaction between minor version and patch in order to define if the release was considered stable or not. But this is not the case nowadays.

I’d rather have a convenient interface for cases we know about than a less-convenient interface for theoretical cases.

Complementary regex is not theoretical.

Could you please unpack that into an example then? It’d be easier for me to understand why you think a shell function would be better if I had something concrete to look at, instead of lofty talk about Chomsky hierarchies (which isn’t even accurate; PCREs accept Type-2 languages) and hints at ‘complicated interactions’ that I’m not familiar with.

The person that maintains Trealla is a bit strange.
Every single day theey fire at least five new tagged releases:

I am pondering to filter the latest version whose patch number is a multiple of 20 - since it would be useless to package all releases.

Okay, so you’d use allowedVersions = "\\.([0-9]*[24680])?0$"; if that feature were available to you?

Yes. Better than nothing.

Just for completeness sake, in GNOME update script, we have a freeze argument, which takes either a string representing a strict upper bound on version or true (short for major.(minor+1)). That is slightly nicer to use but allowedVersions is more flexible and necessary for some of the stuff in common-updater-scripts: add allowedVersions parameter by rhendric · Pull Request #322284 · NixOS/nixpkgs · GitHub.