Skip to content

Commit

Permalink
- add support for repository disabling
Browse files Browse the repository at this point in the history
- add support for checksum stringification
- rename internal repodata functions
- add limited support for package colors
- do not put patches/patterns into the transaction
  • Loading branch information
mlschroe committed Jul 9, 2009
1 parent 44c8cfa commit 539bae9
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 78 deletions.
8 changes: 4 additions & 4 deletions examples/solv.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ checksig(Pool *sigpool, FILE *fp, FILE *sigfp)
cleanupgpg(gpgdir);
return 0;
}
snprintf(cmd, sizeof(cmd), "gpg -q --homedir %s --import %s", gpgdir, keysfile);
snprintf(cmd, sizeof(cmd), "gpg2 -q --homedir %s --import %s", gpgdir, keysfile);
if (system(cmd))
{
fprintf(stderr, "key import error\n");
Expand Down Expand Up @@ -632,7 +632,7 @@ writecachedrepo(Repo *repo, unsigned char *cookie)
sat_free(addedfileprovides);
repodata_internalize(info);
repo_write(repo, fp, 0, 0, 0);
repo_free_repodata(repo, info);
repodata_free(info);
if (fwrite(cookie, 32, 1, fp) != 1)
{
fclose(fp);
Expand Down Expand Up @@ -1417,7 +1417,7 @@ main(int argc, char **argv)
if (os->repo == pool->installed && os->name == s->name && os->arch == s->arch && os->evr == baseevr)
break;
}
if (op)
if (op && access("/usr/bin/applydeltarpm", X_OK) == 0)
{
/* base is installed, run sequence check */
const char *seqname;
Expand All @@ -1434,7 +1434,7 @@ main(int argc, char **argv)
seqnum = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM);
seq = pool_tmpjoin(pool, seqname, "-", seqevr);
seq = pool_tmpjoin(pool, seq, "-", seqnum);
if (system(pool_tmpjoin(pool, "applydeltarpm -c -s ", seq, 0)) != 0)
if (system(pool_tmpjoin(pool, "/usr/bin/applydeltarpm -c -s ", seq, 0)) != 0)
continue; /* didn't match */
/* looks good, download delta */
chksumtype = 0;
Expand Down
35 changes: 23 additions & 12 deletions src/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,12 @@ prune_to_best_version(Pool *pool, Queue *plist)
{
FOR_PROVIDES(p, pp, obs)
{
if (pool->solvables[p].name == s->name)
Solvable *ps = pool->solvables + p;
if (ps->name == s->name)
continue;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
continue;
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
for (j = 0; j < plist->count; j++)
{
Expand Down Expand Up @@ -472,11 +475,14 @@ policy_create_obsolete_index(Solver *solv)
{
FOR_PROVIDES(p, pp, obs)
{
if (pool->solvables[p].repo != installed)
Solvable *ps = pool->solvables + p;;
if (ps->repo != installed)
continue;
if (ps->name == s->name)
continue;
if (pool->solvables[p].name == s->name)
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
continue;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
obsoletes[p - installed->start]++;
}
Expand All @@ -503,15 +509,17 @@ policy_create_obsolete_index(Solver *solv)
{
FOR_PROVIDES(p, pp, obs)
{
if (pool->solvables[p].repo != installed)
Solvable *ps = pool->solvables + p;;
if (ps->repo != installed)
continue;
if (pool->solvables[p].name == s->name)
if (ps->name == s->name)
continue;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
continue;
p -= installed->start;
if (obsoletes_data[obsoletes[p]] != i)
obsoletes_data[--obsoletes[p]] = i;
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
if (obsoletes_data[obsoletes[p - installed->start]] != i)
obsoletes_data[--obsoletes[p - installed->start]] = i;
}
}
}
Expand Down Expand Up @@ -570,7 +578,10 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all)
{
FOR_PROVIDES(p2, pp2, obs) /* and all matching providers of the obsoletes */
{
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
Solvable *ps2 = pool->solvables + p2;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps2, obs))
continue;
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps2))
continue;
if (p2 == n) /* match ! */
break;
Expand Down
20 changes: 4 additions & 16 deletions src/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ struct _Pool {
int promoteepoch; /* true: missing epoch is replaced by epoch of dependency */
int obsoleteusesprovides; /* true: obsoletes are matched against provides, not names */
int implicitobsoleteusesprovides; /* true: implicit obsoletes due to same name are matched against provides, not names */
int obsoleteusescolors; /* true: obsoletes check arch color */
int novirtualconflicts; /* true: conflicts on names, not on provides */
int allowselfconflicts; /* true: packages which conflict with itself are installable */

Id *id2arch; /* map arch ids to scores */
Id lastarch; /* last valid entry in id2arch */
unsigned char *id2color; /* map arch ids to colors */
Id lastarch; /* last valid entry in id2arch/id2color */

Queue vendormap; /* map vendor to vendorclasses mask */

/* providers data, as two-step indirect list
Expand Down Expand Up @@ -241,21 +244,6 @@ extern void pool_addfileprovides_ids(Pool *pool, struct _Repo *installed, Id **i
extern void pool_freewhatprovides(Pool *pool);
extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);

static inline int pool_installable(const Pool *pool, Solvable *s)
{
if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
return 0;
if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))
return 0;
if (pool->considered)
{
Id id = s - pool->solvables;
if (!MAPTST(pool->considered, id))
return 0;
}
return 1;
}

extern Id pool_addrelproviders(Pool *pool, Id d);

static inline Id pool_whatprovides(Pool *pool, Id d)
Expand Down
22 changes: 22 additions & 0 deletions src/poolarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pool_setarch(Pool *pool, const char *arch)
Id id, lastarch;

pool->id2arch = sat_free(pool->id2arch);
pool->id2color = sat_free(pool->id2color);
if (!arch)
{
pool->lastarch = 0;
Expand Down Expand Up @@ -108,3 +109,24 @@ pool_setarch(Pool *pool, const char *arch)
pool->id2arch = id2arch;
pool->lastarch = lastarch;
}

unsigned char
pool_arch2color_slow(Pool *pool, Id arch)
{
const char *s;
unsigned char color;

if (arch > pool->lastarch)
return ARCHCOLOR_ALL;
if (!pool->id2color)
pool->id2color = sat_calloc(pool->lastarch + 1, 1);
s = id2str(pool, arch);
if (arch == ARCH_NOARCH || arch == ARCH_ALL)
color = ARCHCOLOR_ALL;
else if (!strcmp(s, "s390x") || strstr(s, "64"))
color = ARCHCOLOR_64;
else
color = ARCHCOLOR_32;
return color;
}

23 changes: 23 additions & 0 deletions src/poolarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,28 @@
#include "pool.h"

extern void pool_setarch(Pool *, const char *);
extern unsigned char pool_arch2color_slow(Pool *pool, Id arch);

#define ARCHCOLOR_32 1
#define ARCHCOLOR_64 2
#define ARCHCOLOR_ALL 255

static inline unsigned char pool_arch2color(Pool *pool, Id arch)
{
if (arch > pool->lastarch)
return ARCHCOLOR_ALL;
if (pool->id2color && pool->id2color[arch])
return pool->id2color[arch];
return pool_arch2color_slow(pool, arch);
}

static inline int pool_colormatch(Pool *pool, Solvable *s1, Solvable *s2)
{
if (s1->arch == s2->arch)
return 1;
if ((pool_arch2color(pool, s1->arch) & pool_arch2color(pool, s2->arch)) != 0)
return 1;
return 0;
}

#endif /* SATSOLVER_POOLARCH_H */
16 changes: 4 additions & 12 deletions src/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repo_freedata(Repo *repo)
{
int i;
for (i = 0; i < repo->nrepodata; i++)
repodata_free(repo->repodata + i);
repodata_freedata(repo->repodata + i);
sat_free(repo->repodata);
sat_free(repo->idarraydata);
sat_free(repo->rpmdbid);
Expand Down Expand Up @@ -797,6 +797,8 @@ repo_search(Repo *repo, Id p, Id keyname, const char *match, int flags, int (*ca
{
struct matchdata md;

if (repo->disabled && !(flags & SEARCH_DISABLED_REPOS))
return;
memset(&md, 0, sizeof(md));
md.pool = repo->pool;
md.flags = flags;
Expand Down Expand Up @@ -972,7 +974,7 @@ repo_add_repodata(Repo *repo, int localpool)
repo->nrepodata++;
repo->repodata = sat_realloc2(repo->repodata, repo->nrepodata, sizeof(*data));
data = repo->repodata + repo->nrepodata - 1;
repodata_init(data, repo, localpool);
repodata_initdata(data, repo, localpool);
return data;
}

Expand All @@ -986,16 +988,6 @@ repo_last_repodata(Repo *repo)
return repo_add_repodata(repo, 0);
}

void
repo_free_repodata(Repo *repo, Repodata *data)
{
int i = data - repo->repodata;
repodata_free(data);
if (i < repo->nrepodata - 1)
memmove(repo->repodata + i, repo->repodata + i + 1, (repo->nrepodata - 1 - i) * sizeof(Repodata));
repo->nrepodata--;
}

void
repo_set_id(Repo *repo, Id p, Id keyname, Id id)
{
Expand Down
69 changes: 45 additions & 24 deletions src/repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@


typedef struct _Repo {
const char *name;
const char *name; /* application private name pointer */
Id repoid; /* our id */
void *appdata; /* application private pointer */

Pool *pool; /* pool containing repo data */
Pool *pool; /* pool containing this repo */

int start; /* start of this repo solvables within pool->solvables */
int end; /* last solvable + 1 of this repo */
int nsolvables; /* number of solvables repo is contributing to pool */

int disabled; /* ignore the solvables? */
int priority; /* priority of this repo */
int subpriority; /* sub-priority of this repo, used just for sorting, not pruning */

Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */
int idarraysize;
Offset lastoff;
Offset lastoff; /* start of last array in idarraydata */

Id *rpmdbid; /* solvable side data */

Expand Down Expand Up @@ -114,15 +115,34 @@ static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int
pool_free_solvable_block(repo->pool, start, count, reuseids);
}

#define FOR_REPO_SOLVABLES(r, p, s) \
for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
if (s->repo == (r))


/* those two functions are here because they need the Repo definition */

static inline Repo *pool_id2repo(Pool *pool, Id repoid)
{
return pool->repos[repoid - 1];
}

#define FOR_REPO_SOLVABLES(r, p, s) \
for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
if (s->repo == (r))

static inline int pool_installable(const Pool *pool, Solvable *s)
{
if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
return 0;
if (s->repo && s->repo->disabled)
return 0;
if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))
return 0;
if (pool->considered)
{
Id id = s - pool->solvables;
if (!MAPTST(pool->considered, id))
return 0;
}
return 1;
}

/* search callback values */

Expand All @@ -143,28 +163,30 @@ typedef struct _KeyValue {
struct _KeyValue *parent;
} KeyValue;

/* search flags */
/* search matcher flags */
#define SEARCH_STRINGMASK 15
#define SEARCH_STRING 1
#define SEARCH_SUBSTRING 2
#define SEARCH_GLOB 3
#define SEARCH_REGEX 4
#define SEARCH_ERROR 5

#define SEARCH_NOCASE (1<<8)
#define SEARCH_NO_STORAGE_SOLVABLE (1<<9)
#define SEARCH_SUB (1<<10)
#define SEARCH_ARRAYSENTINEL (1<<11)
#define SEARCH_SKIP_KIND (1<<12)


/* By default we don't match in attributes representing filelists
because the construction of those strings is costly. Specify this
flag if you want this. In that case kv->str will contain the full
filename (if matched of course). */
#define SEARCH_FILES (1<<13)

/* Internal */
#define SEARCH_NOCASE (1<<7)

/* iterator control */
#define SEARCH_NO_STORAGE_SOLVABLE (1<<8)
#define SEARCH_SUB (1<<9)
#define SEARCH_ARRAYSENTINEL (1<<10)
#define SEARCH_DISABLED_REPOS (1<<11)

/* stringification flags */
#define SEARCH_SKIP_KIND (1<<16)
/* By default we stringify just to the basename of a file because
the construction of the full filename is costly. Specify this
flag if you want to match full filenames */
#define SEARCH_FILES (1<<17)
#define SEARCH_CHECKSUMS (1<<18)

/* dataiterator internal */
#define SEARCH_THISSOLVID (1<<31)


Expand All @@ -174,7 +196,6 @@ typedef struct _KeyValue {

Repodata *repo_add_repodata(Repo *repo, int localpool);
Repodata *repo_last_repodata(Repo *repo);
void repo_free_repodata(Repo *repo, Repodata *data);

void repo_search(Repo *repo, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata);

Expand Down
Loading

0 comments on commit 539bae9

Please sign in to comment.