mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-22 07:00:39 +02:00
qpkg: adding handling of conflicts (in progress)
- prereq.c (conflicts): detect conflicts - prereq.c (prereq): pass list of conflicts of initial package - test/conflict: regression test for basic conflict handling - TODO: updated for partial implementation of conflicts
This commit is contained in:
parent
b181db5b9e
commit
be31904f5d
@ -3,6 +3,9 @@ Still left to do
|
||||
|
||||
- check whether introducing a new package would cause a conflict
|
||||
|
||||
Update: conflicts among the packages considered for installation are now
|
||||
checked.
|
||||
|
||||
- compile the list of conflicts of installed packages
|
||||
|
||||
- handle Provides:
|
||||
|
@ -93,6 +93,7 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref)
|
||||
return 0;
|
||||
if (!ref->version)
|
||||
return 1;
|
||||
/* @@@ error in the database, not qpkg's fault */
|
||||
assert(pkg->version);
|
||||
cmp = comp_versions(pkg->version, ref->version);
|
||||
//fprintf(stderr, "%.*s <%d> %.*s\n",
|
||||
@ -112,7 +113,14 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref)
|
||||
|
||||
static int conflicts(const struct pkg *pkg, const struct list *conf)
|
||||
{
|
||||
/* @@@ */
|
||||
const struct ref *ref;
|
||||
|
||||
while (conf) {
|
||||
for (ref = conf->refs; ref; ref = ref->next)
|
||||
if (satisfies(pkg, ref))
|
||||
return 1;
|
||||
conf = conf->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -219,9 +227,14 @@ struct pkg **prereq(struct pkg *pkg)
|
||||
.pkg = pkg,
|
||||
.next = NULL
|
||||
};
|
||||
struct list conf = {
|
||||
.refs = pkg->conflicts,
|
||||
.next = NULL
|
||||
};
|
||||
|
||||
/* @@@ make list of pre-existing conflicts */
|
||||
pkg->flags |= QPKG_ADDING;
|
||||
resolve(NULL, pkg->depends, &stack, NULL);
|
||||
resolve(NULL, pkg->depends, &stack, &conf);
|
||||
pkg->flags &= ~QPKG_ADDING;
|
||||
free(installs);
|
||||
return best;
|
||||
|
157
qpkg/test/conflict
Executable file
157
qpkg/test/conflict
Executable file
@ -0,0 +1,157 @@
|
||||
#!/bin/sh
|
||||
. ./Common
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg_fail "direct conflict precludes resolution" prereq A <<EOF
|
||||
Package: B
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: B
|
||||
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B
|
||||
Conflicts: B
|
||||
Filename: A
|
||||
EOF
|
||||
expect <<EOF
|
||||
can't resolve A
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg_fail "indirect conflict precludes resolution" prereq A <<EOF
|
||||
Package: C
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: C
|
||||
|
||||
Package: B
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: C
|
||||
Filename: B
|
||||
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B
|
||||
Conflicts: C
|
||||
Filename: A
|
||||
EOF
|
||||
expect <<EOF
|
||||
can't resolve A
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg_fail "aggregation of conflicts" prereq A <<EOF
|
||||
Package: C
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: C
|
||||
|
||||
Package: B
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: C
|
||||
Conflicts: C
|
||||
Filename: B
|
||||
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B
|
||||
Filename: A
|
||||
EOF
|
||||
expect <<EOF
|
||||
can't resolve A
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg_fail "conflicts honor version (match)" prereq A <<EOF
|
||||
Package: B
|
||||
Version: 1
|
||||
Architecture: test
|
||||
Filename: B
|
||||
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B
|
||||
Conflicts: B (= 1)
|
||||
Filename: A
|
||||
EOF
|
||||
expect <<EOF
|
||||
can't resolve A
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg "conflicts honor version (mismatch)" prereq A <<EOF
|
||||
Package: B
|
||||
Version: 1
|
||||
Architecture: test
|
||||
Filename: B
|
||||
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B
|
||||
Conflicts: B (= 0)
|
||||
Filename: A
|
||||
EOF
|
||||
expect <<EOF
|
||||
B
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg "conflict trumps preference (1)" prereq foo <<EOF
|
||||
Package: bar
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: bar_0
|
||||
|
||||
Package: bar
|
||||
Version: 1
|
||||
Architecture: test
|
||||
Filename: bar_1
|
||||
|
||||
Package: foo
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: bar
|
||||
Conflicts: bar (>= 1)
|
||||
Filename: foo
|
||||
EOF
|
||||
expect <<EOF
|
||||
bar_0
|
||||
EOF
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg "conflict trumps preference (2)" prereq foo <<EOF
|
||||
Package: bar
|
||||
Version: 1
|
||||
Architecture: test
|
||||
Filename: bar_1
|
||||
|
||||
Package: bar
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: bar_0
|
||||
|
||||
Package: foo
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: bar
|
||||
Conflicts: bar (>= 1)
|
||||
Filename: foo
|
||||
EOF
|
||||
expect <<EOF
|
||||
bar_0
|
||||
EOF
|
Loading…
Reference in New Issue
Block a user