diff options
author | Michael Schroeder <mls@suse.de> | 2012-12-05 13:31:53 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-12-05 13:31:53 +0100 |
commit | 56f5e60ce72a2ca18dd2533061a0f207bd381ed0 (patch) | |
tree | fd9cadb18a2abad40f34c787da9c06d81e544fd8 | |
parent | 510dd15e9bc4fbe6a733c3c305929c81f9999e87 (diff) | |
download | libsolv-56f5e60ce72a2ca18dd2533061a0f207bd381ed0.tar.gz libsolv-56f5e60ce72a2ca18dd2533061a0f207bd381ed0.tar.bz2 libsolv-56f5e60ce72a2ca18dd2533061a0f207bd381ed0.zip |
Add Dep.Rel() method and a couple of Selection constructors
-rw-r--r-- | bindings/solv.i | 55 | ||||
-rwxr-xr-x | examples/p5solv | 3 | ||||
-rwxr-xr-x | examples/pysolv | 5 | ||||
-rwxr-xr-x | examples/rbsolv | 5 |
4 files changed, 60 insertions, 8 deletions
diff --git a/bindings/solv.i b/bindings/solv.i index bc3f1ab..654ea86 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1317,6 +1317,12 @@ typedef struct { Selection *Selection() { return new_Selection($self); } + %newobject Selection_all; + Selection *Selection_all(int setflags=0) { + Selection *sel = new_Selection($self); + queue_push2(&sel->q, SOLVER_SOLVABLE_ALL | setflags, 0); + return sel; + } %newobject select; Selection *select(const char *name, int flags) { Selection *sel = new_Selection($self); @@ -1512,6 +1518,14 @@ typedef struct { return new_XRepodata($self, 1); } + %newobject Selection; + Selection *Selection(int setflags=0) { + Selection *sel = new_Selection($self->pool); + setflags |= SOLVER_SETREPO; + queue_push2(&sel->q, SOLVER_SOLVABLE_REPO | setflags, $self->repoid); + return sel; + } + bool __eq__(Repo *repo) { return $self == repo; } @@ -1920,6 +1934,40 @@ typedef struct { s->id = id; return s; } + %newobject Rel; + Dep *Rel(int flags, DepId evrid, bool create=1) { + Id id = pool_rel2id($self->pool, $self->id, evrid, flags, create); + if (!id) + return 0; + return new_Dep($self->pool, id); + } + %newobject Selection_name; + Selection *Selection_name(int setflags=0) { + Selection *sel = new_Selection($self->pool); + if (ISRELDEP($self->id)) { + Reldep *rd = GETRELDEP($self->pool, $self->id); + if (rd->flags == REL_EQ) { + setflags |= $self->pool->disttype == DISTTYPE_DEB || strchr(pool_id2str($self->pool, rd->evr), '-') != 0 ? SOLVER_SETEVR : SOLVER_SETEV; + if (ISRELDEP(rd->name)) + rd = GETRELDEP($self->pool, rd->name); + } + if (rd->flags == REL_ARCH) + setflags |= SOLVER_SETARCH; + } + queue_push2(&sel->q, SOLVER_SOLVABLE_NAME | setflags, $self->id); + return sel; + } + %newobject Selection_provides; + Selection *Selection_provides(int setflags=0) { + Selection *sel = new_Selection($self->pool); + if (ISRELDEP($self->id)) { + Reldep *rd = GETRELDEP($self->pool, $self->id); + if (rd->flags == REL_ARCH) + setflags |= SOLVER_SETARCH; + } + queue_push2(&sel->q, SOLVER_SOLVABLE_PROVIDES | setflags, $self->id); + return sel; + } const char *str() { return pool_dep2str($self->pool, $self->id); } @@ -2165,6 +2213,13 @@ typedef struct { solvable_add_deparray(s, keyname, id, marker); } + %newobject Selection; + Selection *Selection(int setflags=0) { + Selection *sel = new_Selection($self->pool); + queue_push2(&sel->q, SOLVER_SOLVABLE | setflags, $self->id); + return sel; + } + bool __eq__(XSolvable *s) { return $self->pool == s->pool && $self->id == s->id; } diff --git a/examples/p5solv b/examples/p5solv index fdb47d7..e02d6da 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -585,8 +585,7 @@ for my $arg (@ARGV) { } if (!@jobs && ($cmd eq 'up' || $cmd eq 'dup' || $cmd eq 'verify')) { - my $sel = $pool->Selection(); - $sel->add_raw($solv::Job::SOLVER_SOLVABLE_ALL, 0); + my $sel = $pool->Selection_all(); push @jobs, $sel->jobs($cmdactionmap{$cmd}); } diff --git a/examples/pysolv b/examples/pysolv index e898c09..b6b58ec 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -644,7 +644,7 @@ if options.repos: if hasattr(repo, 'handle'): if not repofilter: repofilter = pool.Selection() - repofilter.add_raw(Job.SOLVER_SOLVABLE_REPO|Job.SOLVER_SETREPO|Job.SOLVER_SETVENDOR, repo.handle.id) + repofilter.add(repo.handle.Selection(Job.SOLVER_SETVENDOR)) if cmd == 'search': pool.createwhatprovides() @@ -713,8 +713,7 @@ for arg in args: jobs += sel.jobs(cmdactionmap[cmd]) if not jobs and (cmd == 'up' or cmd == 'dup' or cmd == 'verify' or repofilter): - sel = pool.Selection() - sel.add_raw(Job.SOLVER_SOLVABLE_ALL, 0) + sel = pool.Selection_all() if repofilter: sel.filter(repofilter) jobs += sel.jobs(cmdactionmap[cmd]) diff --git a/examples/rbsolv b/examples/rbsolv index 367b6c3..d9b05c6 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -580,7 +580,7 @@ pool.createwhatprovides() jobs = [] for arg in args - flags = Solv::Selection::SELECTION_NAME | Solv::Selection::SELECTION_PROVIDES|Solv::Selection::SELECTION_GLOB + flags = Solv::Selection::SELECTION_NAME | Solv::Selection::SELECTION_PROVIDES | Solv::Selection::SELECTION_GLOB flags |= Solv::Selection::SELECTION_CANON | Solv::Selection::SELECTION_DOTARCH | Solv::Selection::SELECTION_REL if arg =~ /^\// flags |= Solv::Selection::SELECTION_FILELIST @@ -597,8 +597,7 @@ for arg in args end if jobs.empty? && (cmd == 'up' || cmd == 'dup' || cmd == 'verify') - sel = pool.Selection() - sel.add_raw(Solv::Job::SOLVER_SOLVABLE_ALL, 0) + sel = pool.Selection_all() jobs += sel.jobs(cmdactionmap[cmd]) end |