From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 215D41384B4 for ; Sat, 28 Nov 2015 21:14:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BFB2921C058; Sat, 28 Nov 2015 21:14:43 +0000 (UTC) Received: from a1www.kph.uni-mainz.de (a1www.kph.uni-mainz.de [134.93.134.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A76FF21C03C for ; Sat, 28 Nov 2015 21:14:42 +0000 (UTC) Received: from a1i15.kph.uni-mainz.de (a1i15.kph.uni-mainz.de [134.93.134.92]) by a1www.kph.uni-mainz.de (8.14.9/8.14.7) with ESMTP id tASLEeum006207 for ; Sat, 28 Nov 2015 22:14:40 +0100 Received: from a1i15.kph.uni-mainz.de (localhost [127.0.0.1]) by a1i15.kph.uni-mainz.de (8.14.8/8.14.2) with ESMTP id tASLEeJv013616; Sat, 28 Nov 2015 22:14:40 +0100 Received: (from ulm@localhost) by a1i15.kph.uni-mainz.de (8.14.8/8.14.8/Submit) id tASLEdLZ013612; Sat, 28 Nov 2015 22:14:39 +0100 Message-ID: <22106.6463.805834.391338@a1i15.kph.uni-mainz.de> Date: Sat, 28 Nov 2015 22:14:39 +0100 To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] RFD: Replacement for versionator.eclass in PMS (for EAPI 7?) X-Mailer: VM 8.2.0b under 24.3.1 (x86_64-pc-linux-gnu) From: Ulrich Mueller Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="pgp+signed+96kBcsU/vXsgjLB"; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: 24e0c0ae-ac13-4e27-b81b-9a4c8de1957d X-Archives-Hash: a992cd7a6d2327ffafcfaa11ba4bbf4a This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --pgp+signed+96kBcsU/vXsgjLB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --pgp+signed+96kBcsU/vXsgjLB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBCAAGBQJWWhk6AAoJEMMJBoUcYcJziOkH/Rh8ODTijS97s3oZTZuycJ4U 9haE7odJv55QnmWVaPhhgX7GRzOHQ/WL4zmpzidbVpBl+BNqjmIEqE+0qtR3P6GO EDssV0X1+sOUVgjm37AjYsFJe8tcP/R3t1O99oz8/DhcEMjTr9HdscQwOsUNqnMV o/1W83kEgI/IX7LpjsbC+8tqhLXK+ik8uCYw4MlTZGxuYU/AN1Nj0svMXHzddSB0 yBuLqut06fntrbL7buYRgl1dpjiCFccmX5Ie9/MdqH6wDM7Rr3ZHcqaSB84xw9wi hEXIL0zi2NTWDL6ZX2U34FZCUNi2o0Qo68JwFHAv23CzeqsTcPJF0Y7QeL33TWk= =4USQ -----END PGP SIGNATURE----- --pgp+signed+96kBcsU/vXsgjLB--