Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms:eapi-7 commit in: /
Date: Thu, 28 Sep 2017 16:58:28
Message-Id: 1506616248.62a8ce605351d6968db8102a70f84b9dead9a863.mgorny@gentoo
1 commit: 62a8ce605351d6968db8102a70f84b9dead9a863
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 27 21:23:22 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 28 16:30:48 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/pms.git/commit/?id=62a8ce60
7
8 EAPI 7 has version manipulation and comparison functions
9
10 Bug: https://bugs.gentoo.org/482170
11
12 eapi-differences.tex | 4 +++
13 pkg-mgr-commands.tex | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 84 insertions(+)
15
16 diff --git a/eapi-differences.tex b/eapi-differences.tex
17 index 44869c0..a56f1ff 100644
18 --- a/eapi-differences.tex
19 +++ b/eapi-differences.tex
20 @@ -41,6 +41,9 @@ of this document for a complete table of previous EAPIs.
21 \bottomrule
22 \endlastfoot
23
24 +\t{ver_*} functions & \compactfeatureref{ver-functions} &
25 + No & No & No & No & Yes \\
26 +
27 \t{package.mask} directory & \compactfeatureref{package-mask-dir} &
28 No & No & No & No & Yes \\
29
30 @@ -383,6 +386,7 @@ EAPI 7 is EAPI 6 with the following changes:
31 \item \t{package.mask}, \t{package.use}, \t{use.*} and \t{package.use.*} in a profile can be
32 directories, \featureref{profile-file-dirs}.
33 \item \t{dohtml} banned, \featureref{banned-commands}.
34 +\item Version manipulation and comparison functions added, \featureref{ver-functions}.
35 \end{compactitem}
36
37 \ChangeWhenAddingAnEAPI{7}
38
39 diff --git a/pkg-mgr-commands.tex b/pkg-mgr-commands.tex
40 index e8a6555..15bfcde 100644
41 --- a/pkg-mgr-commands.tex
42 +++ b/pkg-mgr-commands.tex
43 @@ -817,6 +817,86 @@ These functions check whitespace-separated lists for a particular value.
44 \item[hasq] Deprecated synonym for \t{has}.
45 \end{description}
46
47 +\subsubsection{Version manipulation and comparison commands}
48 +\featurelabel{ver-functions}
49 +Those functions provide routines to work with version strings. Their availability per EAPI is listed
50 +in table~\ref{tab:version-functions}.
51 +
52 +For the purpose of version manipulation functions, the specification provides a method for splitting
53 +an arbitrary version string (not necessarily conforming to \ref{sec:version-spec}) into a series of
54 +version components and version separators.
55 +
56 +A version component consists either purely of digits (\t{[0-9]+}) or purely of a combination of
57 +uppercase and lowercase letters (\t{[a-zA-Z]+}). A version separator is either a string of any other
58 +characters (\t{[\textasciicircum 0-9a-zA-Z]}) or it occurs at the transition between a sequence of digits
59 +and a sequence of letters, or vice versa. In the latter case, the version separator is an empty
60 +string.
61 +
62 +The version string is processed left-to-right, with the successive version components being assigned
63 +successive indices starting with 1. The separator following a version component is assigned
64 +the index of the preceding version component. If the first version component is preceded by
65 +a non-null string of version separator characters, this separator is assigned the index 0.
66 +
67 +The version components are presumed present if not empty. The version separators between version
68 +components are always presumed present, even if they are empty. The version separators preceding
69 +the first version component and following the last are only presumed present if they are not empty.
70 +
71 +Whenever the functions support ranges, the range is specified as a non-negative integer, optionally
72 +followed by a hyphen (\t{-}), which in turn is optionally followed by another non-negative integer.
73 +
74 +A single integer specifies a single component or separator index. An integer followed by a hyphen
75 +specifies all components or separators starting with the one at specified index. Two integers
76 +separated by a hyphen specify a range of versions starting at the index specified by the first
77 +and ending at the second, inclusively.
78 +
79 +\begin{description}
80 +\item[ver_cut] Takes a range as the first argument, and optionally a version string as the second.
81 + Prints a substring of the version string starting at the version component specified as start
82 + of the range and ending at the version component specified as end of the range. If the version
83 + string is not specified, \t{\$\{PVR\}} is used.
84 +
85 + If the range spans outside the present version components, the missing components and separators
86 + are presumed empty. In particular, the range starting at zero includes zeroth version separator
87 + if present, and the range spanning past the last version component includes the suffix following
88 + it if present. A range that does not intersect with any present version components yields empty
89 + string.
90 +
91 +\item[ver_rs] Takes one or more pairs of arguments, optionally followed by a version string. Every
92 + argument pair specifies a range and a replacement string. Prints a version string after
93 + performing the specified separator substitutions. If the version string is not specified,
94 + \t{\$\{PVR\}} is used.
95 +
96 + For every argument pair specified, each of the version separators present at indices specified
97 + by the range is replaced with the replacement string, in order. If the range spans outside
98 + the range of present version separators, it is silently truncated.
99 +
100 +\item[ver_test] Takes two or three arguments. In the 3-argument form, it takes a LHS version string,
101 + followed by an operator, followed by RHS version string. In the 2-argument form, the first
102 + version string is omitted and \t{\$\{PVR\}} is used as LHS version string. Returns 0
103 + if the specified relation between LHS and RHS version strings is true.
104 +
105 + The operator can be \t{-lt}, \t{-le}, \t{-eq}, \t{-ne}, \t{-ge} and \t{-gt} to test whether
106 + LHS is respectively older than, older or equal, equal, not equal, newer or equal, and newer
107 + than RHS. Both version strings must conform to the version specification
108 + at~\ref{sec:version-spec}, the comparison is done using algorithm~\ref{alg:version-comparison}.
109 +\end{description}
110 +
111 +\ChangeWhenAddingAnEAPI{7}
112 +\begin{centertable}{EAPIs supporting version manipulation commands}
113 + \label{tab:version-functions}
114 + \begin{tabular}{llll}
115 + \toprule
116 + \multicolumn{1}{c}{\textbf{EAPI}} &
117 + \multicolumn{1}{c}{\textbf{\t{ver_cut}?}} &
118 + \multicolumn{1}{c}{\textbf{\t{ver_rs}?}} &
119 + \multicolumn{1}{c}{\textbf{\t{ver_test}?}} \\
120 + \midrule
121 + 0, 1, 2, 3, 4, 5, 6 & No & No & No \\
122 + 7 & Yes & Yes & Yes \\
123 + \bottomrule
124 + \end{tabular}
125 +\end{centertable}
126 +
127 \subsubsection{Misc commands}
128 The following commands are always available in the ebuild environment, but don't really fit in any
129 of the above categories. Ebuilds must not run any of these commands once the current phase function