Beispiel #1
0
static Offset
parse_deps(Solvable *s, char *bp, Id marker)
{
  Pool *pool = s->repo->pool;
  Offset deps = 0;
  char *nbp, *ebp;
  for (; bp; bp = nbp)
    {
      int ispre = 0;
      Id id, evr = 0;
      int flags = 0;

      nbp = strchr(bp, '@');
      if (!nbp)
	ebp = bp + strlen(bp);
      else
	{
	  ebp = nbp;
	  *nbp++ = 0;
	}
      if (ebp[-1] == ']')
	{
	  char *sbp = ebp - 1;
	  while (sbp >= bp && *sbp != '[')
	    sbp--;
	  if (sbp >= bp && sbp[1] != '*')
	    {
	      char *fbp;
	      for (fbp = sbp + 1;; fbp++)
		{
		  if (*fbp == '>')
		    flags |= REL_GT;
		  else if (*fbp == '=')
		    flags |= REL_EQ;
		  else if (*fbp == '<')
		    flags |= REL_LT;
		  else
		    break;
		}
	      if (*fbp == ' ')
		fbp++;
	      evr = pool_strn2id(pool, fbp, ebp - 1 - fbp, 1);
	      ebp = sbp;
	    }
	}
      if (ebp[-1] == ']' && ebp >= bp + 3 && !strncmp(ebp - 3, "[*]", 3))
	{
	  ispre = 1;
	  ebp -= 3;
	}
      id = pool_strn2id(pool, bp, ebp - bp, 1);
      if (evr)
	id = pool_rel2id(pool, id, evr, flags, 1);
      deps = repo_addid_dep(s->repo, deps, id, ispre ? marker : 0);
      bp = nbp;
    }
  return deps;
}
Beispiel #2
0
static void
set_sourcerpm(Repodata *data, Solvable *s, Id handle, char *sourcerpm)
{
  const char *p, *sevr, *sarch, *name, *evr;
  Pool *pool;

  p = strrchr(sourcerpm, '.');
  if (!p || strcmp(p, ".rpm") != 0)
    return;
  p--;
  while (p > sourcerpm && *p != '.')
    p--;
  if (*p != '.' || p == sourcerpm)
    return;
  sarch = p-- + 1;
  while (p > sourcerpm && *p != '-')
    p--;
  if (*p != '-' || p == sourcerpm)
    return;
  p--;
  while (p > sourcerpm && *p != '-')
    p--;
  if (*p != '-' || p == sourcerpm)
    return;
  sevr = p + 1;
  pool = s->repo->pool;
  if (!strcmp(sarch, "src.rpm"))
    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_SRC);
  else if (!strcmp(sarch, "nosrc.rpm"))
    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_NOSRC);
  else
    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, pool_strn2id(pool, sarch, strlen(sarch) - 4, 1));
  evr = pool_id2str(pool, s->evr);
  if (evr && !strncmp(sevr, evr, sarch - sevr - 1) && evr[sarch - sevr - 1] == 0)
    repodata_set_void(data, handle, SOLVABLE_SOURCEEVR);
  else
    repodata_set_id(data, handle, SOLVABLE_SOURCEEVR, pool_strn2id(pool, sevr, sarch - sevr - 1, 1));
  name = pool_id2str(pool, s->name);
  if (name && !strncmp(sourcerpm, name, sevr - sourcerpm - 1) && name[sevr - sourcerpm - 1] == 0)
    repodata_set_void(data, handle, SOLVABLE_SOURCENAME);
  else
    repodata_set_id(data, handle, SOLVABLE_SOURCENAME, pool_strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1));
}
Beispiel #3
0
/*
 * we support three relations:
 *
 * a = b   both architectures a and b are treated as equivalent
 * a > b   a is considered a "better" architecture, the solver
 *         should change from a to b, but must not change from b to a
 * a : b   a is considered a "better" architecture, the solver
 *         must not change the architecture from a to b or b to a
 */
void
pool_setarchpolicy(Pool *pool, const char *arch)
{
  unsigned int score = 0x10001;
  size_t l;
  char d;
  Id *id2arch;
  Id id, lastarch;

  pool->id2arch = solv_free(pool->id2arch);
  pool->id2color = solv_free(pool->id2color);
  if (!arch)
    {
      pool->lastarch = 0;
      return;
    }
  id = pool->noarchid;
  lastarch = id + 255;
  /* note that we overallocate one element to be compatible with
   * old versions that accessed id2arch[lastarch].
   * id2arch[lastarch] will always be zero */
  id2arch = solv_calloc(lastarch + 1, sizeof(Id));
  id2arch[id] = 1;	/* the "noarch" class */

  d = 0;
  while (*arch)
    {
      l = strcspn(arch, ":=>");
      if (l)
	{
	  id = pool_strn2id(pool, arch, l, 1);
	  if (id >= lastarch)
	    {
	      id2arch = solv_realloc2(id2arch, (id + 255 + 1), sizeof(Id));
	      memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id));
	      lastarch = id + 255;
	    }
	  if (id2arch[id] == 0)
	    {
	      if (d == ':')
		score += 0x10000;
	      else if (d == '>')
		score += 0x00001;
	      id2arch[id] = score;
	    }
	}
      arch += l;
      if ((d = *arch++) == 0)
	break;
    }
  pool->id2arch = id2arch;
  pool->lastarch = lastarch;
}
Beispiel #4
0
static Offset
adddep(Repo *repo, Offset olddeps, char *line)
{
  Pool *pool = repo->pool;
  char *p;
  Id id;

  while (*line == ' ' && *line == '\t')
    line++;
  p = line;
  while (*p && *p != ' ' && *p != '\t' && *p != '<' && *p != '=' && *p != '>')
    p++;
  id = pool_strn2id(pool, line, p - line, 1);
  while (*p == ' ' && *p == '\t')
    p++;
  if (*p == '<' || *p == '=' || *p == '>')
    {
      int flags = 0;
      for (;; p++)
	{  
	  if (*p == '<')
	    flags |= REL_LT;
	  else if (*p == '=')
	    flags |= REL_EQ;
	  else if (*p == '>')
	    flags |= REL_GT;
	  else
	    break;
	}
      while (*p == ' ' && *p == '\t')
        p++;
      line = p;
      while (*p && *p != ' ' && *p != '\t')
	p++;
      id = pool_rel2id(pool, id, pool_strn2id(pool, line, p - line, 1), flags, 1);
    }
  return repo_addid_dep(repo, olddeps, id, 0);
}
Beispiel #5
0
/*
 * we support three relations:
 *
 * a = b   both architectures a and b are treated as equivalent
 * a > b   a is considered a "better" architecture, the solver
 *         should change from a to b, but must not change from b to a
 * a : b   a is considered a "better" architecture, the solver
 *         must not change the architecture from a to b or b to a
 */
void
pool_setarchpolicy(Pool *pool, const char *arch)
{
  unsigned int score = 0x10001;
  size_t l;
  char d;
  Id *id2arch;
  Id id, lastarch;

  pool->id2arch = solv_free(pool->id2arch);
  pool->id2color = solv_free(pool->id2color);
  if (!arch)
    {
      pool->lastarch = 0;
      return;
    }
  id = pool->noarchid;
  lastarch = id + 255;
  id2arch = solv_calloc(lastarch + 1, sizeof(Id));
  id2arch[id] = 1;	/* the "noarch" class */

  d = 0;
  while (*arch)
    {
      l = strcspn(arch, ":=>");
      if (l)
	{
	  id = pool_strn2id(pool, arch, l, 1);
	  if (id > lastarch)
	    {
	      id2arch = solv_realloc2(id2arch, (id + 255 + 1), sizeof(Id));
	      memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id));
	      lastarch = id + 255;
	    }
	  if (id2arch[id] == 0)
	    {
	      if (d == ':')
		score += 0x10000;
	      else if (d == '>')
		score += 0x00001;
	      id2arch[id] = score;
	    }
	}
      arch += l;
      if ((d = *arch++) == 0)
	break;
    }
  pool->id2arch = id2arch;
  pool->lastarch = lastarch;
}
Beispiel #6
0
static Id
parseonedep(Pool *pool, char *p)
{
  char *n, *ne, *e, *ee;
  Id name, evr;
  int flags;

  while (*p == ' ' || *p == '\t' || *p == '\n')
    p++;
  if (!*p)
    return 0;
  if (!strcmp(p, "!true"))
    return 0;
  if (!strcmp(p, "!false"))
    return pool_str2id(pool, p, 1);
  n = p;
  /* find end of name */
  while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '|')
    p++;
  ne = p;
  while (*p == ' ' || *p == '\t' || *p == '\n')
    p++;
  evr = 0;
  flags = 0;
  e = ee = 0;
  if (*p == '>' || *p == '<' || *p == '=' || *p == '!')
    {
      if (*p == '>')
	flags |= REL_GT;
      else if (*p == '=')
	flags |= REL_EQ;
      else if (*p == '<')
	flags |= REL_LT;
      else if (*p == '!')
	flags |= REL_LT | REL_GT | REL_EQ;
      p++;
      if (flags && *p == '=')
	{
	  if (p[-1] != '=')
	    flags ^= REL_EQ;
	  p++;
	}
      while (*p == ' ' || *p == '\t' || *p == '\n')
	p++;
      e = p;
      while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '|')
	p++;
      ee = p;
      while (*p == ' ' || *p == '\t' || *p == '\n')
	p++;
    }
  name = pool_strn2id(pool, n, ne - n, 1);
  if (e)
    {
      evr = pool_strn2id(pool, e, ee - e, 1);
      name = pool_rel2id(pool, name, evr, flags, 1);
    }
  if (*p == '|')
    {
      Id id = parseonedep(pool, p + 1);
      if (id)
	name = pool_rel2id(pool, name, id, REL_OR, 1);
    }
  return name;
}
Beispiel #7
0
static Id
parseonedep(Pool *pool, char *p)
{
  char *n, *ne, *e, *ee;
  Id name, evr;
  int flags;

  while (*p == ' ' || *p == '\t' || *p == '\n')
    p++;
  if (!*p || *p == '(')
    return 0;
  n = p;
  /* find end of name */
  while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '(' && *p != '|')
    p++;
  ne = p;
  while (*p == ' ' || *p == '\t' || *p == '\n')
    p++;
  evr = 0;
  flags = 0;
  e = ee = 0;
  if (*p == '(')
    {
      p++;
      while (*p == ' ' || *p == '\t' || *p == '\n')
	p++;
      if (*p == '>')
	flags |= REL_GT;
      else if (*p == '=')
	flags |= REL_EQ;
      else if (*p == '<')
	flags |= REL_LT;
      if (flags)
	{
	  p++;
	  if (*p == '>')
	    flags |= REL_GT;
	  else if (*p == '=')
	    flags |= REL_EQ;
	  else if (*p == '<')
	    flags |= REL_LT;
	  else
	    p--;
	  p++;
	}
      while (*p == ' ' || *p == '\t' || *p == '\n')
	p++;
      e = p;
      while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != ')')
	p++;
      ee = p;
      while (*p && *p != ')')
	p++;
      if (*p)
	p++;
      while (*p == ' ' || *p == '\t' || *p == '\n')
	p++;
    }
  if (ne - n > 4 && ne[-4] == ':' && !strncmp(ne - 4, ":any", 4))
    {
      /* multiarch annotation */
      name = pool_strn2id(pool, n, ne - n - 4, 1);
      name = pool_rel2id(pool, name, ARCH_ANY, REL_MULTIARCH, 1);
    }
  else
    name = pool_strn2id(pool, n, ne - n, 1);
  if (e)
    {
      evr = pool_strn2id(pool, e, ee - e, 1);
      name = pool_rel2id(pool, name, evr, flags, 1);
    }
  if (*p == '|')
    {
      Id id = parseonedep(pool, p + 1);
      if (id)
	name = pool_rel2id(pool, name, id, REL_OR, 1);
    }
  return name;
}