public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
@ 2015-11-28 21:14 Ulrich Mueller
  2015-11-29 23:23 ` Peter Stuge
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ulrich Mueller @ 2015-11-28 21:14 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 4325 bytes --]

As you may know, we intend to move the functionality of
versionator.eclass to the package manager, possibly in EAPI 7.
The following is what mgorny and myself have come up with, see
bug 482170 [1], especially comments 15 and 16 there.

Currently there are 15 functions defined in that eclass, and we
believe that it will not be feasible to implement all of them.
However, several of the functions are similar to each other and can
be combined. Two of them, namely get_version_component_range() and
replace_version_separator(), account for the vast majority of what
is used by ebuilds.

We therefore think that the following three functions would be
sufficient to cover all ebuilds' needs:


version_test [VERSION1] OP VERSION2
===================================

This comes in a two and a three argument form. Syntax is based on
test(1) (therefore the name).

- Compares VERSION1 with VERSION2, using the usual PMS version
  comparison algorithm.

- OP can be one of -eq, -ne, -lt, -le, -gt, -ge, i.e. the binary
  arithmetic operators from test(1). (We avoid C style <, >, etc.
  because they suffer from quoting issues.)

- Both VERSION1 and VERSION2 must be valid Gentoo versions.

- VERSION1 can be omitted and defaults to PVR.

version_cut RANGE [VERSION]
===========================

Since this (and the next) function is intended to aid with conversion
from Gentoo versions to foreign versions and vice versa, it is neither
required that VERSION is a valid Gentoo version, nor will the function
use Gentoo version syntax for splitting. Instead, the following simple
rules will be applied:

A version string is composed of one or more version components,
delimited by (possibly empty) version separators. Each component is a
sequence made purely of letters [A-Za-z] or purely of digits [0-9].
Separators are sequences of other characters [^A-Za-z0-9]. A version
string must start and end with a component (if it doesn't, an empty
first or last component is implied).

For example, the version:

   1.2.3b_alpha4

would be split into (c being component indexes, s separator indexes):

   1  .  2  .  3  '' b  _  alpha '' 4

   ^  ^  ^  ^  ^  ^  ^  ^  ^     ^  ^
   c1 s1 c2 s2 c3 s3 c4 s4 c5    s5 c6

Now to the version_cut() function itself:

- Extracts a part of the version string, containing components from
  the specified RANGE along with separators that are inbetween.

- RANGE is START[-[END]], i.e. START for one index, START-END for a
  range of indexes, or START- for up to the last component.

- All separators contained between the requested version components
  are included; separators preceding and following them are not.
  For example, "version_cut 2-4 1.2.3b_alpha4" would return "2.3b".

- VERSION can be omitted and defaults to PV.

version_replace_separator RANGE REPL [RANGE REPL...] [VERSION]
==============================================================

Especially for this function's name, bikeshedding is still needed.
The name should be reasonably short, as it will be used in global
scope command substitution.

Version components and separators are determined as for the
version_cut() function.

- Replaces version separators by index.

- RANGE is START[-[END]], i.e. START for one index, START-END for a
  range of indexes, or START- for up to the last separator.

- If RANGE includes empty separators, they are replaced as well.
  For example, "replace_version_sep 3 - 1.2.3b" outputs "1.2.3-b".

- REPL is a replacement string. It can be any string, and will be
  repeated for each replaced separator.

- Multiple pairs of RANGE and REPL can be specified. For example,
  "replace_version_sep 1 - 3 '~' 1.2.3b" would output "1-2.3~b".

- VERSION can be omitted and defaults to PV.

- It is not yet entirely clear what should be done in case of
  overlapping ranges. It could be an error, or the last replacement
  could win. Similarly, what should be done if there are less
  separators than specified? (versionator.eclass silently ignores the
  surplus ones.)


Questions:
1. Will these three functions be sufficient, or have we overlooked
   anything important?
2. Are the proposed specifications sane?
3. Some bikeshedding for the names, especially for the name of the
   version_replace_separator() function is needed.

Ulrich


[1] https://bugs.gentoo.org/show_bug.cgi?id=482170

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-11-28 21:14 [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?) Ulrich Mueller
@ 2015-11-29 23:23 ` Peter Stuge
  2015-11-30  6:28   ` Michał Górny
  2015-12-02 11:03 ` Alexis Ballier
  2015-12-07  5:37 ` Jason Zaman
  2 siblings, 1 reply; 9+ messages in thread
From: Peter Stuge @ 2015-11-29 23:23 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 314 bytes --]

Ulrich Mueller wrote:
> 1. Will these three functions be sufficient, or have we overlooked
>    anything important?

Something that comes to mind as probably being semi-frequent is to
transform a version number component into a Gentoo -p number.

Or do you suggest doing that by replacing the separator?


//Peter

[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-11-29 23:23 ` Peter Stuge
@ 2015-11-30  6:28   ` Michał Górny
  0 siblings, 0 replies; 9+ messages in thread
From: Michał Górny @ 2015-11-30  6:28 UTC (permalink / raw
  To: Peter Stuge; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

On Mon, 30 Nov 2015 00:23:02 +0100
Peter Stuge <peter@stuge.se> wrote:

> Ulrich Mueller wrote:
> > 1. Will these three functions be sufficient, or have we overlooked
> >    anything important?  
> 
> Something that comes to mind as probably being semi-frequent is to
> transform a version number component into a Gentoo -p number.
> 
> Or do you suggest doing that by replacing the separator?

Yep, separator replacement can do that easily. RHS can be any string.

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-11-28 21:14 [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?) Ulrich Mueller
  2015-11-29 23:23 ` Peter Stuge
@ 2015-12-02 11:03 ` Alexis Ballier
  2015-12-02 12:04   ` Ulrich Mueller
  2015-12-07  5:37 ` Jason Zaman
  2 siblings, 1 reply; 9+ messages in thread
From: Alexis Ballier @ 2015-12-02 11:03 UTC (permalink / raw
  To: gentoo-dev

On Sat, 28 Nov 2015 22:14:39 +0100
Ulrich Mueller <ulm@gentoo.org> wrote:

> As you may know, we intend to move the functionality of
> versionator.eclass to the package manager, possibly in EAPI 7.
> The following is what mgorny and myself have come up with, see
> bug 482170 [1], especially comments 15 and 16 there.
> 
> Currently there are 15 functions defined in that eclass, and we
> believe that it will not be feasible to implement all of them.
> However, several of the functions are similar to each other and can
> be combined. Two of them, namely get_version_component_range() and
> replace_version_separator(), account for the vast majority of what
> is used by ebuilds.
> 
> We therefore think that the following three functions would be
> sufficient to cover all ebuilds' needs:

What's the point, need or advantage in moving this to all-ebuild-scope?

Usually eclass refactor/api cleanup are done in a -r{n+1} while
deprecating -rn. This would have the advantage that you can quickly
post a complete implementation and get wider reviews.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-12-02 11:03 ` Alexis Ballier
@ 2015-12-02 12:04   ` Ulrich Mueller
  2015-12-02 12:18     ` Alexis Ballier
  0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Mueller @ 2015-12-02 12:04 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

>>>>> On Wed, 2 Dec 2015, Alexis Ballier wrote:

> What's the point, need or advantage in moving this to all-ebuild-scope?

> Usually eclass refactor/api cleanup are done in a -r{n+1} while
> deprecating -rn. This would have the advantage that you can quickly
> post a complete implementation and get wider reviews.

A proof-of-concept implementation for the two version manipulation
functions is here:
https://482170.bugs.gentoo.org/attachment.cgi?id=418072
Add some comments and you'll have a working eclass. :)

Some details are still to be discussed, e.g. what should be the
behaviour if the version string starts or ends with a separator?

Also version_test is missing, but the idea there was to avoid
redundancy and use the implementation that already exists in the
package manager (which does version comparison all the time). This is
one of the reasons for moving it to the package manager.

Ulrich

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-12-02 12:04   ` Ulrich Mueller
@ 2015-12-02 12:18     ` Alexis Ballier
  0 siblings, 0 replies; 9+ messages in thread
From: Alexis Ballier @ 2015-12-02 12:18 UTC (permalink / raw
  To: gentoo-dev

On Wed, 2 Dec 2015 13:04:19 +0100
Ulrich Mueller <ulm@gentoo.org> wrote:

> >>>>> On Wed, 2 Dec 2015, Alexis Ballier wrote:  
> 
> > What's the point, need or advantage in moving this to
> > all-ebuild-scope?  
> 
> > Usually eclass refactor/api cleanup are done in a -r{n+1} while
> > deprecating -rn. This would have the advantage that you can quickly
> > post a complete implementation and get wider reviews.  
> 
> A proof-of-concept implementation for the two version manipulation
> functions is here:
> https://482170.bugs.gentoo.org/attachment.cgi?id=418072
> Add some comments and you'll have a working eclass. :)

Yes, but I don't see the point of defining bash code in PMS and
copy/pasting it in every compliant PM, when said code used to be in
only one place. Sounds like a "regression" to me.


[...]
> Also version_test is missing, but the idea there was to avoid
> redundancy and use the implementation that already exists in the
> package manager (which does version comparison all the time). This is
> one of the reasons for moving it to the package manager.


well, then maybe version_test is the only one that makes sense to be
added to PM. Though it is unclear to me how to interface it: spawning a
python interp. every time the function is called doesn't seem to be a
terrible idea wrt performance.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-11-28 21:14 [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?) Ulrich Mueller
  2015-11-29 23:23 ` Peter Stuge
  2015-12-02 11:03 ` Alexis Ballier
@ 2015-12-07  5:37 ` Jason Zaman
  2015-12-07  7:00   ` Michał Górny
  2015-12-07  7:41   ` Ulrich Mueller
  2 siblings, 2 replies; 9+ messages in thread
From: Jason Zaman @ 2015-12-07  5:37 UTC (permalink / raw
  To: gentoo-dev

On Sat, Nov 28, 2015 at 10:14:39PM +0100, Ulrich Mueller wrote:
> Questions:
> 1. Will these three functions be sufficient, or have we overlooked
>    anything important?

Can we also have get_version_component_count() in there?

I have a package that likes to change the number of parts so I need to
know how many parts before I can split it up.

Basically this:
if [[ $(get_version_component_count) -eq 6 ]]; then
	STUDIO_V=$(get_version_component_range 1-4)
	BUILD_V=$(get_version_component_range 5-6)
else
	STUDIO_V=$(get_version_component_range 1-3)
	BUILD_V=$(get_version_component_range 4-5)
fi

-- Jason


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-12-07  5:37 ` Jason Zaman
@ 2015-12-07  7:00   ` Michał Górny
  2015-12-07  7:41   ` Ulrich Mueller
  1 sibling, 0 replies; 9+ messages in thread
From: Michał Górny @ 2015-12-07  7:00 UTC (permalink / raw
  To: gentoo-dev, Jason Zaman



Dnia 7 grudnia 2015 06:37:50 CET, Jason Zaman <perfinion@gentoo.org> napisał(a):
>On Sat, Nov 28, 2015 at 10:14:39PM +0100, Ulrich Mueller wrote:
>> Questions:
>> 1. Will these three functions be sufficient, or have we overlooked
>>    anything important?
>
>Can we also have get_version_component_count() in there?
>
>I have a package that likes to change the number of parts so I need to
>know how many parts before I can split it up.
>
>Basically this:
>if [[ $(get_version_component_count) -eq 6 ]]; then
>	STUDIO_V=$(get_version_component_range 1-4)
>	BUILD_V=$(get_version_component_range 5-6)
>else
>	STUDIO_V=$(get_version_component_range 1-3)
>	BUILD_V=$(get_version_component_range 4-5)
>fi

local v=( ${PV//./} )

then ${#v[@]}. With some more work, you should be even able to use negative indexing there to avoid conditionals.

I'd rather avoid introducing extra redundant functions for corner cases.

>
>-- Jason

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?)
  2015-12-07  5:37 ` Jason Zaman
  2015-12-07  7:00   ` Michał Górny
@ 2015-12-07  7:41   ` Ulrich Mueller
  1 sibling, 0 replies; 9+ messages in thread
From: Ulrich Mueller @ 2015-12-07  7:41 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

>>>>> On Mon, 7 Dec 2015, Jason Zaman wrote:

> Can we also have get_version_component_count() in there?

> I have a package that likes to change the number of parts so I need
> to know how many parts before I can split it up.

> Basically this:
> if [[ $(get_version_component_count) -eq 6 ]]; then
> 	STUDIO_V=$(get_version_component_range 1-4)
> 	BUILD_V=$(get_version_component_range 5-6)
> else
> 	STUDIO_V=$(get_version_component_range 1-3)
> 	BUILD_V=$(get_version_component_range 4-5)
> fi

You could use a condition like:

    if [[ -n $(version_cut 6) ]]; then

This assumes that the function would simply return an empty string
when trying to read after the last component.

Ulrich

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-12-07  7:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-28 21:14 [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?) Ulrich Mueller
2015-11-29 23:23 ` Peter Stuge
2015-11-30  6:28   ` Michał Górny
2015-12-02 11:03 ` Alexis Ballier
2015-12-02 12:04   ` Ulrich Mueller
2015-12-02 12:18     ` Alexis Ballier
2015-12-07  5:37 ` Jason Zaman
2015-12-07  7:00   ` Michał Górny
2015-12-07  7:41   ` Ulrich Mueller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox