Date:2010-11-22 03:24:44 (9 years 17 days ago)
Author:Werner Almesberger
Commit:be31904f5d4d922fe93ecc638f358c6e28edb713
Message: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
Files: qpkg/TODO (1 diff)
qpkg/prereq.c (3 diffs)
qpkg/test/conflict (1 diff)

Change Details

qpkg/TODO
33
44- check whether introducing a new package would cause a conflict
55
6  Update: conflicts among the packages considered for installation are now
7  checked.
8
69- compile the list of conflicts of installed packages
710
811- handle Provides:
qpkg/prereq.c
9393        return 0;
9494    if (!ref->version)
9595        return 1;
96    /* @@@ error in the database, not qpkg's fault */
9697    assert(pkg->version);
9798    cmp = comp_versions(pkg->version, ref->version);
9899//fprintf(stderr, "%.*s <%d> %.*s\n",
...... 
112113
113114static int conflicts(const struct pkg *pkg, const struct list *conf)
114115{
115    /* @@@ */
116    const struct ref *ref;
117
118    while (conf) {
119        for (ref = conf->refs; ref; ref = ref->next)
120            if (satisfies(pkg, ref))
121                return 1;
122        conf = conf->next;
123    }
116124    return 0;
117125}
118126
...... 
219227        .pkg = pkg,
220228        .next = NULL
221229    };
230    struct list conf = {
231        .refs = pkg->conflicts,
232        .next = NULL
233    };
234
222235    /* @@@ make list of pre-existing conflicts */
223236    pkg->flags |= QPKG_ADDING;
224    resolve(NULL, pkg->depends, &stack, NULL);
237    resolve(NULL, pkg->depends, &stack, &conf);
225238    pkg->flags &= ~QPKG_ADDING;
226239    free(installs);
227240    return best;
qpkg/test/conflict
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6qpkg_fail "direct conflict precludes resolution" prereq A <<EOF
7Package: B
8Version: 0
9Architecture: test
10Filename: B
11
12Package: A
13Version: 0
14Architecture: test
15Depends: B
16Conflicts: B
17Filename: A
18EOF
19expect <<EOF
20can't resolve A
21EOF
22
23###############################################################################
24
25qpkg_fail "indirect conflict precludes resolution" prereq A <<EOF
26Package: C
27Version: 0
28Architecture: test
29Filename: C
30
31Package: B
32Version: 0
33Architecture: test
34Depends: C
35Filename: B
36
37Package: A
38Version: 0
39Architecture: test
40Depends: B
41Conflicts: C
42Filename: A
43EOF
44expect <<EOF
45can't resolve A
46EOF
47
48###############################################################################
49
50qpkg_fail "aggregation of conflicts" prereq A <<EOF
51Package: C
52Version: 0
53Architecture: test
54Filename: C
55
56Package: B
57Version: 0
58Architecture: test
59Depends: C
60Conflicts: C
61Filename: B
62
63Package: A
64Version: 0
65Architecture: test
66Depends: B
67Filename: A
68EOF
69expect <<EOF
70can't resolve A
71EOF
72
73###############################################################################
74
75qpkg_fail "conflicts honor version (match)" prereq A <<EOF
76Package: B
77Version: 1
78Architecture: test
79Filename: B
80
81Package: A
82Version: 0
83Architecture: test
84Depends: B
85Conflicts: B (= 1)
86Filename: A
87EOF
88expect <<EOF
89can't resolve A
90EOF
91
92###############################################################################
93
94qpkg "conflicts honor version (mismatch)" prereq A <<EOF
95Package: B
96Version: 1
97Architecture: test
98Filename: B
99
100Package: A
101Version: 0
102Architecture: test
103Depends: B
104Conflicts: B (= 0)
105Filename: A
106EOF
107expect <<EOF
108B
109EOF
110
111###############################################################################
112
113qpkg "conflict trumps preference (1)" prereq foo <<EOF
114Package: bar
115Version: 0
116Architecture: test
117Filename: bar_0
118
119Package: bar
120Version: 1
121Architecture: test
122Filename: bar_1
123
124Package: foo
125Version: 0
126Architecture: test
127Depends: bar
128Conflicts: bar (>= 1)
129Filename: foo
130EOF
131expect <<EOF
132bar_0
133EOF
134
135###############################################################################
136
137qpkg "conflict trumps preference (2)" prereq foo <<EOF
138Package: bar
139Version: 1
140Architecture: test
141Filename: bar_1
142
143Package: bar
144Version: 0
145Architecture: test
146Filename: bar_0
147
148Package: foo
149Version: 0
150Architecture: test
151Depends: bar
152Conflicts: bar (>= 1)
153Filename: foo
154EOF
155expect <<EOF
156bar_0
157EOF

Archive Download the corresponding diff file

Branches:
master



interactive