Permalink
Browse files

Fix selection_canon when there's a zero epoch provided

Also add tests.
  • Loading branch information...
1 parent 405df83 commit b5d0451c757b16fe2f8b0a9aef21608e42b14e07 @mlschroe mlschroe committed Nov 20, 2017
Showing with 65 additions and 2 deletions.
  1. +12 −2 src/selection.c
  2. +53 −0 test/testcases/selection/selection_canon_rpm.t
View
@@ -1034,11 +1034,22 @@ selection_filelist(Pool *pool, Queue *selection, const char *name, int flags)
/* magic epoch promotion code, works only for SELECTION_NAME selections */
static void
-selection_filter_evr(Pool *pool, Queue *selection, char *evr)
+selection_filter_evr(Pool *pool, Queue *selection, const char *evr)
{
int i, j;
Queue q;
Id qbuf[10];
+ const char *sp;
+
+ /* do we already have an epoch? */
+ for (sp = evr; *sp >= '0' && *sp <= '9'; sp++)
+ ;
+ if (*sp == ':' && sp != evr)
+ {
+ /* yes, just add the rel filter */
+ selection_filter_rel(pool, selection, REL_EQ, pool_str2id(pool, evr, 1));
+ return;
+ }
queue_init(&q);
queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
@@ -1055,7 +1066,6 @@ selection_filter_evr(Pool *pool, Queue *selection, char *evr)
{
Solvable *s = pool->solvables + p;
const char *sevr = pool_id2str(pool, s->evr);
- const char *sp;
for (sp = sevr; *sp >= '0' && *sp <= '9'; sp++)
;
if (*sp != ':')
@@ -0,0 +1,53 @@
+repo available 0 testtags <inline>
+#>=Pkg: A 1 1 noarch
+#>=Pkg: A 2 1 noarch
+#>=Prv: A = 3.1
+#>=Pkg: A 2 2 i686
+#>=Pkg: A 1:1 1 i686
+#>=Pkg: A 2 2 badarch
+#>=Pkg: A 1:3 1 i686
+system i686 rpm
+
+disable pkg E-1-1.src@available
+disable pkg F-1-1.src@available
+
+job noop selection A-2 canon
+result jobs <inline>
+#>job noop name A = 2 [setev]
+
+nextjob
+job noop selection A-2-1 canon
+result jobs <inline>
+#>job noop name A = 2-1 [setevr]
+
+nextjob
+job noop selection A-3 canon
+result jobs <inline>
+#>job noop name A = 1:3 [setev]
+
+nextjob
+job noop selection A-3-1 canon
+result jobs <inline>
+#>job noop name A = 1:3-1 [setevr]
+
+nextjob
+job noop selection A-1 canon
+result jobs <inline>
+#>job noop oneof A-1-1.noarch@available A-1:1-1.i686@available
+
+nextjob
+job noop selection A-1-1 canon
+result jobs <inline>
+#>job noop oneof A-1-1.noarch@available A-1:1-1.i686@available
+
+
+nextjob
+job noop selection A-0:1-1 canon
+result jobs <inline>
+#>job noop name A = 0:1-1 [setevr]
+
+nextjob
+job noop selection A-1:1-1 canon
+result jobs <inline>
+#>job noop name A = 1:1-1 [setevr]
+

0 comments on commit b5d0451

Please sign in to comment.