|
danw@157
|
1 |
We start with two razor_sets, system and upstream, and a list of
|
|
danw@157
|
2 |
requested installations and removals.
|
|
danw@157
|
3 |
|
|
danw@157
|
4 |
FIXME: what about multiple upstream repos? Having to deal with
|
|
danw@157
|
5 |
arbitrary numbers of razor_sets is possible, but will probably be
|
|
danw@157
|
6 |
messy... It might be easier to either store all upstream repo data
|
|
danw@157
|
7 |
in a single .repo file, or else merge all upstream .repo files
|
|
danw@157
|
8 |
together into a single razor_set at startup. (Or some combination
|
|
danw@157
|
9 |
of those.)
|
|
danw@157
|
10 |
|
|
danw@157
|
11 |
We create a bit array of the packages in each set, indicating which
|
|
danw@157
|
12 |
ones are installed; the system bitarray starts out all 1s, and the
|
|
danw@157
|
13 |
upstream bitarray all 0s. Each bit is only allowed to change state
|
|
danw@157
|
14 |
once during the transaction; an installed package can be removed, or
|
|
danw@157
|
15 |
an uninstalled package installed, but trying to reinstall a removed
|
|
danw@157
|
16 |
package, or uninstall a newly-installed package is an error. This
|
|
danw@157
|
17 |
means the packages break down into four categories:
|
|
danw@157
|
18 |
|
|
danw@157
|
19 |
- installed (1 bit in the system bit array)
|
|
danw@157
|
20 |
- to-be-removed (0 bit in the system bit array)
|
|
danw@157
|
21 |
- to-be-installed (1 bit in the upstream bit array)
|
|
danw@157
|
22 |
- installable (0 bit in the upstream bit array)
|
|
danw@157
|
23 |
|
|
danw@157
|
24 |
|
|
danw@158
|
25 |
Depsolver:
|
|
danw@157
|
26 |
|
|
danw@158
|
27 |
- Create new razor_transaction_packages ("rtp"s) for each
|
|
danw@161
|
28 |
requested install or remove. These will be "unresolved", because
|
|
danw@161
|
29 |
we haven't yet found the razor_packages that correspond to them.
|
|
danw@157
|
30 |
|
|
danw@158
|
31 |
- while there are new rtps:
|
|
danw@157
|
32 |
|
|
danw@161
|
33 |
- sort the new rtps
|
|
danw@157
|
34 |
|
|
danw@161
|
35 |
- Walk the system property list, upstream property list, and
|
|
danw@161
|
36 |
new rtp list in parallel, and:
|
|
danw@157
|
37 |
|
|
danw@161
|
38 |
- For each uninstalled PROVIDES:
|
|
danw@161
|
39 |
|
|
danw@161
|
40 |
- If the property is a valid package name (that is,
|
|
danw@161
|
41 |
either it's a package providing its own name, or it
|
|
danw@161
|
42 |
has a matching OBSOLETES), and it matches the name
|
|
danw@161
|
43 |
of a new rtp of type INSTALL or FORCED_UPDATE with
|
|
danw@161
|
44 |
an unresolved new_package, then set the rtp's
|
|
danw@161
|
45 |
new_package to point to the package providing this
|
|
danw@161
|
46 |
property and set the appropriate bit in the upstream
|
|
danw@161
|
47 |
bit array.
|
|
danw@157
|
48 |
|
|
danw@158
|
49 |
- For each to-be-installed non-file REQUIRES:
|
|
danw@157
|
50 |
|
|
danw@158
|
51 |
- See if there's an installed or to-be-installed
|
|
danw@158
|
52 |
package that PROVIDES that property.
|
|
danw@157
|
53 |
|
|
danw@158
|
54 |
- If not, see if there's an installable package that
|
|
danw@158
|
55 |
PROVIDES that property, and create a new INSTALL rtp
|
|
danw@158
|
56 |
for it if so.
|
|
danw@157
|
57 |
|
|
danw@158
|
58 |
- If not, see if there's a to-be-removed package that
|
|
danw@158
|
59 |
PROVIDES that property. (If we find such a package,
|
|
danw@158
|
60 |
we have a CONTRADICTION error.)
|
|
danw@157
|
61 |
|
|
danw@158
|
62 |
- If none of the above, then we have an UNSATISFIABLE
|
|
danw@158
|
63 |
error
|
|
danw@157
|
64 |
|
|
danw@158
|
65 |
- For each to-be-installed file REQUIRES:
|
|
danw@157
|
66 |
|
|
danw@158
|
67 |
- (We create fake file PROVIDES to match file REQUIRES
|
|
danw@158
|
68 |
when importing/merging razor sets, so if there is
|
|
danw@158
|
69 |
already another installed package that REQUIRES this
|
|
danw@158
|
70 |
file, there will be a PROVIDES listed for it as well.)
|
|
danw@157
|
71 |
|
|
danw@158
|
72 |
- See if there's an installed package that PROVIDES
|
|
danw@158
|
73 |
that file.
|
|
danw@157
|
74 |
|
|
danw@158
|
75 |
- If not, do a binary search of the system file tree
|
|
danw@158
|
76 |
looking to see if some installed package provides
|
|
danw@158
|
77 |
that file but does not have a PROVIDES for it.
|
|
danw@157
|
78 |
|
|
danw@158
|
79 |
- If not, see if there's an installable package that
|
|
danw@158
|
80 |
PROVIDES that property, and create a new INSTALL rtp
|
|
danw@158
|
81 |
for it if so.
|
|
danw@157
|
82 |
|
|
danw@158
|
83 |
- (If we actually work with multiple upstream
|
|
danw@158
|
84 |
razor_sets, then we will need to search the upstream
|
|
danw@158
|
85 |
file trees at this point, because it's possible that
|
|
danw@158
|
86 |
a package in one upstream repo would require a file
|
|
danw@158
|
87 |
in another upstream repo. But if we merge the
|
|
danw@158
|
88 |
multiple upstream repos into a single razor_set at
|
|
danw@158
|
89 |
some point, then we would not need to do that,
|
|
danw@158
|
90 |
because it would be guaranteed that we would have
|
|
danw@158
|
91 |
already created a fake PROVIDES if any package
|
|
danw@158
|
92 |
provides the file.)
|
|
danw@157
|
93 |
|
|
danw@158
|
94 |
- If no installed or installable package provides the
|
|
danw@158
|
95 |
file, see if there's a to-be-removed package that
|
|
danw@158
|
96 |
provides the file. (If we find such a package, we
|
|
danw@158
|
97 |
have a CONTRADICTION error.)
|
|
danw@157
|
98 |
|
|
danw@158
|
99 |
- If none of the above, then we have an UNSATISFIABLE
|
|
danw@158
|
100 |
error
|
|
danw@157
|
101 |
|
|
danw@158
|
102 |
- For each to-be-installed PROVIDES:
|
|
danw@157
|
103 |
|
|
danw@158
|
104 |
- Check if the new PROVIDES conflicts with an
|
|
danw@158
|
105 |
installed CONFLICTS. If so, create a new
|
|
danw@158
|
106 |
FORCED_UPDATE rtp for the installed package, so we
|
|
danw@158
|
107 |
can try to upgrade it to a non-conflicting version.
|
|
danw@158
|
108 |
(If we can't, we'll have an OLD_CONFLICT error.)
|
|
danw@157
|
109 |
|
|
danw@158
|
110 |
- Check if the new PROVIDES conflicts with an
|
|
danw@158
|
111 |
installed OBSOLETES *and* the PROVIDES property
|
|
danw@158
|
112 |
corresponds to the name of its package. (That is,
|
|
danw@158
|
113 |
OBSOLETES are only matched against package names,
|
|
danw@158
|
114 |
not arbitrary provided properties.) If so, we have
|
|
danw@158
|
115 |
an ALREADY_OBSOLETE error.
|
|
danw@157
|
116 |
|
|
danw@158
|
117 |
- Check if the new PROVIDES conflicts with a
|
|
danw@158
|
118 |
to-be-installed CONFLICTS. If so, we have a
|
|
danw@158
|
119 |
CONTRADICTION error.
|
|
danw@157
|
120 |
|
|
danw@158
|
121 |
- For each to-be-installed CONFLICTS:
|
|
danw@157
|
122 |
|
|
danw@158
|
123 |
- Basically the reverse of the previous case: check if
|
|
danw@158
|
124 |
the new CONFLICTS conflicts with an installed
|
|
danw@158
|
125 |
PROVIDES. If so, create a new FORCED_UPDATE rtp for
|
|
danw@158
|
126 |
the installed package, so we can try to upgrade it
|
|
danw@158
|
127 |
to a non-conflicting version. (If we can't, we'll
|
|
danw@158
|
128 |
have an NEW_CONFLICT error.)
|
|
danw@157
|
129 |
|
|
danw@158
|
130 |
- Check if the new CONFLICTS conflicts with a
|
|
danw@158
|
131 |
to-be-installed PROVIDES. If so, we have a
|
|
danw@158
|
132 |
CONTRADICTION error.
|
|
danw@157
|
133 |
|
|
danw@158
|
134 |
- For each to-be-installed OBSOLETES:
|
|
danw@157
|
135 |
|
|
danw@158
|
136 |
- Check if there's an installed package that PROVIDES
|
|
danw@158
|
137 |
that property. If so, create an OBSOLETED rtp for
|
|
danw@158
|
138 |
the installed package.
|
|
danw@157
|
139 |
|
|
danw@158
|
140 |
- If not, check if there's a to-be-installed package
|
|
danw@158
|
141 |
that PROVIDES that property. If so, we have a
|
|
danw@158
|
142 |
CONTRADICTION error.
|
|
danw@157
|
143 |
|
|
danw@161
|
144 |
|
|
danw@161
|
145 |
- For each installed PROVIDES:
|
|
danw@161
|
146 |
|
|
danw@161
|
147 |
- If the property is a valid package name (that is,
|
|
danw@161
|
148 |
it's a package providing its own name), and it
|
|
danw@161
|
149 |
matches the name of a new rtp with an unresolved
|
|
danw@161
|
150 |
old_package, then set the rtp's old_package to point
|
|
danw@161
|
151 |
to the package providing this property and clear the
|
|
danw@161
|
152 |
appropriate bit in the system bit array.
|
|
danw@161
|
153 |
|
|
danw@158
|
154 |
- For each to-be-removed PROVIDES:
|
|
danw@157
|
155 |
|
|
danw@158
|
156 |
- If there's also an identical to-be-installed
|
|
danw@158
|
157 |
PROVIDES, we're ok and can skip this
|
|
danw@157
|
158 |
|
|
danw@158
|
159 |
- Otherwise, for each installed REQUIRES of this
|
|
danw@158
|
160 |
property:
|
|
danw@157
|
161 |
|
|
danw@158
|
162 |
- Look for some other installed or to-be-installed
|
|
danw@158
|
163 |
property that satisfies the REQUIRES.
|
|
danw@157
|
164 |
|
|
danw@158
|
165 |
- If there isn't one, then for each installed
|
|
danw@158
|
166 |
package in this REQUIRES's package list:
|
|
danw@157
|
167 |
|
|
danw@158
|
168 |
- If the PROVIDES was lost because the old
|
|
danw@158
|
169 |
package was REMOVEd (not FORCED_UPDATE or
|
|
danw@158
|
170 |
OBSOLETED), then create a new REMOVE rtp for
|
|
danw@158
|
171 |
this package.
|
|
danw@157
|
172 |
|
|
danw@158
|
173 |
- Otherwise, create a new FORCED_UPDATE rtp
|
|
danw@158
|
174 |
for this package.
|
|
danw@157
|
175 |
|
|
danw@158
|
176 |
- (We don't need to look at to-be-installed REQUIRES
|
|
danw@158
|
177 |
of this property, because if there are any, they
|
|
danw@158
|
178 |
will cause a CONTRADICTION error when we try to
|
|
danw@158
|
179 |
re-satisfy them the next time through.)
|