File: patchjobs.c

package info (click to toggle)
libsolv 0.7.35-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,804 kB
  • sloc: ansic: 73,004; python: 871; perl: 742; tcl: 730; ruby: 705; sh: 263; cpp: 204; makefile: 41
file content (65 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "pool.h"
#include "repo.h"
#include "evr.h"
#include "solver.h"

void
add_patchjobs(Pool *pool, Queue *job)
{
  Id p, pp;
  int pruneyou = 0;
  Map installedmap, multiversionmap;
  Solvable *s;

  map_init(&multiversionmap, 0);
  map_init(&installedmap, pool->nsolvables);
  solver_calculate_multiversionmap(pool, job, &multiversionmap);
  if (pool->installed)
    {
      FOR_REPO_SOLVABLES(pool->installed, p, s)
        MAPSET(&installedmap, p);
    }

  /* install all patches */
  for (p = 1; p < pool->nsolvables; p++)
    {
      const char *type;
      int r;
      Id p2;

      s = pool->solvables + p;
      if (strncmp(pool_id2str(pool, s->name), "patch:", 6) != 0)
	continue;
      FOR_PROVIDES(p2, pp, s->name)
	{
	  Solvable *s2 = pool->solvables + p2;
	  if (s2->name != s->name)
	    continue;
	  r = pool_evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
	  if (r < 0 || (r == 0 && p > p2))
	    break;
	}
      if (p2)
	continue;
      type = solvable_lookup_str(s, SOLVABLE_PATCHCATEGORY);
      if (type && !strcmp(type, "optional"))
	continue;
      r = solvable_trivial_installable_map(s, &installedmap, 0, &multiversionmap);
      if (r == -1)
	continue;
      if (solvable_lookup_bool(s, UPDATE_RESTART) && r == 0)
	{
	  if (!pruneyou++)
	    queue_empty(job);
	}
      else if (pruneyou)
	continue;
      queue_push2(job, SOLVER_SOLVABLE, p);
    }
  map_free(&installedmap);
  map_free(&multiversionmap);
}