|
krh@15
|
1 |
#define _GNU_SOURCE
|
|
krh@15
|
2 |
|
|
krh@0
|
3 |
#include <stdlib.h>
|
|
krh@19
|
4 |
#include <stddef.h>
|
|
danw@108
|
5 |
#include <stdint.h>
|
|
krh@0
|
6 |
#include <stdio.h>
|
|
krh@0
|
7 |
#include <string.h>
|
|
krh@0
|
8 |
#include <sys/types.h>
|
|
krh@0
|
9 |
#include <sys/stat.h>
|
|
krh@0
|
10 |
#include <sys/mman.h>
|
|
krh@0
|
11 |
#include <unistd.h>
|
|
krh@0
|
12 |
#include <fcntl.h>
|
|
krh@15
|
13 |
#include <errno.h>
|
|
krh@35
|
14 |
#include <ctype.h>
|
|
krh@54
|
15 |
#include <fnmatch.h>
|
|
krh@0
|
16 |
|
|
krh@27
|
17 |
#include "razor.h"
|
|
krh@91
|
18 |
#include "razor-internal.h"
|
|
danw@115
|
19 |
#include "types.h"
|
|
krh@30
|
20 |
|
|
krh@30
|
21 |
struct razor_set_section {
|
|
danw@108
|
22 |
uint32_t type;
|
|
danw@108
|
23 |
uint32_t offset;
|
|
danw@108
|
24 |
uint32_t size;
|
|
krh@30
|
25 |
};
|
|
krh@30
|
26 |
|
|
krh@30
|
27 |
struct razor_set_header {
|
|
danw@108
|
28 |
uint32_t magic;
|
|
danw@108
|
29 |
uint32_t version;
|
|
krh@30
|
30 |
struct razor_set_section sections[0];
|
|
krh@30
|
31 |
};
|
|
krh@30
|
32 |
|
|
krh@30
|
33 |
#define RAZOR_MAGIC 0x7a7a7a7a
|
|
krh@30
|
34 |
#define RAZOR_VERSION 1
|
|
krh@30
|
35 |
|
|
krh@61
|
36 |
#define RAZOR_ENTRY_LAST 0x80000000ul
|
|
krh@61
|
37 |
#define RAZOR_ENTRY_MASK 0x00fffffful
|
|
krh@61
|
38 |
|
|
krh@66
|
39 |
#define RAZOR_STRING_POOL 0
|
|
krh@66
|
40 |
#define RAZOR_PACKAGES 1
|
|
krh@66
|
41 |
#define RAZOR_PROPERTIES 2
|
|
krh@66
|
42 |
#define RAZOR_FILES 3
|
|
krh@66
|
43 |
#define RAZOR_PACKAGE_POOL 4
|
|
krh@66
|
44 |
#define RAZOR_PROPERTY_POOL 5
|
|
krh@66
|
45 |
#define RAZOR_FILE_POOL 6
|
|
krh@30
|
46 |
|
|
krh@30
|
47 |
struct razor_package {
|
|
danw@108
|
48 |
uint32_t name;
|
|
danw@108
|
49 |
uint32_t version;
|
|
danw@117
|
50 |
struct list_head properties;
|
|
danw@117
|
51 |
struct list_head files;
|
|
krh@30
|
52 |
};
|
|
krh@30
|
53 |
|
|
krh@30
|
54 |
struct razor_property {
|
|
danw@119
|
55 |
uint name : 24;
|
|
danw@119
|
56 |
uint flags : 6;
|
|
danw@119
|
57 |
uint type : 2;
|
|
danw@109
|
58 |
uint32_t relation;
|
|
danw@108
|
59 |
uint32_t version;
|
|
danw@117
|
60 |
struct list_head packages;
|
|
krh@30
|
61 |
};
|
|
krh@30
|
62 |
|
|
krh@48
|
63 |
struct razor_entry {
|
|
danw@108
|
64 |
uint32_t name;
|
|
danw@108
|
65 |
uint32_t start;
|
|
danw@117
|
66 |
struct list_head packages;
|
|
krh@48
|
67 |
};
|
|
krh@48
|
68 |
|
|
krh@30
|
69 |
struct razor_set {
|
|
krh@30
|
70 |
struct array string_pool;
|
|
krh@30
|
71 |
struct array packages;
|
|
krh@66
|
72 |
struct array properties;
|
|
krh@56
|
73 |
struct array files;
|
|
krh@56
|
74 |
struct array package_pool;
|
|
krh@66
|
75 |
struct array property_pool;
|
|
krh@56
|
76 |
struct array file_pool;
|
|
krh@30
|
77 |
struct razor_set_header *header;
|
|
krh@30
|
78 |
};
|
|
krh@30
|
79 |
|
|
krh@52
|
80 |
struct import_entry {
|
|
danw@108
|
81 |
uint32_t package;
|
|
krh@52
|
82 |
char *name;
|
|
krh@52
|
83 |
};
|
|
krh@52
|
84 |
|
|
krh@52
|
85 |
struct import_directory {
|
|
danw@108
|
86 |
uint32_t name, count;
|
|
krh@52
|
87 |
struct array files;
|
|
krh@52
|
88 |
struct array packages;
|
|
krh@52
|
89 |
struct import_directory *last;
|
|
krh@52
|
90 |
};
|
|
krh@52
|
91 |
|
|
krh@30
|
92 |
struct razor_importer {
|
|
krh@30
|
93 |
struct razor_set *set;
|
|
krh@78
|
94 |
struct hashtable table;
|
|
krh@30
|
95 |
struct razor_package *package;
|
|
krh@66
|
96 |
struct array properties;
|
|
krh@48
|
97 |
struct array files;
|
|
krh@30
|
98 |
};
|
|
krh@30
|
99 |
|
|
krh@0
|
100 |
static void *
|
|
krh@0
|
101 |
zalloc(size_t size)
|
|
krh@0
|
102 |
{
|
|
krh@0
|
103 |
void *p;
|
|
krh@0
|
104 |
|
|
krh@0
|
105 |
p = malloc(size);
|
|
krh@0
|
106 |
memset(p, 0, size);
|
|
krh@0
|
107 |
|
|
krh@0
|
108 |
return p;
|
|
krh@0
|
109 |
}
|
|
krh@0
|
110 |
|
|
krh@19
|
111 |
struct razor_set_section razor_sections[] = {
|
|
krh@56
|
112 |
{ RAZOR_STRING_POOL, offsetof(struct razor_set, string_pool) },
|
|
krh@19
|
113 |
{ RAZOR_PACKAGES, offsetof(struct razor_set, packages) },
|
|
krh@66
|
114 |
{ RAZOR_PROPERTIES, offsetof(struct razor_set, properties) },
|
|
krh@56
|
115 |
{ RAZOR_FILES, offsetof(struct razor_set, files) },
|
|
krh@39
|
116 |
{ RAZOR_PACKAGE_POOL, offsetof(struct razor_set, package_pool) },
|
|
krh@66
|
117 |
{ RAZOR_PROPERTY_POOL, offsetof(struct razor_set, property_pool) },
|
|
krh@56
|
118 |
{ RAZOR_FILE_POOL, offsetof(struct razor_set, file_pool) },
|
|
krh@19
|
119 |
};
|
|
krh@19
|
120 |
|
|
krh@4
|
121 |
struct razor_set *
|
|
krh@4
|
122 |
razor_set_create(void)
|
|
krh@0
|
123 |
{
|
|
krh@18
|
124 |
return zalloc(sizeof(struct razor_set));
|
|
krh@0
|
125 |
}
|
|
krh@0
|
126 |
|
|
krh@4
|
127 |
struct razor_set *
|
|
krh@4
|
128 |
razor_set_open(const char *filename)
|
|
krh@0
|
129 |
{
|
|
krh@4
|
130 |
struct razor_set *set;
|
|
krh@19
|
131 |
struct razor_set_section *s;
|
|
krh@0
|
132 |
struct stat stat;
|
|
krh@19
|
133 |
struct array *array;
|
|
krh@19
|
134 |
int fd;
|
|
krh@0
|
135 |
|
|
krh@4
|
136 |
set = zalloc(sizeof *set);
|
|
krh@0
|
137 |
fd = open(filename, O_RDONLY);
|
|
krh@0
|
138 |
if (fstat(fd, &stat) < 0)
|
|
krh@0
|
139 |
return NULL;
|
|
krh@4
|
140 |
set->header = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
krh@4
|
141 |
if (set->header == MAP_FAILED) {
|
|
krh@4
|
142 |
free(set);
|
|
krh@0
|
143 |
return NULL;
|
|
krh@0
|
144 |
}
|
|
krh@0
|
145 |
|
|
krh@19
|
146 |
for (s = set->header->sections; ~s->type; s++) {
|
|
krh@19
|
147 |
if (s->type >= ARRAY_SIZE(razor_sections))
|
|
krh@19
|
148 |
continue;
|
|
krh@19
|
149 |
if (s->type != razor_sections[s->type].type)
|
|
krh@19
|
150 |
continue;
|
|
krh@19
|
151 |
array = (void *) set + razor_sections[s->type].offset;
|
|
krh@19
|
152 |
array->data = (void *) set->header + s->offset;
|
|
krh@19
|
153 |
array->size = s->size;
|
|
krh@19
|
154 |
array->alloc = s->size;
|
|
krh@0
|
155 |
}
|
|
krh@0
|
156 |
close(fd);
|
|
krh@0
|
157 |
|
|
krh@4
|
158 |
return set;
|
|
krh@0
|
159 |
}
|
|
krh@0
|
160 |
|
|
krh@0
|
161 |
void
|
|
krh@4
|
162 |
razor_set_destroy(struct razor_set *set)
|
|
krh@0
|
163 |
{
|
|
krh@0
|
164 |
unsigned int size;
|
|
krh@19
|
165 |
struct array *a;
|
|
krh@0
|
166 |
int i;
|
|
krh@0
|
167 |
|
|
krh@4
|
168 |
if (set->header) {
|
|
krh@4
|
169 |
for (i = 0; set->header->sections[i].type; i++)
|
|
krh@0
|
170 |
;
|
|
krh@4
|
171 |
size = set->header->sections[i].type;
|
|
krh@4
|
172 |
munmap(set->header, size);
|
|
krh@0
|
173 |
} else {
|
|
krh@19
|
174 |
for (i = 0; i < ARRAY_SIZE(razor_sections); i++) {
|
|
krh@19
|
175 |
a = (void *) set + razor_sections[i].offset;
|
|
krh@19
|
176 |
free(a->data);
|
|
krh@19
|
177 |
}
|
|
krh@0
|
178 |
}
|
|
krh@0
|
179 |
|
|
krh@4
|
180 |
free(set);
|
|
krh@0
|
181 |
}
|
|
krh@0
|
182 |
|
|
krh@43
|
183 |
int
|
|
krh@4
|
184 |
razor_set_write(struct razor_set *set, const char *filename)
|
|
krh@0
|
185 |
{
|
|
krh@0
|
186 |
char data[4096];
|
|
krh@4
|
187 |
struct razor_set_header *header = (struct razor_set_header *) data;
|
|
krh@19
|
188 |
struct array *a;
|
|
danw@108
|
189 |
uint32_t offset;
|
|
krh@17
|
190 |
int i, fd;
|
|
krh@0
|
191 |
|
|
krh@0
|
192 |
memset(data, 0, sizeof data);
|
|
krh@4
|
193 |
header->magic = RAZOR_MAGIC;
|
|
krh@4
|
194 |
header->version = RAZOR_VERSION;
|
|
krh@17
|
195 |
offset = sizeof data;
|
|
krh@0
|
196 |
|
|
krh@19
|
197 |
for (i = 0; i < ARRAY_SIZE(razor_sections); i++) {
|
|
krh@19
|
198 |
if (razor_sections[i].type != i)
|
|
krh@19
|
199 |
continue;
|
|
krh@19
|
200 |
a = (void *) set + razor_sections[i].offset;
|
|
krh@19
|
201 |
header->sections[i].type = i;
|
|
krh@17
|
202 |
header->sections[i].offset = offset;
|
|
krh@19
|
203 |
header->sections[i].size = a->size;
|
|
krh@91
|
204 |
offset += ALIGN(a->size, 4096);
|
|
krh@17
|
205 |
}
|
|
krh@0
|
206 |
|
|
krh@19
|
207 |
header->sections[i].type = ~0;
|
|
krh@17
|
208 |
header->sections[i].offset = 0;
|
|
krh@17
|
209 |
header->sections[i].size = 0;
|
|
krh@10
|
210 |
|
|
krh@0
|
211 |
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
|
|
krh@0
|
212 |
if (fd < 0)
|
|
krh@0
|
213 |
return -1;
|
|
krh@0
|
214 |
|
|
krh@91
|
215 |
razor_write(fd, data, sizeof data);
|
|
danw@113
|
216 |
memset(data, 0, sizeof data);
|
|
krh@19
|
217 |
for (i = 0; i < ARRAY_SIZE(razor_sections); i++) {
|
|
krh@19
|
218 |
if (razor_sections[i].type != i)
|
|
krh@19
|
219 |
continue;
|
|
krh@19
|
220 |
a = (void *) set + razor_sections[i].offset;
|
|
danw@113
|
221 |
razor_write(fd, a->data, a->size);
|
|
danw@113
|
222 |
razor_write(fd, data, ALIGN(a->size, 4096) - a->size);
|
|
krh@19
|
223 |
}
|
|
krh@17
|
224 |
|
|
krh@17
|
225 |
close(fd);
|
|
krh@0
|
226 |
|
|
krh@0
|
227 |
return 0;
|
|
krh@0
|
228 |
}
|
|
krh@0
|
229 |
|
|
krh@27
|
230 |
void
|
|
krh@30
|
231 |
razor_importer_begin_package(struct razor_importer *importer,
|
|
krh@30
|
232 |
const char *name, const char *version)
|
|
krh@13
|
233 |
{
|
|
krh@25
|
234 |
struct razor_package *p;
|
|
krh@13
|
235 |
|
|
krh@30
|
236 |
p = array_add(&importer->set->packages, sizeof *p);
|
|
krh@95
|
237 |
p->name = hashtable_tokenize(&importer->table, name);
|
|
krh@95
|
238 |
p->version = hashtable_tokenize(&importer->table, version);
|
|
krh@13
|
239 |
|
|
krh@30
|
240 |
importer->package = p;
|
|
krh@66
|
241 |
array_init(&importer->properties);
|
|
krh@13
|
242 |
}
|
|
krh@13
|
243 |
|
|
krh@13
|
244 |
void
|
|
krh@30
|
245 |
razor_importer_finish_package(struct razor_importer *importer)
|
|
krh@13
|
246 |
{
|
|
danw@117
|
247 |
list_set_array(&importer->package->properties,
|
|
danw@117
|
248 |
&importer->set->property_pool,
|
|
danw@117
|
249 |
&importer->properties);
|
|
krh@13
|
250 |
|
|
krh@66
|
251 |
array_release(&importer->properties);
|
|
krh@13
|
252 |
}
|
|
krh@13
|
253 |
|
|
krh@66
|
254 |
void
|
|
krh@30
|
255 |
razor_importer_add_property(struct razor_importer *importer,
|
|
danw@109
|
256 |
const char *name,
|
|
danw@109
|
257 |
enum razor_version_relation relation,
|
|
danw@109
|
258 |
const char *version,
|
|
krh@66
|
259 |
enum razor_property_type type)
|
|
krh@13
|
260 |
{
|
|
krh@25
|
261 |
struct razor_property *p;
|
|
danw@108
|
262 |
uint32_t *r;
|
|
krh@13
|
263 |
|
|
krh@66
|
264 |
p = array_add(&importer->set->properties, sizeof *p);
|
|
danw@119
|
265 |
p->name = hashtable_tokenize(&importer->table, name);
|
|
danw@119
|
266 |
p->flags = 0;
|
|
danw@119
|
267 |
p->type = type;
|
|
danw@109
|
268 |
p->relation = relation;
|
|
krh@95
|
269 |
p->version = hashtable_tokenize(&importer->table, version);
|
|
danw@117
|
270 |
list_set_ptr(&p->packages, importer->package -
|
|
danw@117
|
271 |
(struct razor_package *) importer->set->packages.data);
|
|
krh@13
|
272 |
|
|
krh@66
|
273 |
r = array_add(&importer->properties, sizeof *r);
|
|
krh@66
|
274 |
*r = p - (struct razor_property *) importer->set->properties.data;
|
|
krh@30
|
275 |
}
|
|
krh@30
|
276 |
|
|
krh@46
|
277 |
void
|
|
krh@46
|
278 |
razor_importer_add_file(struct razor_importer *importer, const char *name)
|
|
krh@46
|
279 |
{
|
|
krh@52
|
280 |
struct import_entry *e;
|
|
krh@48
|
281 |
|
|
krh@52
|
282 |
e = array_add(&importer->files, sizeof *e);
|
|
krh@52
|
283 |
|
|
krh@52
|
284 |
e->package = importer->package -
|
|
krh@52
|
285 |
(struct razor_package *) importer->set->packages.data;
|
|
krh@52
|
286 |
e->name = strdup(name);
|
|
krh@46
|
287 |
}
|
|
krh@46
|
288 |
|
|
krh@30
|
289 |
struct razor_importer *
|
|
krh@30
|
290 |
razor_importer_new(void)
|
|
krh@30
|
291 |
{
|
|
krh@30
|
292 |
struct razor_importer *importer;
|
|
krh@30
|
293 |
|
|
krh@30
|
294 |
importer = zalloc(sizeof *importer);
|
|
krh@30
|
295 |
importer->set = razor_set_create();
|
|
krh@78
|
296 |
hashtable_init(&importer->table, &importer->set->string_pool);
|
|
krh@30
|
297 |
|
|
krh@30
|
298 |
return importer;
|
|
krh@9
|
299 |
}
|
|
krh@9
|
300 |
|
|
krh@75
|
301 |
/* Destroy an importer without creating the set. */
|
|
krh@75
|
302 |
void
|
|
krh@75
|
303 |
razor_importer_destroy(struct razor_importer *importer)
|
|
krh@75
|
304 |
{
|
|
krh@75
|
305 |
/* FIXME: write this */
|
|
krh@75
|
306 |
}
|
|
krh@75
|
307 |
|
|
krh@75
|
308 |
|
|
krh@22
|
309 |
typedef int (*compare_with_data_func_t)(const void *p1,
|
|
krh@22
|
310 |
const void *p,
|
|
krh@22
|
311 |
void *data);
|
|
krh@22
|
312 |
|
|
krh@25
|
313 |
struct qsort_context {
|
|
krh@25
|
314 |
size_t size;
|
|
krh@25
|
315 |
compare_with_data_func_t compare;
|
|
krh@25
|
316 |
void *data;
|
|
krh@25
|
317 |
};
|
|
krh@25
|
318 |
|
|
krh@22
|
319 |
static void
|
|
krh@22
|
320 |
qsort_swap(void *p1, void *p2, size_t size)
|
|
krh@22
|
321 |
{
|
|
krh@22
|
322 |
char buffer[size];
|
|
krh@22
|
323 |
|
|
krh@22
|
324 |
memcpy(buffer, p1, size);
|
|
krh@22
|
325 |
memcpy(p1, p2, size);
|
|
krh@22
|
326 |
memcpy(p2, buffer, size);
|
|
krh@22
|
327 |
}
|
|
krh@22
|
328 |
|
|
krh@25
|
329 |
static void
|
|
danw@108
|
330 |
__qsort_with_data(void *base, size_t nelem, uint32_t *map,
|
|
krh@25
|
331 |
struct qsort_context *ctx)
|
|
krh@22
|
332 |
{
|
|
krh@22
|
333 |
void *p, *start, *end, *pivot;
|
|
danw@108
|
334 |
uint32_t *mp, *mstart, *mend, tmp;
|
|
krh@22
|
335 |
int left, right, result;
|
|
krh@25
|
336 |
size_t size = ctx->size;
|
|
krh@22
|
337 |
|
|
krh@22
|
338 |
p = base;
|
|
krh@22
|
339 |
start = base;
|
|
krh@22
|
340 |
end = base + nelem * size;
|
|
krh@25
|
341 |
mp = map;
|
|
krh@25
|
342 |
mstart = map;
|
|
krh@25
|
343 |
mend = map + nelem;
|
|
krh@22
|
344 |
pivot = base + (random() % nelem) * size;
|
|
krh@25
|
345 |
|
|
krh@22
|
346 |
while (p < end) {
|
|
krh@25
|
347 |
result = ctx->compare(p, pivot, ctx->data);
|
|
krh@22
|
348 |
if (result < 0) {
|
|
krh@22
|
349 |
qsort_swap(p, start, size);
|
|
krh@25
|
350 |
tmp = *mp;
|
|
krh@25
|
351 |
*mp = *mstart;
|
|
krh@25
|
352 |
*mstart = tmp;
|
|
krh@22
|
353 |
if (start == pivot)
|
|
krh@22
|
354 |
pivot = p;
|
|
krh@22
|
355 |
start += size;
|
|
krh@25
|
356 |
mstart++;
|
|
krh@22
|
357 |
p += size;
|
|
krh@29
|
358 |
mp++;
|
|
krh@22
|
359 |
} else if (result == 0) {
|
|
krh@22
|
360 |
p += size;
|
|
krh@25
|
361 |
mp++;
|
|
krh@22
|
362 |
} else {
|
|
krh@22
|
363 |
end -= size;
|
|
krh@25
|
364 |
mend--;
|
|
krh@22
|
365 |
qsort_swap(p, end, size);
|
|
krh@25
|
366 |
tmp = *mp;
|
|
krh@29
|
367 |
*mp = *mend;
|
|
krh@29
|
368 |
*mend = tmp;
|
|
krh@22
|
369 |
if (end == pivot)
|
|
krh@22
|
370 |
pivot = p;
|
|
krh@22
|
371 |
}
|
|
krh@22
|
372 |
}
|
|
krh@22
|
373 |
|
|
krh@22
|
374 |
left = (start - base) / size;
|
|
krh@22
|
375 |
right = (base + nelem * size - end) / size;
|
|
krh@22
|
376 |
if (left > 1)
|
|
krh@25
|
377 |
__qsort_with_data(base, left, map, ctx);
|
|
krh@22
|
378 |
if (right > 1)
|
|
krh@25
|
379 |
__qsort_with_data(end, right, mend, ctx);
|
|
krh@25
|
380 |
}
|
|
krh@25
|
381 |
|
|
danw@108
|
382 |
uint32_t *
|
|
krh@25
|
383 |
qsort_with_data(void *base, size_t nelem, size_t size,
|
|
krh@25
|
384 |
compare_with_data_func_t compare, void *data)
|
|
krh@25
|
385 |
{
|
|
krh@25
|
386 |
struct qsort_context ctx;
|
|
danw@108
|
387 |
uint32_t *map;
|
|
krh@25
|
388 |
int i;
|
|
krh@25
|
389 |
|
|
krh@75
|
390 |
if (nelem == 0)
|
|
krh@75
|
391 |
return NULL;
|
|
krh@75
|
392 |
|
|
krh@25
|
393 |
ctx.size = size;
|
|
krh@25
|
394 |
ctx.compare = compare;
|
|
krh@25
|
395 |
ctx.data = data;
|
|
krh@25
|
396 |
|
|
danw@108
|
397 |
map = malloc(nelem * sizeof (uint32_t));
|
|
krh@25
|
398 |
for (i = 0; i < nelem; i++)
|
|
krh@25
|
399 |
map[i] = i;
|
|
krh@25
|
400 |
|
|
krh@25
|
401 |
__qsort_with_data(base, nelem, map, &ctx);
|
|
krh@25
|
402 |
|
|
krh@25
|
403 |
return map;
|
|
krh@22
|
404 |
}
|
|
krh@9
|
405 |
|
|
krh@9
|
406 |
static int
|
|
krh@35
|
407 |
versioncmp(const char *s1, const char *s2)
|
|
krh@35
|
408 |
{
|
|
krh@35
|
409 |
const char *p1, *p2;
|
|
krh@35
|
410 |
long n1, n2;
|
|
krh@35
|
411 |
int res;
|
|
krh@35
|
412 |
|
|
krh@35
|
413 |
n1 = strtol(s1, (char **) &p1, 0);
|
|
krh@35
|
414 |
n2 = strtol(s2, (char **) &p2, 0);
|
|
krh@35
|
415 |
|
|
krh@35
|
416 |
/* Epoch; if one but not the other has an epoch set, default
|
|
krh@35
|
417 |
* the epoch-less version to 0. */
|
|
krh@35
|
418 |
res = (*p1 == ':') - (*p2 == ':');
|
|
krh@35
|
419 |
if (res < 0) {
|
|
krh@35
|
420 |
n1 = 0;
|
|
krh@35
|
421 |
p1 = s1;
|
|
krh@35
|
422 |
p2++;
|
|
krh@35
|
423 |
} else if (res > 0) {
|
|
krh@35
|
424 |
p1++;
|
|
krh@35
|
425 |
n2 = 0;
|
|
krh@35
|
426 |
p2 = s2;
|
|
krh@35
|
427 |
}
|
|
krh@35
|
428 |
|
|
krh@35
|
429 |
if (n1 != n2)
|
|
krh@35
|
430 |
return n1 - n2;
|
|
krh@35
|
431 |
while (*p1 && *p2) {
|
|
krh@35
|
432 |
if (*p1 != *p2)
|
|
krh@35
|
433 |
return *p1 - *p2;
|
|
krh@35
|
434 |
p1++;
|
|
krh@35
|
435 |
p2++;
|
|
krh@35
|
436 |
if (isdigit(*p1) && isdigit(*p2))
|
|
krh@35
|
437 |
return versioncmp(p1, p2);
|
|
krh@35
|
438 |
}
|
|
krh@35
|
439 |
|
|
krh@35
|
440 |
return *p1 - *p2;
|
|
krh@35
|
441 |
}
|
|
krh@35
|
442 |
|
|
krh@35
|
443 |
static int
|
|
krh@22
|
444 |
compare_packages(const void *p1, const void *p2, void *data)
|
|
krh@9
|
445 |
{
|
|
krh@25
|
446 |
const struct razor_package *pkg1 = p1, *pkg2 = p2;
|
|
krh@22
|
447 |
struct razor_set *set = data;
|
|
krh@22
|
448 |
char *pool = set->string_pool.data;
|
|
krh@9
|
449 |
|
|
krh@23
|
450 |
if (pkg1->name == pkg2->name)
|
|
krh@35
|
451 |
return versioncmp(&pool[pkg1->version], &pool[pkg2->version]);
|
|
krh@23
|
452 |
else
|
|
krh@23
|
453 |
return strcmp(&pool[pkg1->name], &pool[pkg2->name]);
|
|
krh@9
|
454 |
}
|
|
krh@9
|
455 |
|
|
krh@9
|
456 |
static int
|
|
krh@22
|
457 |
compare_properties(const void *p1, const void *p2, void *data)
|
|
krh@9
|
458 |
{
|
|
krh@25
|
459 |
const struct razor_property *prop1 = p1, *prop2 = p2;
|
|
krh@22
|
460 |
struct razor_set *set = data;
|
|
krh@22
|
461 |
char *pool = set->string_pool.data;
|
|
krh@9
|
462 |
|
|
danw@119
|
463 |
if (prop1->name != prop2->name)
|
|
danw@119
|
464 |
return strcmp(&pool[prop1->name], &pool[prop2->name]);
|
|
danw@119
|
465 |
else if (prop1->type != prop2->type)
|
|
danw@119
|
466 |
return prop1->type - prop2->type;
|
|
danw@119
|
467 |
else if (prop1->relation != prop2->relation)
|
|
danw@119
|
468 |
return prop1->relation - prop2->relation;
|
|
krh@12
|
469 |
else
|
|
danw@119
|
470 |
return versioncmp(&pool[prop1->version], &pool[prop2->version]);
|
|
krh@9
|
471 |
}
|
|
krh@9
|
472 |
|
|
danw@108
|
473 |
static uint32_t *
|
|
krh@66
|
474 |
uniqueify_properties(struct razor_set *set)
|
|
krh@9
|
475 |
{
|
|
krh@25
|
476 |
struct razor_property *rp, *up, *rp_end;
|
|
krh@18
|
477 |
struct array *pkgs, *p;
|
|
danw@117
|
478 |
struct list_head *r;
|
|
danw@117
|
479 |
uint32_t *map, *rmap;
|
|
krh@18
|
480 |
int i, count, unique;
|
|
krh@9
|
481 |
|
|
krh@66
|
482 |
count = set->properties.size / sizeof(struct razor_property);
|
|
krh@66
|
483 |
map = qsort_with_data(set->properties.data,
|
|
krh@25
|
484 |
count,
|
|
krh@25
|
485 |
sizeof(struct razor_property),
|
|
krh@25
|
486 |
compare_properties,
|
|
krh@25
|
487 |
set);
|
|
krh@9
|
488 |
|
|
krh@66
|
489 |
rp_end = set->properties.data + set->properties.size;
|
|
krh@25
|
490 |
rmap = malloc(count * sizeof *map);
|
|
krh@25
|
491 |
pkgs = zalloc(count * sizeof *pkgs);
|
|
krh@66
|
492 |
for (rp = set->properties.data, up = rp, i = 0; rp < rp_end; rp++, i++) {
|
|
danw@119
|
493 |
if (rp->name != up->name || rp->type != up->type ||
|
|
danw@119
|
494 |
rp->relation != up->relation || rp->version != up->version) {
|
|
krh@25
|
495 |
up++;
|
|
krh@25
|
496 |
up->name = rp->name;
|
|
danw@119
|
497 |
up->flags = 0;
|
|
danw@119
|
498 |
up->type = rp->type;
|
|
danw@109
|
499 |
up->relation = rp->relation;
|
|
krh@25
|
500 |
up->version = rp->version;
|
|
krh@10
|
501 |
}
|
|
krh@25
|
502 |
|
|
krh@66
|
503 |
unique = up - (struct razor_property *) set->properties.data;
|
|
krh@25
|
504 |
rmap[map[i]] = unique;
|
|
krh@25
|
505 |
r = array_add(&pkgs[unique], sizeof *r);
|
|
krh@25
|
506 |
*r = rp->packages;
|
|
krh@10
|
507 |
}
|
|
krh@25
|
508 |
free(map);
|
|
krh@9
|
509 |
|
|
krh@25
|
510 |
up++;
|
|
krh@66
|
511 |
set->properties.size = (void *) up - set->properties.data;
|
|
krh@25
|
512 |
rp_end = up;
|
|
krh@66
|
513 |
for (rp = set->properties.data, p = pkgs; rp < rp_end; rp++, p++) {
|
|
danw@117
|
514 |
list_set_array(&rp->packages, &set->package_pool, p);
|
|
krh@25
|
515 |
array_release(p);
|
|
krh@18
|
516 |
}
|
|
krh@18
|
517 |
|
|
krh@18
|
518 |
free(pkgs);
|
|
krh@18
|
519 |
|
|
krh@25
|
520 |
return rmap;
|
|
krh@10
|
521 |
}
|
|
krh@10
|
522 |
|
|
krh@48
|
523 |
static int
|
|
krh@48
|
524 |
compare_filenames(const void *p1, const void *p2, void *data)
|
|
krh@48
|
525 |
{
|
|
krh@52
|
526 |
const struct import_entry *e1 = p1;
|
|
krh@52
|
527 |
const struct import_entry *e2 = p2;
|
|
krh@48
|
528 |
|
|
krh@52
|
529 |
return strcmp(e1->name, e2->name);
|
|
krh@48
|
530 |
}
|
|
krh@48
|
531 |
|
|
krh@48
|
532 |
static void
|
|
krh@52
|
533 |
count_entries(struct import_directory *d)
|
|
krh@48
|
534 |
{
|
|
krh@52
|
535 |
struct import_directory *p, *end;
|
|
krh@48
|
536 |
|
|
krh@48
|
537 |
p = d->files.data;
|
|
krh@48
|
538 |
end = d->files.data + d->files.size;
|
|
krh@48
|
539 |
d->count = 0;
|
|
krh@48
|
540 |
while (p < end) {
|
|
krh@48
|
541 |
count_entries(p);
|
|
krh@48
|
542 |
d->count += p->count + 1;
|
|
krh@48
|
543 |
p++;
|
|
krh@48
|
544 |
}
|
|
krh@48
|
545 |
}
|
|
krh@48
|
546 |
|
|
krh@48
|
547 |
static void
|
|
krh@52
|
548 |
serialize_files(struct razor_set *set,
|
|
krh@52
|
549 |
struct import_directory *d, struct array *array)
|
|
krh@48
|
550 |
{
|
|
krh@52
|
551 |
struct import_directory *p, *end;
|
|
krh@56
|
552 |
struct razor_entry *e = NULL;
|
|
danw@114
|
553 |
uint32_t s;
|
|
krh@48
|
554 |
|
|
krh@48
|
555 |
p = d->files.data;
|
|
krh@48
|
556 |
end = d->files.data + d->files.size;
|
|
krh@48
|
557 |
s = array->size / sizeof *e + d->files.size / sizeof *p;
|
|
krh@48
|
558 |
while (p < end) {
|
|
krh@48
|
559 |
e = array_add(array, sizeof *e);
|
|
krh@48
|
560 |
e->name = p->name;
|
|
krh@56
|
561 |
e->start = p->count > 0 ? s : 0;
|
|
krh@48
|
562 |
s += p->count;
|
|
krh@60
|
563 |
|
|
danw@117
|
564 |
list_set_array(&e->packages, &set->package_pool, &p->packages);
|
|
krh@52
|
565 |
array_release(&p->packages);
|
|
krh@48
|
566 |
p++;
|
|
krh@48
|
567 |
}
|
|
krh@56
|
568 |
if (e != NULL)
|
|
krh@56
|
569 |
e->name |= RAZOR_ENTRY_LAST;
|
|
krh@48
|
570 |
|
|
krh@48
|
571 |
p = d->files.data;
|
|
krh@48
|
572 |
end = d->files.data + d->files.size;
|
|
krh@48
|
573 |
while (p < end) {
|
|
krh@52
|
574 |
serialize_files(set, p, array);
|
|
krh@48
|
575 |
p++;
|
|
krh@48
|
576 |
}
|
|
krh@48
|
577 |
}
|
|
krh@48
|
578 |
|
|
krh@48
|
579 |
static void
|
|
danw@108
|
580 |
remap_property_package_links(struct array *properties, uint32_t *rmap)
|
|
krh@61
|
581 |
{
|
|
krh@61
|
582 |
struct razor_property *p, *end;
|
|
krh@61
|
583 |
|
|
krh@61
|
584 |
end = properties->data + properties->size;
|
|
krh@61
|
585 |
for (p = properties->data; p < end; p++)
|
|
danw@117
|
586 |
list_remap_head(&p->packages, rmap);
|
|
krh@61
|
587 |
}
|
|
krh@61
|
588 |
|
|
krh@61
|
589 |
static void
|
|
krh@48
|
590 |
build_file_tree(struct razor_importer *importer)
|
|
krh@48
|
591 |
{
|
|
krh@48
|
592 |
int count, i, length;
|
|
krh@52
|
593 |
struct import_entry *filenames;
|
|
krh@52
|
594 |
char *f, *end;
|
|
danw@108
|
595 |
uint32_t name, *r;
|
|
krh@48
|
596 |
char dirname[256];
|
|
krh@52
|
597 |
struct import_directory *d, root;
|
|
krh@48
|
598 |
struct razor_entry *e;
|
|
krh@48
|
599 |
|
|
krh@52
|
600 |
count = importer->files.size / sizeof (struct import_entry);
|
|
krh@48
|
601 |
qsort_with_data(importer->files.data,
|
|
krh@48
|
602 |
count,
|
|
krh@52
|
603 |
sizeof (struct import_entry),
|
|
krh@48
|
604 |
compare_filenames,
|
|
krh@48
|
605 |
NULL);
|
|
krh@48
|
606 |
|
|
krh@95
|
607 |
root.name = hashtable_tokenize(&importer->table, "");
|
|
krh@48
|
608 |
array_init(&root.files);
|
|
krh@52
|
609 |
array_init(&root.packages);
|
|
krh@48
|
610 |
root.last = NULL;
|
|
krh@48
|
611 |
|
|
krh@48
|
612 |
filenames = importer->files.data;
|
|
krh@48
|
613 |
for (i = 0; i < count; i++) {
|
|
krh@52
|
614 |
f = filenames[i].name;
|
|
krh@48
|
615 |
if (*f != '/')
|
|
krh@48
|
616 |
continue;
|
|
krh@57
|
617 |
f++;
|
|
krh@48
|
618 |
|
|
krh@48
|
619 |
d = &root;
|
|
krh@48
|
620 |
while (*f) {
|
|
krh@57
|
621 |
end = strchr(f, '/');
|
|
krh@48
|
622 |
if (end == NULL)
|
|
krh@48
|
623 |
end = f + strlen(f);
|
|
krh@57
|
624 |
length = end - f;
|
|
krh@57
|
625 |
memcpy(dirname, f, length);
|
|
krh@48
|
626 |
dirname[length] ='\0';
|
|
krh@95
|
627 |
name = hashtable_tokenize(&importer->table, dirname);
|
|
krh@48
|
628 |
if (d->last == NULL || d->last->name != name) {
|
|
krh@48
|
629 |
d->last = array_add(&d->files, sizeof *d);
|
|
krh@48
|
630 |
d->last->name = name;
|
|
krh@48
|
631 |
d->last->last = NULL;
|
|
krh@48
|
632 |
array_init(&d->last->files);
|
|
krh@52
|
633 |
array_init(&d->last->packages);
|
|
krh@48
|
634 |
}
|
|
krh@48
|
635 |
d = d->last;
|
|
krh@57
|
636 |
f = end + 1;
|
|
krh@57
|
637 |
if (*end == '\0')
|
|
krh@57
|
638 |
break;
|
|
krh@48
|
639 |
}
|
|
krh@48
|
640 |
|
|
krh@52
|
641 |
r = array_add(&d->packages, sizeof *r);
|
|
krh@52
|
642 |
*r = filenames[i].package;
|
|
krh@52
|
643 |
free(filenames[i].name);
|
|
krh@48
|
644 |
}
|
|
krh@48
|
645 |
|
|
krh@48
|
646 |
count_entries(&root);
|
|
krh@56
|
647 |
array_init(&importer->set->files);
|
|
krh@48
|
648 |
|
|
krh@56
|
649 |
e = array_add(&importer->set->files, sizeof *e);
|
|
krh@56
|
650 |
e->name = root.name | RAZOR_ENTRY_LAST;
|
|
krh@48
|
651 |
e->start = 1;
|
|
danw@117
|
652 |
list_set_empty(&e->packages);
|
|
krh@48
|
653 |
|
|
krh@56
|
654 |
serialize_files(importer->set, &root, &importer->set->files);
|
|
krh@48
|
655 |
|
|
krh@48
|
656 |
array_release(&importer->files);
|
|
krh@48
|
657 |
}
|
|
krh@48
|
658 |
|
|
krh@56
|
659 |
static void
|
|
danw@108
|
660 |
build_package_file_lists(struct razor_set *set, uint32_t *rmap)
|
|
krh@54
|
661 |
{
|
|
krh@56
|
662 |
struct razor_package *p, *packages;
|
|
krh@56
|
663 |
struct array *pkgs;
|
|
krh@54
|
664 |
struct razor_entry *e, *end;
|
|
danw@117
|
665 |
struct list *r;
|
|
danw@117
|
666 |
uint32_t *q;
|
|
krh@56
|
667 |
int i, count;
|
|
krh@54
|
668 |
|
|
krh@56
|
669 |
count = set->packages.size / sizeof *p;
|
|
krh@56
|
670 |
pkgs = zalloc(count * sizeof *pkgs);
|
|
krh@54
|
671 |
|
|
krh@56
|
672 |
end = set->files.data + set->files.size;
|
|
krh@92
|
673 |
for (e = set->files.data; e < end; e++) {
|
|
danw@117
|
674 |
list_remap_head(&e->packages, rmap);
|
|
danw@116
|
675 |
r = list_first(&e->packages, &set->package_pool);
|
|
danw@116
|
676 |
while (r) {
|
|
danw@117
|
677 |
q = array_add(&pkgs[r->data], sizeof *q);
|
|
krh@56
|
678 |
*q = e - (struct razor_entry *) set->files.data;
|
|
danw@116
|
679 |
r = list_next(r);
|
|
krh@54
|
680 |
}
|
|
krh@54
|
681 |
}
|
|
krh@54
|
682 |
|
|
krh@56
|
683 |
packages = set->packages.data;
|
|
krh@56
|
684 |
for (i = 0; i < count; i++) {
|
|
danw@117
|
685 |
list_set_array(&packages[i].files, &set->file_pool, &pkgs[i]);
|
|
krh@56
|
686 |
array_release(&pkgs[i]);
|
|
krh@48
|
687 |
}
|
|
krh@56
|
688 |
free(pkgs);
|
|
krh@52
|
689 |
}
|
|
krh@52
|
690 |
|
|
krh@27
|
691 |
struct razor_set *
|
|
krh@30
|
692 |
razor_importer_finish(struct razor_importer *importer)
|
|
krh@9
|
693 |
{
|
|
krh@30
|
694 |
struct razor_set *set;
|
|
danw@108
|
695 |
uint32_t *map, *rmap;
|
|
krh@39
|
696 |
int i, count;
|
|
krh@18
|
697 |
|
|
krh@66
|
698 |
map = uniqueify_properties(importer->set);
|
|
danw@116
|
699 |
list_remap_pool(&importer->set->property_pool, map);
|
|
krh@39
|
700 |
free(map);
|
|
krh@25
|
701 |
|
|
krh@30
|
702 |
count = importer->set->packages.size / sizeof(struct razor_package);
|
|
krh@30
|
703 |
map = qsort_with_data(importer->set->packages.data,
|
|
krh@25
|
704 |
count,
|
|
krh@25
|
705 |
sizeof(struct razor_package),
|
|
krh@25
|
706 |
compare_packages,
|
|
krh@30
|
707 |
importer->set);
|
|
krh@39
|
708 |
|
|
krh@39
|
709 |
rmap = malloc(count * sizeof *rmap);
|
|
krh@39
|
710 |
for (i = 0; i < count; i++)
|
|
krh@39
|
711 |
rmap[map[i]] = i;
|
|
krh@25
|
712 |
free(map);
|
|
krh@13
|
713 |
|
|
krh@48
|
714 |
build_file_tree(importer);
|
|
danw@116
|
715 |
list_remap_pool(&importer->set->package_pool, rmap);
|
|
krh@60
|
716 |
build_package_file_lists(importer->set, rmap);
|
|
krh@66
|
717 |
remap_property_package_links(&importer->set->properties, rmap);
|
|
krh@52
|
718 |
free(rmap);
|
|
krh@48
|
719 |
|
|
krh@30
|
720 |
set = importer->set;
|
|
krh@78
|
721 |
hashtable_release(&importer->table);
|
|
krh@30
|
722 |
free(importer);
|
|
krh@30
|
723 |
|
|
krh@30
|
724 |
return set;
|
|
krh@9
|
725 |
}
|
|
krh@9
|
726 |
|
|
krh@92
|
727 |
struct razor_package_iterator {
|
|
krh@92
|
728 |
struct razor_set *set;
|
|
krh@92
|
729 |
struct razor_package *package, *end;
|
|
danw@117
|
730 |
struct list *index;
|
|
krh@92
|
731 |
};
|
|
krh@92
|
732 |
|
|
krh@92
|
733 |
struct razor_package_iterator *
|
|
krh@101
|
734 |
razor_package_iterator_create_with_index(struct razor_set *set,
|
|
danw@117
|
735 |
struct list *index)
|
|
krh@3
|
736 |
{
|
|
krh@92
|
737 |
struct razor_package_iterator *pi;
|
|
krh@92
|
738 |
|
|
krh@92
|
739 |
pi = zalloc(sizeof *pi);
|
|
krh@92
|
740 |
pi->set = set;
|
|
krh@101
|
741 |
pi->index = index;
|
|
krh@92
|
742 |
|
|
krh@92
|
743 |
return pi;
|
|
krh@92
|
744 |
}
|
|
krh@92
|
745 |
|
|
krh@101
|
746 |
struct razor_package_iterator *
|
|
krh@101
|
747 |
razor_package_iterator_create(struct razor_set *set)
|
|
krh@101
|
748 |
{
|
|
danw@116
|
749 |
struct razor_package_iterator *pi;
|
|
danw@116
|
750 |
|
|
danw@116
|
751 |
pi = zalloc(sizeof *pi);
|
|
danw@116
|
752 |
pi->set = set;
|
|
danw@116
|
753 |
pi->end = set->packages.data + set->packages.size;
|
|
danw@116
|
754 |
pi->package = set->packages.data;
|
|
danw@116
|
755 |
|
|
danw@116
|
756 |
return pi;
|
|
krh@101
|
757 |
}
|
|
krh@101
|
758 |
|
|
krh@101
|
759 |
struct razor_package_iterator *
|
|
krh@101
|
760 |
razor_package_iterator_create_for_property(struct razor_set *set,
|
|
krh@101
|
761 |
struct razor_property *property)
|
|
krh@101
|
762 |
{
|
|
danw@117
|
763 |
struct list *index;
|
|
krh@101
|
764 |
|
|
danw@116
|
765 |
index = list_first(&property->packages, &set->package_pool);
|
|
krh@101
|
766 |
return razor_package_iterator_create_with_index(set, index);
|
|
krh@101
|
767 |
}
|
|
krh@101
|
768 |
|
|
krh@92
|
769 |
int
|
|
krh@92
|
770 |
razor_package_iterator_next(struct razor_package_iterator *pi,
|
|
krh@92
|
771 |
struct razor_package **package,
|
|
krh@92
|
772 |
const char **name, const char **version)
|
|
krh@92
|
773 |
{
|
|
krh@6
|
774 |
char *pool;
|
|
krh@101
|
775 |
int valid;
|
|
krh@101
|
776 |
struct razor_package *p, *packages;
|
|
krh@3
|
777 |
|
|
danw@116
|
778 |
if (pi->package) {
|
|
krh@101
|
779 |
p = pi->package++;
|
|
krh@101
|
780 |
valid = p < pi->end;
|
|
danw@116
|
781 |
} else if (pi->index) {
|
|
danw@116
|
782 |
packages = pi->set->packages.data;
|
|
danw@117
|
783 |
p = &packages[pi->index->data];
|
|
danw@116
|
784 |
pi->index = list_next(pi->index);
|
|
danw@116
|
785 |
valid = 1;
|
|
danw@116
|
786 |
} else
|
|
danw@116
|
787 |
valid = 0;
|
|
krh@92
|
788 |
|
|
krh@101
|
789 |
if (valid) {
|
|
krh@101
|
790 |
pool = pi->set->string_pool.data;
|
|
krh@101
|
791 |
*package = p;
|
|
krh@101
|
792 |
*name = &pool[p->name & RAZOR_ENTRY_MASK];
|
|
krh@101
|
793 |
*version = &pool[p->version];
|
|
krh@101
|
794 |
} else {
|
|
krh@101
|
795 |
*package = NULL;
|
|
krh@101
|
796 |
}
|
|
krh@101
|
797 |
|
|
krh@101
|
798 |
return valid;
|
|
krh@92
|
799 |
}
|
|
krh@92
|
800 |
|
|
krh@92
|
801 |
void
|
|
krh@92
|
802 |
razor_package_iterator_destroy(struct razor_package_iterator *pi)
|
|
krh@92
|
803 |
{
|
|
krh@92
|
804 |
free(pi);
|
|
krh@3
|
805 |
}
|
|
krh@3
|
806 |
|
|
krh@10
|
807 |
struct razor_package *
|
|
krh@10
|
808 |
razor_set_get_package(struct razor_set *set, const char *package)
|
|
krh@10
|
809 |
{
|
|
krh@97
|
810 |
struct razor_package_iterator *pi;
|
|
krh@97
|
811 |
struct razor_package *p;
|
|
krh@97
|
812 |
const char *name, *version;
|
|
krh@97
|
813 |
|
|
krh@97
|
814 |
pi = razor_package_iterator_create(set);
|
|
krh@97
|
815 |
while (razor_package_iterator_next(pi, &p, &name, &version)) {
|
|
krh@97
|
816 |
if (strcmp(package, name) == 0)
|
|
krh@97
|
817 |
break;
|
|
krh@97
|
818 |
}
|
|
krh@97
|
819 |
razor_package_iterator_destroy(pi);
|
|
krh@97
|
820 |
|
|
krh@97
|
821 |
return p;
|
|
krh@10
|
822 |
}
|
|
krh@10
|
823 |
|
|
krh@92
|
824 |
struct razor_property_iterator {
|
|
krh@92
|
825 |
struct razor_set *set;
|
|
krh@92
|
826 |
struct razor_property *property, *end;
|
|
danw@117
|
827 |
struct list *index;
|
|
krh@92
|
828 |
};
|
|
krh@92
|
829 |
|
|
krh@92
|
830 |
struct razor_property_iterator *
|
|
krh@92
|
831 |
razor_property_iterator_create(struct razor_set *set,
|
|
krh@92
|
832 |
struct razor_package *package)
|
|
krh@92
|
833 |
{
|
|
krh@92
|
834 |
struct razor_property_iterator *pi;
|
|
krh@92
|
835 |
|
|
krh@92
|
836 |
pi = zalloc(sizeof *pi);
|
|
krh@92
|
837 |
pi->set = set;
|
|
krh@98
|
838 |
|
|
danw@116
|
839 |
if (package) {
|
|
danw@117
|
840 |
pi->index = list_first(&package->properties,
|
|
danw@117
|
841 |
&set->property_pool);
|
|
danw@116
|
842 |
} else {
|
|
danw@116
|
843 |
pi->property = set->properties.data;
|
|
danw@116
|
844 |
pi->end = set->properties.data + set->properties.size;
|
|
danw@116
|
845 |
}
|
|
krh@92
|
846 |
|
|
krh@92
|
847 |
return pi;
|
|
krh@92
|
848 |
}
|
|
krh@92
|
849 |
|
|
krh@92
|
850 |
int
|
|
krh@92
|
851 |
razor_property_iterator_next(struct razor_property_iterator *pi,
|
|
krh@92
|
852 |
struct razor_property **property,
|
|
danw@109
|
853 |
const char **name,
|
|
danw@109
|
854 |
enum razor_version_relation *relation,
|
|
danw@109
|
855 |
const char **version,
|
|
krh@92
|
856 |
enum razor_property_type *type)
|
|
krh@92
|
857 |
{
|
|
krh@92
|
858 |
char *pool;
|
|
krh@92
|
859 |
int valid;
|
|
krh@92
|
860 |
struct razor_property *p, *properties;
|
|
krh@92
|
861 |
|
|
danw@116
|
862 |
if (pi->property) {
|
|
krh@92
|
863 |
p = pi->property++;
|
|
krh@92
|
864 |
valid = p < pi->end;
|
|
danw@116
|
865 |
} else if (pi->index) {
|
|
danw@116
|
866 |
properties = pi->set->properties.data;
|
|
danw@117
|
867 |
p = &properties[pi->index->data];
|
|
danw@116
|
868 |
pi->index = list_next(pi->index);
|
|
danw@116
|
869 |
valid = 1;
|
|
danw@116
|
870 |
} else
|
|
danw@116
|
871 |
valid = 0;
|
|
krh@92
|
872 |
|
|
krh@96
|
873 |
if (valid) {
|
|
krh@96
|
874 |
pool = pi->set->string_pool.data;
|
|
krh@96
|
875 |
*property = p;
|
|
danw@119
|
876 |
*name = &pool[p->name];
|
|
danw@109
|
877 |
*relation = p->relation;
|
|
krh@96
|
878 |
*version = &pool[p->version];
|
|
danw@119
|
879 |
*type = p->type;
|
|
krh@96
|
880 |
} else {
|
|
krh@96
|
881 |
*property = NULL;
|
|
krh@96
|
882 |
}
|
|
krh@92
|
883 |
|
|
krh@92
|
884 |
return valid;
|
|
krh@92
|
885 |
}
|
|
krh@92
|
886 |
|
|
krh@66
|
887 |
void
|
|
krh@92
|
888 |
razor_property_iterator_destroy(struct razor_property_iterator *pi)
|
|
krh@8
|
889 |
{
|
|
krh@92
|
890 |
free(pi);
|
|
krh@10
|
891 |
}
|
|
krh@10
|
892 |
|
|
krh@56
|
893 |
static struct razor_entry *
|
|
krh@56
|
894 |
find_entry(struct razor_set *set, struct razor_entry *dir, const char *pattern)
|
|
krh@56
|
895 |
{
|
|
krh@56
|
896 |
struct razor_entry *e;
|
|
krh@56
|
897 |
const char *n, *pool = set->string_pool.data;
|
|
krh@56
|
898 |
int len;
|
|
krh@56
|
899 |
|
|
krh@56
|
900 |
e = (struct razor_entry *) set->files.data + dir->start;
|
|
krh@56
|
901 |
do {
|
|
krh@56
|
902 |
n = pool + (e->name & RAZOR_ENTRY_MASK);
|
|
krh@56
|
903 |
if (strcmp(pattern + 1, n) == 0)
|
|
krh@56
|
904 |
return e;
|
|
krh@57
|
905 |
len = strlen(n);
|
|
krh@56
|
906 |
if (e->start != 0 && strncmp(pattern + 1, n, len) == 0 &&
|
|
krh@56
|
907 |
pattern[len + 1] == '/') {
|
|
krh@56
|
908 |
return find_entry(set, e, pattern + len + 1);
|
|
krh@56
|
909 |
}
|
|
krh@56
|
910 |
} while (((e++)->name & RAZOR_ENTRY_LAST) == 0);
|
|
krh@56
|
911 |
|
|
krh@56
|
912 |
return NULL;
|
|
krh@56
|
913 |
}
|
|
krh@56
|
914 |
|
|
krh@56
|
915 |
static void
|
|
krh@56
|
916 |
list_dir(struct razor_set *set, struct razor_entry *dir,
|
|
krh@56
|
917 |
const char *prefix, const char *pattern)
|
|
krh@56
|
918 |
{
|
|
krh@56
|
919 |
struct razor_entry *e;
|
|
krh@56
|
920 |
const char *n, *pool = set->string_pool.data;
|
|
krh@56
|
921 |
|
|
krh@56
|
922 |
e = (struct razor_entry *) set->files.data + dir->start;
|
|
krh@56
|
923 |
do {
|
|
krh@56
|
924 |
n = pool + (e->name & RAZOR_ENTRY_MASK);
|
|
krh@56
|
925 |
if (pattern && pattern[0] && fnmatch(pattern, n, 0) != 0)
|
|
krh@56
|
926 |
continue;
|
|
krh@56
|
927 |
printf("%s/%s%s\n", prefix, n, e->start > 0 ? "/" : "");
|
|
krh@56
|
928 |
} while (((e++)->name & RAZOR_ENTRY_LAST) == 0);
|
|
krh@56
|
929 |
}
|
|
krh@56
|
930 |
|
|
krh@56
|
931 |
void
|
|
krh@56
|
932 |
razor_set_list_files(struct razor_set *set, const char *pattern)
|
|
krh@56
|
933 |
{
|
|
krh@56
|
934 |
struct razor_entry *e;
|
|
krh@56
|
935 |
char buffer[512], *p, *base;
|
|
krh@56
|
936 |
|
|
krh@56
|
937 |
if (pattern == NULL)
|
|
krh@56
|
938 |
pattern = "/";
|
|
krh@56
|
939 |
|
|
krh@56
|
940 |
strcpy(buffer, pattern);
|
|
krh@56
|
941 |
e = find_entry(set, set->files.data, buffer);
|
|
krh@56
|
942 |
if (e && e->start > 0) {
|
|
krh@56
|
943 |
base = NULL;
|
|
krh@56
|
944 |
} else {
|
|
krh@56
|
945 |
p = strrchr(buffer, '/');
|
|
krh@56
|
946 |
if (p) {
|
|
krh@56
|
947 |
*p = '\0';
|
|
krh@56
|
948 |
base = p + 1;
|
|
krh@56
|
949 |
} else {
|
|
krh@56
|
950 |
base = NULL;
|
|
krh@56
|
951 |
}
|
|
krh@56
|
952 |
}
|
|
krh@56
|
953 |
e = find_entry(set, set->files.data, buffer);
|
|
krh@56
|
954 |
if (e->start != 0)
|
|
krh@56
|
955 |
list_dir(set, e, buffer, base);
|
|
krh@56
|
956 |
}
|
|
krh@56
|
957 |
|
|
krh@102
|
958 |
struct razor_package_iterator *
|
|
krh@102
|
959 |
razor_package_iterator_create_for_file(struct razor_set *set,
|
|
krh@102
|
960 |
const char *filename)
|
|
krh@56
|
961 |
{
|
|
krh@102
|
962 |
struct razor_entry *entry;
|
|
danw@117
|
963 |
struct list *index;
|
|
krh@56
|
964 |
|
|
krh@102
|
965 |
entry = find_entry(set, set->files.data, filename);
|
|
krh@102
|
966 |
if (entry == NULL)
|
|
krh@102
|
967 |
return NULL;
|
|
krh@56
|
968 |
|
|
danw@116
|
969 |
index = list_first(&entry->packages, &set->package_pool);
|
|
krh@102
|
970 |
return razor_package_iterator_create_with_index(set, index);
|
|
krh@56
|
971 |
}
|
|
krh@56
|
972 |
|
|
danw@117
|
973 |
static struct list *
|
|
danw@117
|
974 |
list_package_files(struct razor_set *set, struct list *r,
|
|
danw@108
|
975 |
struct razor_entry *dir, uint32_t end,
|
|
krh@56
|
976 |
char *prefix)
|
|
krh@56
|
977 |
{
|
|
krh@56
|
978 |
struct razor_entry *e, *f, *entries;
|
|
danw@108
|
979 |
uint32_t next, file;
|
|
krh@56
|
980 |
char *pool;
|
|
krh@56
|
981 |
int len;
|
|
krh@56
|
982 |
|
|
krh@56
|
983 |
entries = (struct razor_entry *) set->files.data;
|
|
krh@56
|
984 |
pool = set->string_pool.data;
|
|
krh@56
|
985 |
|
|
krh@56
|
986 |
e = entries + dir->start;
|
|
krh@56
|
987 |
do {
|
|
danw@117
|
988 |
if (entries + r->data == e) {
|
|
krh@56
|
989 |
printf("%s/%s\n", prefix,
|
|
krh@56
|
990 |
pool + (e->name & RAZOR_ENTRY_MASK));
|
|
danw@116
|
991 |
r = list_next(r);
|
|
danw@116
|
992 |
if (!r)
|
|
krh@83
|
993 |
return NULL;
|
|
danw@117
|
994 |
if (r->data >= end)
|
|
krh@83
|
995 |
return r;
|
|
krh@56
|
996 |
}
|
|
krh@83
|
997 |
} while (!((e++)->name & RAZOR_ENTRY_LAST));
|
|
krh@56
|
998 |
|
|
krh@56
|
999 |
e = entries + dir->start;
|
|
krh@56
|
1000 |
do {
|
|
krh@56
|
1001 |
if (e->start == 0)
|
|
krh@56
|
1002 |
continue;
|
|
krh@56
|
1003 |
|
|
krh@56
|
1004 |
if (e->name & RAZOR_ENTRY_LAST)
|
|
krh@56
|
1005 |
next = end;
|
|
krh@56
|
1006 |
else {
|
|
krh@56
|
1007 |
f = e + 1;
|
|
krh@56
|
1008 |
while (f->start == 0 && !(f->name & RAZOR_ENTRY_LAST))
|
|
krh@56
|
1009 |
f++;
|
|
krh@56
|
1010 |
if (f->start == 0)
|
|
krh@56
|
1011 |
next = end;
|
|
krh@56
|
1012 |
else
|
|
krh@56
|
1013 |
next = f->start;
|
|
krh@56
|
1014 |
}
|
|
krh@56
|
1015 |
|
|
danw@117
|
1016 |
file = r->data;
|
|
krh@83
|
1017 |
if (e->start <= file && file < next) {
|
|
krh@56
|
1018 |
len = strlen(prefix);
|
|
krh@56
|
1019 |
prefix[len] = '/';
|
|
krh@56
|
1020 |
strcpy(prefix + len + 1,
|
|
krh@56
|
1021 |
pool + (e->name & RAZOR_ENTRY_MASK));
|
|
krh@56
|
1022 |
r = list_package_files(set, r, e, next, prefix);
|
|
krh@56
|
1023 |
prefix[len] = '\0';
|
|
krh@56
|
1024 |
}
|
|
krh@83
|
1025 |
} while (!((e++)->name & RAZOR_ENTRY_LAST) && r != NULL);
|
|
krh@56
|
1026 |
|
|
krh@56
|
1027 |
return r;
|
|
krh@56
|
1028 |
}
|
|
krh@56
|
1029 |
|
|
krh@56
|
1030 |
void
|
|
krh@56
|
1031 |
razor_set_list_package_files(struct razor_set *set, const char *name)
|
|
krh@56
|
1032 |
{
|
|
krh@56
|
1033 |
struct razor_package *package;
|
|
danw@117
|
1034 |
struct list *r;
|
|
danw@117
|
1035 |
uint32_t end;
|
|
krh@56
|
1036 |
char buffer[512];
|
|
krh@56
|
1037 |
|
|
krh@56
|
1038 |
package = razor_set_get_package(set, name);
|
|
krh@56
|
1039 |
|
|
danw@116
|
1040 |
r = list_first(&package->files, &set->file_pool);
|
|
krh@56
|
1041 |
end = set->files.size / sizeof (struct razor_entry);
|
|
krh@56
|
1042 |
buffer[0] = '\0';
|
|
krh@56
|
1043 |
list_package_files(set, r, set->files.data, end, buffer);
|
|
krh@56
|
1044 |
}
|
|
krh@56
|
1045 |
|
|
krh@43
|
1046 |
static void
|
|
krh@21
|
1047 |
razor_set_validate(struct razor_set *set, struct array *unsatisfied)
|
|
krh@21
|
1048 |
{
|
|
krh@66
|
1049 |
struct razor_property *r, *p, *end;
|
|
danw@108
|
1050 |
uint32_t *u;
|
|
krh@21
|
1051 |
char *pool;
|
|
krh@21
|
1052 |
|
|
krh@66
|
1053 |
end = set->properties.data + set->properties.size;
|
|
krh@21
|
1054 |
pool = set->string_pool.data;
|
|
krh@21
|
1055 |
|
|
krh@66
|
1056 |
for (r = set->properties.data, p = r; r < end; r++) {
|
|
danw@119
|
1057 |
if (r->type != RAZOR_PROPERTY_REQUIRES)
|
|
krh@66
|
1058 |
continue;
|
|
krh@66
|
1059 |
|
|
danw@119
|
1060 |
if (r->name != p->name) {
|
|
krh@66
|
1061 |
p = r;
|
|
danw@119
|
1062 |
while (p < end && p->name == r->name &&
|
|
danw@119
|
1063 |
p->type == r->type)
|
|
krh@66
|
1064 |
p++;
|
|
krh@66
|
1065 |
}
|
|
krh@37
|
1066 |
|
|
krh@35
|
1067 |
/* If there is more than one version of a provides,
|
|
krh@35
|
1068 |
* seek to the end for the highest version. */
|
|
krh@66
|
1069 |
/* FIXME: This doesn't work if we have a series of
|
|
krh@66
|
1070 |
* requires a = 1, provides a = 1, requires a = 2,
|
|
krh@66
|
1071 |
* provides a = 2, as the kernel and kernel-devel
|
|
krh@66
|
1072 |
* does.*/
|
|
danw@119
|
1073 |
while (p + 1 < end && p->name == (p + 1)->name &&
|
|
danw@119
|
1074 |
p->type == (p + 1)->type)
|
|
krh@35
|
1075 |
p++;
|
|
krh@37
|
1076 |
|
|
krh@37
|
1077 |
/* FIXME: We need to track property flags (<, <=, =
|
|
krh@37
|
1078 |
* etc) to properly determine if a requires is
|
|
krh@37
|
1079 |
* satisfied. The current code doesn't track that the
|
|
krh@37
|
1080 |
* requires a = 1 isn't satisfied by a = 2 provides. */
|
|
krh@37
|
1081 |
|
|
krh@66
|
1082 |
if (p == end ||
|
|
danw@119
|
1083 |
p->type != RAZOR_PROPERTY_PROVIDES ||
|
|
danw@119
|
1084 |
r->name != p->name ||
|
|
krh@35
|
1085 |
versioncmp(&pool[r->version], &pool[p->version]) > 0) {
|
|
krh@35
|
1086 |
/* FIXME: We ignore file requires for now. */
|
|
danw@119
|
1087 |
if (pool[r->name] == '/')
|
|
krh@35
|
1088 |
continue;
|
|
krh@21
|
1089 |
u = array_add(unsatisfied, sizeof *u);
|
|
krh@66
|
1090 |
*u = r - (struct razor_property *) set->properties.data;
|
|
krh@21
|
1091 |
}
|
|
krh@21
|
1092 |
}
|
|
krh@21
|
1093 |
}
|
|
krh@21
|
1094 |
|
|
krh@21
|
1095 |
void
|
|
krh@21
|
1096 |
razor_set_list_unsatisfied(struct razor_set *set)
|
|
krh@21
|
1097 |
{
|
|
krh@21
|
1098 |
struct array unsatisfied;
|
|
krh@66
|
1099 |
struct razor_property *properties, *r;
|
|
danw@108
|
1100 |
uint32_t *u, *end;
|
|
krh@21
|
1101 |
char *pool;
|
|
krh@21
|
1102 |
|
|
krh@21
|
1103 |
array_init(&unsatisfied);
|
|
krh@21
|
1104 |
razor_set_validate(set, &unsatisfied);
|
|
krh@21
|
1105 |
|
|
krh@21
|
1106 |
end = unsatisfied.data + unsatisfied.size;
|
|
krh@66
|
1107 |
properties = set->properties.data;
|
|
krh@21
|
1108 |
pool = set->string_pool.data;
|
|
krh@21
|
1109 |
|
|
krh@21
|
1110 |
for (u = unsatisfied.data; u < end; u++) {
|
|
krh@66
|
1111 |
r = properties + *u;
|
|
krh@66
|
1112 |
if (pool[r->version] == '\0')
|
|
krh@66
|
1113 |
printf("%ss not satisfied\n",
|
|
danw@119
|
1114 |
&pool[r->name]);
|
|
krh@66
|
1115 |
else
|
|
krh@66
|
1116 |
printf("%s-%s not satisfied\n",
|
|
danw@119
|
1117 |
&pool[r->name],
|
|
krh@66
|
1118 |
&pool[r->version]);
|
|
krh@21
|
1119 |
}
|
|
krh@21
|
1120 |
|
|
krh@21
|
1121 |
array_release(&unsatisfied);
|
|
krh@21
|
1122 |
}
|
|
krh@21
|
1123 |
|
|
krh@41
|
1124 |
#define UPSTREAM_SOURCE 0x80000000ul
|
|
krh@41
|
1125 |
#define INDEX_MASK 0x00fffffful
|
|
krh@41
|
1126 |
|
|
krh@41
|
1127 |
struct source {
|
|
krh@41
|
1128 |
struct razor_set *set;
|
|
danw@108
|
1129 |
uint32_t *property_map;
|
|
krh@41
|
1130 |
};
|
|
krh@41
|
1131 |
|
|
krh@79
|
1132 |
struct razor_merger {
|
|
krh@79
|
1133 |
struct razor_set *set;
|
|
krh@79
|
1134 |
struct hashtable table;
|
|
krh@79
|
1135 |
struct source source1;
|
|
krh@79
|
1136 |
struct source source2;
|
|
krh@79
|
1137 |
};
|
|
krh@79
|
1138 |
|
|
krh@79
|
1139 |
static struct razor_merger *
|
|
krh@79
|
1140 |
razor_merger_create(struct razor_set *set1, struct razor_set *set2)
|
|
krh@41
|
1141 |
{
|
|
krh@79
|
1142 |
struct razor_merger *merger;
|
|
krh@41
|
1143 |
int count;
|
|
krh@41
|
1144 |
size_t size;
|
|
krh@41
|
1145 |
|
|
krh@79
|
1146 |
merger = zalloc(sizeof *merger);
|
|
krh@79
|
1147 |
merger->set = razor_set_create();
|
|
krh@79
|
1148 |
hashtable_init(&merger->table, &merger->set->string_pool);
|
|
krh@41
|
1149 |
|
|
krh@79
|
1150 |
count = set1->properties.size / sizeof (struct razor_property);
|
|
krh@79
|
1151 |
size = count * sizeof merger->source1.property_map[0];
|
|
krh@79
|
1152 |
merger->source1.property_map = zalloc(size);
|
|
krh@79
|
1153 |
merger->source1.set = set1;
|
|
krh@79
|
1154 |
|
|
krh@79
|
1155 |
count = set2->properties.size / sizeof (struct razor_property);
|
|
krh@79
|
1156 |
size = count * sizeof merger->source2.property_map[0];
|
|
krh@79
|
1157 |
merger->source2.property_map = zalloc(size);
|
|
krh@79
|
1158 |
merger->source2.set = set2;
|
|
krh@79
|
1159 |
|
|
krh@79
|
1160 |
return merger;
|
|
krh@41
|
1161 |
}
|
|
krh@41
|
1162 |
|
|
krh@33
|
1163 |
static void
|
|
krh@79
|
1164 |
add_package(struct razor_merger *merger,
|
|
krh@41
|
1165 |
struct razor_package *package, struct source *source,
|
|
danw@108
|
1166 |
uint32_t flags)
|
|
krh@33
|
1167 |
{
|
|
krh@33
|
1168 |
char *pool;
|
|
danw@117
|
1169 |
struct list *r;
|
|
krh@41
|
1170 |
struct razor_package *p;
|
|
krh@33
|
1171 |
|
|
krh@41
|
1172 |
pool = source->set->string_pool.data;
|
|
krh@79
|
1173 |
p = array_add(&merger->set->packages, sizeof *p);
|
|
krh@79
|
1174 |
p->name = hashtable_tokenize(&merger->table, &pool[package->name]);
|
|
krh@41
|
1175 |
p->name |= flags;
|
|
krh@79
|
1176 |
p->version = hashtable_tokenize(&merger->table,
|
|
krh@79
|
1177 |
&pool[package->version]);
|
|
krh@66
|
1178 |
p->properties = package->properties;
|
|
krh@33
|
1179 |
|
|
danw@116
|
1180 |
r = list_first(&package->properties, &source->set->property_pool);
|
|
danw@116
|
1181 |
while (r) {
|
|
danw@117
|
1182 |
source->property_map[r->data] = 1;
|
|
danw@116
|
1183 |
r = list_next(r);
|
|
krh@64
|
1184 |
}
|
|
krh@41
|
1185 |
}
|
|
krh@41
|
1186 |
|
|
krh@41
|
1187 |
|
|
krh@41
|
1188 |
/* Build the new package list sorted by merging the two package lists.
|
|
krh@79
|
1189 |
* Build new string pool as we go. */
|
|
krh@41
|
1190 |
static void
|
|
krh@79
|
1191 |
merge_packages(struct razor_merger *merger, struct array *packages)
|
|
krh@41
|
1192 |
{
|
|
krh@41
|
1193 |
struct razor_package *upstream_packages, *p, *s, *send;
|
|
krh@79
|
1194 |
struct source *source1, *source2;
|
|
krh@41
|
1195 |
char *spool, *upool;
|
|
danw@108
|
1196 |
uint32_t *u, *uend;
|
|
krh@41
|
1197 |
int cmp;
|
|
krh@41
|
1198 |
|
|
krh@79
|
1199 |
source1 = &merger->source1;
|
|
krh@79
|
1200 |
source2 = &merger->source2;
|
|
krh@41
|
1201 |
upstream_packages = source2->set->packages.data;
|
|
krh@41
|
1202 |
|
|
krh@41
|
1203 |
u = packages->data;
|
|
krh@41
|
1204 |
uend = packages->data + packages->size;
|
|
krh@41
|
1205 |
upool = source2->set->string_pool.data;
|
|
krh@41
|
1206 |
|
|
krh@41
|
1207 |
s = source1->set->packages.data;
|
|
krh@41
|
1208 |
send = source1->set->packages.data + source1->set->packages.size;
|
|
krh@41
|
1209 |
spool = source1->set->string_pool.data;
|
|
krh@41
|
1210 |
|
|
krh@41
|
1211 |
while (s < send) {
|
|
krh@41
|
1212 |
p = upstream_packages + *u;
|
|
krh@41
|
1213 |
|
|
krh@41
|
1214 |
if (u < uend)
|
|
krh@41
|
1215 |
cmp = strcmp(&spool[s->name], &upool[p->name]);
|
|
krh@41
|
1216 |
if (u >= uend || cmp < 0) {
|
|
krh@79
|
1217 |
add_package(merger, s, source1, 0);
|
|
krh@41
|
1218 |
s++;
|
|
krh@41
|
1219 |
} else if (cmp == 0) {
|
|
krh@79
|
1220 |
add_package(merger, p, source2, UPSTREAM_SOURCE);
|
|
krh@41
|
1221 |
s++;
|
|
krh@41
|
1222 |
u++;
|
|
krh@41
|
1223 |
} else {
|
|
krh@79
|
1224 |
add_package(merger, p, source2, UPSTREAM_SOURCE);
|
|
krh@41
|
1225 |
u++;
|
|
krh@41
|
1226 |
}
|
|
krh@41
|
1227 |
}
|
|
krh@41
|
1228 |
}
|
|
krh@41
|
1229 |
|
|
danw@108
|
1230 |
static uint32_t
|
|
krh@79
|
1231 |
add_property(struct razor_merger *merger,
|
|
danw@109
|
1232 |
const char *name, enum razor_version_relation relation,
|
|
danw@109
|
1233 |
const char *version, int type)
|
|
krh@41
|
1234 |
{
|
|
krh@41
|
1235 |
struct razor_property *p;
|
|
krh@41
|
1236 |
|
|
krh@79
|
1237 |
p = array_add(&merger->set->properties, sizeof *p);
|
|
danw@119
|
1238 |
p->name = hashtable_tokenize(&merger->table, name);
|
|
danw@119
|
1239 |
p->flags = 0;
|
|
danw@119
|
1240 |
p->type = type;
|
|
danw@109
|
1241 |
p->relation = relation;
|
|
krh@79
|
1242 |
p->version = hashtable_tokenize(&merger->table, version);
|
|
krh@41
|
1243 |
|
|
krh@79
|
1244 |
return p - (struct razor_property *) merger->set->properties.data;
|
|
krh@41
|
1245 |
}
|
|
krh@41
|
1246 |
|
|
krh@41
|
1247 |
static void
|
|
krh@79
|
1248 |
merge_properties(struct razor_merger *merger)
|
|
krh@41
|
1249 |
{
|
|
krh@41
|
1250 |
struct razor_property *p1, *p2;
|
|
krh@79
|
1251 |
struct razor_set *set1, *set2;
|
|
danw@108
|
1252 |
uint32_t *map1, *map2;
|
|
krh@41
|
1253 |
int i, j, cmp, count1, count2;
|
|
krh@41
|
1254 |
char *pool1, *pool2;
|
|
krh@41
|
1255 |
|
|
krh@79
|
1256 |
set1 = merger->source1.set;
|
|
krh@79
|
1257 |
set2 = merger->source2.set;
|
|
krh@79
|
1258 |
map1 = merger->source1.property_map;
|
|
krh@79
|
1259 |
map2 = merger->source2.property_map;
|
|
krh@79
|
1260 |
|
|
krh@41
|
1261 |
i = 0;
|
|
krh@41
|
1262 |
j = 0;
|
|
krh@41
|
1263 |
pool1 = set1->string_pool.data;
|
|
krh@41
|
1264 |
pool2 = set2->string_pool.data;
|
|
krh@41
|
1265 |
|
|
krh@66
|
1266 |
count1 = set1->properties.size / sizeof *p1;
|
|
krh@66
|
1267 |
count2 = set2->properties.size / sizeof *p2;
|
|
krh@41
|
1268 |
while (i < count1 || j < count2) {
|
|
krh@41
|
1269 |
if (i < count1 && map1[i] == 0) {
|
|
krh@41
|
1270 |
i++;
|
|
krh@41
|
1271 |
continue;
|
|
krh@41
|
1272 |
}
|
|
krh@41
|
1273 |
if (j < count2 && map2[j] == 0) {
|
|
krh@41
|
1274 |
j++;
|
|
krh@41
|
1275 |
continue;
|
|
krh@41
|
1276 |
}
|
|
krh@66
|
1277 |
p1 = (struct razor_property *) set1->properties.data + i;
|
|
krh@66
|
1278 |
p2 = (struct razor_property *) set2->properties.data + j;
|
|
krh@41
|
1279 |
if (i < count1 && j < count2)
|
|
danw@119
|
1280 |
cmp = strcmp(&pool1[p1->name], &pool2[p2->name]);
|
|
krh@41
|
1281 |
else if (i < count1)
|
|
krh@41
|
1282 |
cmp = -1;
|
|
krh@41
|
1283 |
else
|
|
krh@41
|
1284 |
cmp = 1;
|
|
krh@41
|
1285 |
if (cmp == 0)
|
|
danw@109
|
1286 |
cmp = p1->relation - p2->relation;
|
|
danw@109
|
1287 |
if (cmp == 0)
|
|
krh@41
|
1288 |
cmp = versioncmp(&pool1[p1->version],
|
|
krh@41
|
1289 |
&pool2[p2->version]);
|
|
krh@41
|
1290 |
if (cmp < 0) {
|
|
krh@79
|
1291 |
map1[i++] = add_property(merger,
|
|
danw@119
|
1292 |
&pool1[p1->name],
|
|
danw@109
|
1293 |
p1->relation,
|
|
krh@69
|
1294 |
&pool1[p1->version],
|
|
danw@119
|
1295 |
p1->type);
|
|
krh@41
|
1296 |
} else if (cmp > 0) {
|
|
krh@79
|
1297 |
map2[j++] = add_property(merger,
|
|
danw@119
|
1298 |
&pool2[p2->name],
|
|
danw@109
|
1299 |
p2->relation,
|
|
krh@69
|
1300 |
&pool2[p2->version],
|
|
danw@119
|
1301 |
p2->type);
|
|
krh@41
|
1302 |
} else {
|
|
krh@79
|
1303 |
map1[i++] = map2[j++] = add_property(merger,
|
|
danw@119
|
1304 |
&pool1[p1->name],
|
|
danw@109
|
1305 |
p1->relation,
|
|
krh@69
|
1306 |
&pool1[p1->version],
|
|
danw@119
|
1307 |
p1->type);
|
|
krh@41
|
1308 |
}
|
|
krh@41
|
1309 |
}
|
|
krh@41
|
1310 |
}
|
|
krh@41
|
1311 |
|
|
danw@116
|
1312 |
static void
|
|
danw@117
|
1313 |
emit_properties(struct list_head *properties, struct array *source_pool,
|
|
danw@108
|
1314 |
uint32_t *map, struct array *pool)
|
|
krh@41
|
1315 |
{
|
|
danw@117
|
1316 |
uint32_t r;
|
|
danw@117
|
1317 |
struct list *p, *q;
|
|
krh@41
|
1318 |
|
|
krh@41
|
1319 |
r = pool->size / sizeof *q;
|
|
danw@116
|
1320 |
p = list_first(properties, source_pool);
|
|
danw@116
|
1321 |
while (p) {
|
|
krh@41
|
1322 |
q = array_add(pool, sizeof *q);
|
|
danw@117
|
1323 |
q->data = map[p->data];
|
|
danw@117
|
1324 |
q->flags = p->flags;
|
|
danw@116
|
1325 |
p = list_next(p);
|
|
krh@33
|
1326 |
}
|
|
krh@33
|
1327 |
|
|
danw@117
|
1328 |
list_set_ptr(properties, r);
|
|
krh@41
|
1329 |
}
|
|
krh@41
|
1330 |
|
|
krh@41
|
1331 |
/* Rebuild property->packages maps. We can't just remap these, as a
|
|
krh@41
|
1332 |
* property may have lost or gained a number of packages. Allocate an
|
|
krh@41
|
1333 |
* array per property and loop through the packages and add them to
|
|
krh@41
|
1334 |
* the arrays for their properties. */
|
|
krh@41
|
1335 |
static void
|
|
krh@41
|
1336 |
rebuild_package_lists(struct razor_set *set)
|
|
krh@41
|
1337 |
{
|
|
krh@66
|
1338 |
struct array *pkgs, *a;
|
|
krh@41
|
1339 |
struct razor_package *pkg, *pkg_end;
|
|
krh@41
|
1340 |
struct razor_property *prop, *prop_end;
|
|
danw@116
|
1341 |
struct array *pool;
|
|
danw@117
|
1342 |
struct list *r;
|
|
danw@117
|
1343 |
uint32_t *q;
|
|
krh@66
|
1344 |
int count;
|
|
krh@41
|
1345 |
|
|
krh@66
|
1346 |
count = set->properties.size / sizeof (struct razor_property);
|
|
krh@66
|
1347 |
pkgs = zalloc(count * sizeof *pkgs);
|
|
krh@41
|
1348 |
pkg_end = set->packages.data + set->packages.size;
|
|
danw@116
|
1349 |
pool = &set->property_pool;
|
|
krh@41
|
1350 |
|
|
krh@41
|
1351 |
for (pkg = set->packages.data; pkg < pkg_end; pkg++) {
|
|
danw@116
|
1352 |
r = list_first(&pkg->properties, pool);
|
|
danw@116
|
1353 |
while (r) {
|
|
danw@117
|
1354 |
q = array_add(&pkgs[r->data], sizeof *q);
|
|
krh@41
|
1355 |
*q = pkg - (struct razor_package *) set->packages.data;
|
|
danw@116
|
1356 |
r = list_next(r);
|
|
krh@41
|
1357 |
}
|
|
krh@33
|
1358 |
}
|
|
krh@33
|
1359 |
|
|
krh@66
|
1360 |
prop_end = set->properties.data + set->properties.size;
|
|
krh@66
|
1361 |
a = pkgs;
|
|
krh@66
|
1362 |
for (prop = set->properties.data; prop < prop_end; prop++, a++) {
|
|
danw@117
|
1363 |
list_set_array(&prop->packages, pool, a);
|
|
krh@41
|
1364 |
array_release(a);
|
|
krh@41
|
1365 |
}
|
|
krh@66
|
1366 |
free(pkgs);
|
|
krh@33
|
1367 |
}
|
|
krh@33
|
1368 |
|
|
krh@79
|
1369 |
struct razor_set *
|
|
krh@79
|
1370 |
razor_merger_finish(struct razor_merger *merger)
|
|
krh@79
|
1371 |
{
|
|
krh@79
|
1372 |
struct razor_set *result;
|
|
krh@79
|
1373 |
|
|
krh@79
|
1374 |
result = merger->set;
|
|
krh@79
|
1375 |
hashtable_release(&merger->table);
|
|
krh@79
|
1376 |
free(merger);
|
|
krh@79
|
1377 |
|
|
krh@79
|
1378 |
return result;
|
|
krh@79
|
1379 |
}
|
|
krh@79
|
1380 |
|
|
krh@33
|
1381 |
/* Add packages from 'upstream' to 'set'. The packages to add are
|
|
krh@33
|
1382 |
* specified by the 'packages' array, which is a sorted list of
|
|
krh@33
|
1383 |
* package indexes. Returns a newly allocated package set. Does not
|
|
krh@41
|
1384 |
* enforce validity of the resulting package set.
|
|
krh@41
|
1385 |
*
|
|
krh@41
|
1386 |
* This looks more complicated than it is. An easy way to merge two
|
|
krh@41
|
1387 |
* package sets would be to just use a razor_importer, but that
|
|
krh@41
|
1388 |
* requires resorting, and is thus O(n log n). We can do this in a
|
|
krh@41
|
1389 |
* linear sweep, but it gets a little more complicated.
|
|
krh@41
|
1390 |
*/
|
|
krh@33
|
1391 |
struct razor_set *
|
|
krh@33
|
1392 |
razor_set_add(struct razor_set *set, struct razor_set *upstream,
|
|
krh@33
|
1393 |
struct array *packages)
|
|
krh@33
|
1394 |
{
|
|
krh@79
|
1395 |
struct razor_merger *merger;
|
|
krh@41
|
1396 |
struct razor_package *p, *pend;
|
|
krh@33
|
1397 |
|
|
krh@79
|
1398 |
merger = razor_merger_create(set, upstream);
|
|
krh@33
|
1399 |
|
|
krh@79
|
1400 |
merge_packages(merger, packages);
|
|
krh@41
|
1401 |
|
|
krh@41
|
1402 |
/* As we built the package list, we filled out a bitvector of
|
|
krh@41
|
1403 |
* the properties that are referenced by the packages in the
|
|
krh@41
|
1404 |
* new set. Now we do a parallel loop through the properties
|
|
krh@41
|
1405 |
* and emit those marked in the bit vector to the new set. In
|
|
krh@41
|
1406 |
* the process, we update the bit vector to actually map from
|
|
krh@41
|
1407 |
* indices in the old property list to indices in the new
|
|
krh@41
|
1408 |
* property list for both sets. */
|
|
krh@41
|
1409 |
|
|
krh@79
|
1410 |
merge_properties(merger);
|
|
krh@41
|
1411 |
|
|
krh@41
|
1412 |
/* Now we loop through the packages again and emit the
|
|
krh@41
|
1413 |
* property lists, remapped to point to the new properties. */
|
|
krh@41
|
1414 |
|
|
krh@79
|
1415 |
pend = merger->set->packages.data + merger->set->packages.size;
|
|
krh@79
|
1416 |
for (p = merger->set->packages.data; p < pend; p++) {
|
|
krh@41
|
1417 |
struct source *src;
|
|
krh@41
|
1418 |
|
|
krh@41
|
1419 |
if (p->name & UPSTREAM_SOURCE)
|
|
krh@79
|
1420 |
src = &merger->source2;
|
|
krh@41
|
1421 |
else
|
|
krh@79
|
1422 |
src = &merger->source1;
|
|
krh@41
|
1423 |
|
|
danw@116
|
1424 |
emit_properties(&p->properties,
|
|
danw@116
|
1425 |
&src->set->property_pool,
|
|
danw@116
|
1426 |
src->property_map,
|
|
danw@116
|
1427 |
&merger->set->property_pool);
|
|
krh@41
|
1428 |
p->name &= INDEX_MASK;
|
|
krh@33
|
1429 |
}
|
|
krh@33
|
1430 |
|
|
krh@79
|
1431 |
rebuild_package_lists(merger->set);
|
|
krh@41
|
1432 |
|
|
krh@79
|
1433 |
return razor_merger_finish(merger);
|
|
krh@33
|
1434 |
}
|
|
krh@33
|
1435 |
|
|
krh@37
|
1436 |
void
|
|
krh@37
|
1437 |
razor_set_satisfy(struct razor_set *set, struct array *unsatisfied,
|
|
krh@37
|
1438 |
struct razor_set *upstream, struct array *list)
|
|
krh@37
|
1439 |
{
|
|
krh@37
|
1440 |
struct razor_property *requires, *r;
|
|
krh@37
|
1441 |
struct razor_property *p, *pend;
|
|
danw@116
|
1442 |
uint32_t *u, *end, *pkg;
|
|
danw@116
|
1443 |
struct array *package_pool;
|
|
krh@37
|
1444 |
char *pool, *upool;
|
|
krh@37
|
1445 |
|
|
krh@37
|
1446 |
end = unsatisfied->data + unsatisfied->size;
|
|
krh@66
|
1447 |
requires = set->properties.data;
|
|
krh@37
|
1448 |
pool = set->string_pool.data;
|
|
krh@37
|
1449 |
|
|
krh@66
|
1450 |
p = upstream->properties.data;
|
|
krh@66
|
1451 |
pend = upstream->properties.data + upstream->properties.size;
|
|
krh@37
|
1452 |
upool = upstream->string_pool.data;
|
|
danw@116
|
1453 |
package_pool = &upstream->package_pool;
|
|
krh@37
|
1454 |
|
|
krh@37
|
1455 |
for (u = unsatisfied->data; u < end; u++) {
|
|
krh@37
|
1456 |
r = requires + *u;
|
|
krh@37
|
1457 |
|
|
krh@66
|
1458 |
while (p < pend &&
|
|
danw@119
|
1459 |
strcmp(&pool[r->name], &upool[p->name]) > 0 &&
|
|
danw@119
|
1460 |
p->type != RAZOR_PROPERTY_PROVIDES)
|
|
krh@37
|
1461 |
p++;
|
|
krh@37
|
1462 |
/* If there is more than one version of a provides,
|
|
krh@37
|
1463 |
* seek to the end for the highest version. */
|
|
danw@119
|
1464 |
while (p + 1 < pend && p->name == (p + 1)->name && p->type == (p + 1)->type)
|
|
krh@37
|
1465 |
p++;
|
|
krh@37
|
1466 |
|
|
krh@37
|
1467 |
if (p == pend ||
|
|
danw@119
|
1468 |
strcmp(&pool[r->name], &upool[p->name]) != 0 ||
|
|
krh@37
|
1469 |
versioncmp(&pool[r->version], &upool[p->version]) > 0) {
|
|
krh@37
|
1470 |
/* Do we need to track unsatisfiable requires
|
|
krh@37
|
1471 |
* as we go, or should we just do a
|
|
krh@37
|
1472 |
* razor_set_validate() at the end? */
|
|
krh@37
|
1473 |
} else {
|
|
krh@37
|
1474 |
pkg = array_add(list, sizeof *pkg);
|
|
krh@37
|
1475 |
/* We just pull in the first package that provides */
|
|
danw@117
|
1476 |
*pkg = list_first(&p->packages, package_pool)->data;
|
|
krh@37
|
1477 |
}
|
|
krh@37
|
1478 |
}
|
|
krh@37
|
1479 |
}
|
|
krh@37
|
1480 |
|
|
krh@38
|
1481 |
static void
|
|
krh@38
|
1482 |
find_packages(struct razor_set *set,
|
|
krh@105
|
1483 |
int count, const char **package_names, struct array *list)
|
|
krh@38
|
1484 |
{
|
|
krh@105
|
1485 |
struct razor_package_iterator *pi;
|
|
krh@105
|
1486 |
struct razor_package *p, *packages;
|
|
krh@105
|
1487 |
const char *name, *version;
|
|
danw@108
|
1488 |
uint32_t *r;
|
|
krh@38
|
1489 |
int i;
|
|
krh@38
|
1490 |
|
|
krh@105
|
1491 |
packages = (struct razor_package *) set->packages.data;
|
|
krh@105
|
1492 |
pi = razor_package_iterator_create(set);
|
|
krh@105
|
1493 |
|
|
krh@105
|
1494 |
while (razor_package_iterator_next(pi, &p, &name, &version)) {
|
|
krh@105
|
1495 |
for (i = 0; i < count; i++) {
|
|
krh@105
|
1496 |
if (strcmp(name, package_names[i]) == 0) {
|
|
krh@105
|
1497 |
r = array_add(list, sizeof *r);
|
|
krh@105
|
1498 |
*r = p - packages;
|
|
krh@105
|
1499 |
break;
|
|
krh@105
|
1500 |
}
|
|
krh@105
|
1501 |
}
|
|
krh@38
|
1502 |
}
|
|
krh@105
|
1503 |
|
|
krh@105
|
1504 |
razor_package_iterator_destroy(pi);
|
|
krh@38
|
1505 |
}
|
|
krh@38
|
1506 |
|
|
krh@38
|
1507 |
static void
|
|
krh@38
|
1508 |
find_all_packages(struct razor_set *set,
|
|
krh@38
|
1509 |
struct razor_set *upstream, struct array *list)
|
|
krh@38
|
1510 |
{
|
|
krh@38
|
1511 |
struct razor_package *p, *u, *pend, *uend;
|
|
danw@108
|
1512 |
uint32_t *r;
|
|
krh@38
|
1513 |
char *pool, *upool;
|
|
krh@38
|
1514 |
|
|
krh@38
|
1515 |
pend = set->packages.data + set->packages.size;
|
|
krh@38
|
1516 |
pool = set->string_pool.data;
|
|
krh@38
|
1517 |
u = upstream->packages.data;
|
|
krh@38
|
1518 |
uend = upstream->packages.data + upstream->packages.size;
|
|
krh@38
|
1519 |
upool = upstream->string_pool.data;
|
|
krh@38
|
1520 |
|
|
krh@38
|
1521 |
for (p = set->packages.data; p < pend; p++) {
|
|
krh@38
|
1522 |
while (u < uend && strcmp(&pool[p->name], &upool[u->name]) > 0)
|
|
krh@38
|
1523 |
u++;
|
|
krh@38
|
1524 |
if (strcmp(&pool[p->name], &upool[u->name]) == 0) {
|
|
krh@38
|
1525 |
r = array_add(list, sizeof *r);
|
|
krh@38
|
1526 |
*r = u - (struct razor_package *) upstream->packages.data;
|
|
krh@38
|
1527 |
}
|
|
krh@38
|
1528 |
}
|
|
krh@38
|
1529 |
}
|
|
krh@38
|
1530 |
|
|
krh@33
|
1531 |
struct razor_set *
|
|
krh@33
|
1532 |
razor_set_update(struct razor_set *set, struct razor_set *upstream,
|
|
krh@33
|
1533 |
int count, const char **packages)
|
|
krh@33
|
1534 |
{
|
|
krh@37
|
1535 |
struct razor_set *new;
|
|
krh@43
|
1536 |
struct razor_package *upackages;
|
|
krh@37
|
1537 |
struct array list, unsatisfied;
|
|
krh@37
|
1538 |
char *pool;
|
|
danw@108
|
1539 |
uint32_t *u, *end;
|
|
krh@38
|
1540 |
int total = 0;
|
|
krh@33
|
1541 |
|
|
krh@33
|
1542 |
array_init(&list);
|
|
krh@38
|
1543 |
if (count > 0)
|
|
krh@38
|
1544 |
find_packages(upstream, count, packages, &list);
|
|
krh@38
|
1545 |
else
|
|
krh@38
|
1546 |
find_all_packages(set, upstream, &list);
|
|
krh@33
|
1547 |
|
|
krh@37
|
1548 |
end = list.data + list.size;
|
|
krh@37
|
1549 |
upackages = upstream->packages.data;
|
|
krh@37
|
1550 |
pool = upstream->string_pool.data;
|
|
krh@38
|
1551 |
total += list.size / sizeof *u;
|
|
krh@37
|
1552 |
|
|
krh@37
|
1553 |
while (list.size > 0) {
|
|
krh@37
|
1554 |
new = razor_set_add(set, upstream, &list);
|
|
krh@37
|
1555 |
array_release(&list);
|
|
krh@37
|
1556 |
razor_set_destroy(set);
|
|
krh@37
|
1557 |
set = new;
|
|
krh@37
|
1558 |
|
|
krh@37
|
1559 |
array_init(&unsatisfied);
|
|
krh@37
|
1560 |
razor_set_validate(new, &unsatisfied);
|
|
krh@37
|
1561 |
array_init(&list);
|
|
krh@37
|
1562 |
razor_set_satisfy(new, &unsatisfied, upstream, &list);
|
|
krh@37
|
1563 |
array_release(&unsatisfied);
|
|
krh@37
|
1564 |
|
|
krh@37
|
1565 |
end = list.data + list.size;
|
|
krh@37
|
1566 |
upackages = upstream->packages.data;
|
|
krh@37
|
1567 |
pool = upstream->string_pool.data;
|
|
krh@38
|
1568 |
total += list.size / sizeof *u;
|
|
krh@37
|
1569 |
}
|
|
krh@37
|
1570 |
|
|
krh@37
|
1571 |
array_release(&list);
|
|
krh@37
|
1572 |
|
|
krh@37
|
1573 |
return set;
|
|
krh@33
|
1574 |
}
|
|
krh@33
|
1575 |
|
|
krh@44
|
1576 |
/* The diff order matters. We should sort the packages so that a
|
|
krh@44
|
1577 |
* REMOVE of a package comes before the INSTALL, and so that all
|
|
krh@44
|
1578 |
* requires for a package have been installed before the package.
|
|
krh@44
|
1579 |
**/
|
|
krh@44
|
1580 |
|
|
krh@44
|
1581 |
void
|
|
krh@44
|
1582 |
razor_set_diff(struct razor_set *set, struct razor_set *upstream,
|
|
krh@44
|
1583 |
razor_package_callback_t callback, void *data)
|
|
krh@44
|
1584 |
{
|
|
krh@103
|
1585 |
struct razor_package_iterator *pi1, *pi2;
|
|
krh@103
|
1586 |
struct razor_package *p1, *p2;
|
|
krh@103
|
1587 |
const char *name1, *name2, *version1, *version2;
|
|
krh@106
|
1588 |
int res;
|
|
krh@44
|
1589 |
|
|
krh@103
|
1590 |
pi1 = razor_package_iterator_create(set);
|
|
krh@103
|
1591 |
pi2 = razor_package_iterator_create(upstream);
|
|
krh@44
|
1592 |
|
|
krh@103
|
1593 |
razor_package_iterator_next(pi1, &p1, &name1, &version1);
|
|
krh@103
|
1594 |
razor_package_iterator_next(pi2, &p2, &name2, &version2);
|
|
krh@44
|
1595 |
|
|
krh@103
|
1596 |
while (p1 || p2) {
|
|
krh@103
|
1597 |
if (p1 && p2) {
|
|
krh@103
|
1598 |
res = strcmp(name1, name2);
|
|
krh@44
|
1599 |
if (res == 0)
|
|
krh@103
|
1600 |
res = versioncmp(version1, version2);
|
|
krh@106
|
1601 |
} else {
|
|
krh@106
|
1602 |
res = 0;
|
|
krh@44
|
1603 |
}
|
|
krh@44
|
1604 |
|
|
krh@103
|
1605 |
if (p2 == NULL || res < 0)
|
|
krh@103
|
1606 |
callback(name1, version1, NULL, data);
|
|
krh@103
|
1607 |
else if (p1 == NULL || res > 0)
|
|
krh@103
|
1608 |
callback(name2, NULL, version2, data);
|
|
krh@103
|
1609 |
|
|
krh@103
|
1610 |
if (p1 != NULL && res <= 0)
|
|
krh@103
|
1611 |
razor_package_iterator_next(pi1, &p1,
|
|
krh@103
|
1612 |
&name1, &version1);
|
|
krh@103
|
1613 |
if (p2 != NULL && res >= 0)
|
|
krh@103
|
1614 |
razor_package_iterator_next(pi2, &p2,
|
|
krh@103
|
1615 |
&name2, &version2);
|
|
krh@44
|
1616 |
}
|
|
krh@103
|
1617 |
|
|
krh@103
|
1618 |
razor_package_iterator_destroy(pi1);
|
|
krh@103
|
1619 |
razor_package_iterator_destroy(pi2);
|
|
krh@44
|
1620 |
}
|