diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-22 18:32:40 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-22 18:32:40 +0000 |
commit | a6df5907d273f0fe067e82c60391d6bf9a02dd4b (patch) | |
tree | f8e7b8ddb37709e1e0f7288a35467bd800d75fbc | |
parent | e31f721e140a7bb2377f1c1b09715f1bcbf9ec7a (diff) | |
download | busybox-w32-a6df5907d273f0fe067e82c60391d6bf9a02dd4b.tar.gz busybox-w32-a6df5907d273f0fe067e82c60391d6bf9a02dd4b.tar.bz2 busybox-w32-a6df5907d273f0fe067e82c60391d6bf9a02dd4b.zip |
dpkg: getopt32-ification etc, -100 bytes
-rw-r--r-- | archival/dpkg.c | 393 |
1 files changed, 170 insertions, 223 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index 6ef04522d..3ff6249d9 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -34,7 +34,7 @@ | |||
34 | * 3) all _hash_prime's must be a prime number or chaos is assured, if your looking | 34 | * 3) all _hash_prime's must be a prime number or chaos is assured, if your looking |
35 | * for a prime, try http://www.utm.edu/research/primes/lists/small/10000.txt | 35 | * for a prime, try http://www.utm.edu/research/primes/lists/small/10000.txt |
36 | * 4) if you go bigger than 15 bits you may get into trouble (untested) as its | 36 | * 4) if you go bigger than 15 bits you may get into trouble (untested) as its |
37 | * sometimes cast to an unsigned int, if you go to 16 bit you will overlap | 37 | * sometimes cast to an unsigned, if you go to 16 bit you will overlap |
38 | * int's and chaos is assured, 16381 is the max prime for 14 bit field | 38 | * int's and chaos is assured, 16381 is the max prime for 14 bit field |
39 | */ | 39 | */ |
40 | 40 | ||
@@ -53,16 +53,16 @@ | |||
53 | * and available file */ | 53 | * and available file */ |
54 | #define PACKAGE_HASH_PRIME 10007 | 54 | #define PACKAGE_HASH_PRIME 10007 |
55 | typedef struct edge_s { | 55 | typedef struct edge_s { |
56 | unsigned int operator:3; | 56 | unsigned operator:3; |
57 | unsigned int type:4; | 57 | unsigned type:4; |
58 | unsigned int name:14; | 58 | unsigned name:14; |
59 | unsigned int version:14; | 59 | unsigned version:14; |
60 | } edge_t; | 60 | } edge_t; |
61 | 61 | ||
62 | typedef struct common_node_s { | 62 | typedef struct common_node_s { |
63 | unsigned int name:14; | 63 | unsigned name:14; |
64 | unsigned int version:14; | 64 | unsigned version:14; |
65 | unsigned int num_of_edges:14; | 65 | unsigned num_of_edges:14; |
66 | edge_t **edge; | 66 | edge_t **edge; |
67 | } common_node_t; | 67 | } common_node_t; |
68 | 68 | ||
@@ -71,8 +71,8 @@ typedef struct common_node_s { | |||
71 | * likely to be installed at any one time, so there is a bit of leeway here */ | 71 | * likely to be installed at any one time, so there is a bit of leeway here */ |
72 | #define STATUS_HASH_PRIME 8191 | 72 | #define STATUS_HASH_PRIME 8191 |
73 | typedef struct status_node_s { | 73 | typedef struct status_node_s { |
74 | unsigned int package:14; /* has to fit PACKAGE_HASH_PRIME */ | 74 | unsigned package:14; /* has to fit PACKAGE_HASH_PRIME */ |
75 | unsigned int status:14; /* has to fit STATUS_HASH_PRIME */ | 75 | unsigned status:14; /* has to fit STATUS_HASH_PRIME */ |
76 | } status_node_t; | 76 | } status_node_t; |
77 | 77 | ||
78 | /* Were statically declared here, but such a big bss is nommu-unfriendly */ | 78 | /* Were statically declared here, but such a big bss is nommu-unfriendly */ |
@@ -104,26 +104,14 @@ enum operator_e { | |||
104 | VER_ANY = 6 | 104 | VER_ANY = 6 |
105 | }; | 105 | }; |
106 | 106 | ||
107 | enum dpkg_opt_e { | ||
108 | dpkg_opt_purge = 1, | ||
109 | dpkg_opt_remove = 2, | ||
110 | dpkg_opt_unpack = 4, | ||
111 | dpkg_opt_configure = 8, | ||
112 | dpkg_opt_install = 16, | ||
113 | dpkg_opt_package_name = 32, | ||
114 | dpkg_opt_filename = 64, | ||
115 | dpkg_opt_list_installed = 128, | ||
116 | dpkg_opt_force_ignore_depends = 256 | ||
117 | }; | ||
118 | |||
119 | typedef struct deb_file_s { | 107 | typedef struct deb_file_s { |
120 | char *control_file; | 108 | char *control_file; |
121 | char *filename; | 109 | char *filename; |
122 | unsigned int package:14; | 110 | unsigned package:14; |
123 | } deb_file_t; | 111 | } deb_file_t; |
124 | 112 | ||
125 | 113 | ||
126 | static void make_hash(const char *key, unsigned int *start, unsigned int *decrement, const int hash_prime) | 114 | static void make_hash(const char *key, unsigned *start, unsigned *decrement, const int hash_prime) |
127 | { | 115 | { |
128 | unsigned long int hash_num = key[0]; | 116 | unsigned long int hash_num = key[0]; |
129 | int len = strlen(key); | 117 | int len = strlen(key); |
@@ -138,26 +126,24 @@ static void make_hash(const char *key, unsigned int *start, unsigned int *decrem | |||
138 | * no effect*/ | 126 | * no effect*/ |
139 | hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24)); | 127 | hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24)); |
140 | } | 128 | } |
141 | *start = (unsigned int) hash_num % hash_prime; | 129 | *start = (unsigned) hash_num % hash_prime; |
142 | *decrement = (unsigned int) 1 + (hash_num % (hash_prime - 1)); | 130 | *decrement = (unsigned) 1 + (hash_num % (hash_prime - 1)); |
143 | } | 131 | } |
144 | 132 | ||
145 | /* this adds the key to the hash table */ | 133 | /* this adds the key to the hash table */ |
146 | static int search_name_hashtable(const char *key) | 134 | static int search_name_hashtable(const char *key) |
147 | { | 135 | { |
148 | unsigned int probe_address = 0; | 136 | unsigned probe_address = 0; |
149 | unsigned int probe_decrement = 0; | 137 | unsigned probe_decrement = 0; |
150 | // char *temp; | ||
151 | 138 | ||
152 | make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME); | 139 | make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME); |
153 | while (name_hashtable[probe_address] != NULL) { | 140 | while (name_hashtable[probe_address] != NULL) { |
154 | if (strcmp(name_hashtable[probe_address], key) == 0) { | 141 | if (strcmp(name_hashtable[probe_address], key) == 0) { |
155 | return probe_address; | 142 | return probe_address; |
156 | } else { | 143 | } |
157 | probe_address -= probe_decrement; | 144 | probe_address -= probe_decrement; |
158 | if ((int)probe_address < 0) { | 145 | if ((int)probe_address < 0) { |
159 | probe_address += NAME_HASH_PRIME; | 146 | probe_address += NAME_HASH_PRIME; |
160 | } | ||
161 | } | 147 | } |
162 | } | 148 | } |
163 | name_hashtable[probe_address] = xstrdup(key); | 149 | name_hashtable[probe_address] = xstrdup(key); |
@@ -167,20 +153,19 @@ static int search_name_hashtable(const char *key) | |||
167 | /* this DOESNT add the key to the hashtable | 153 | /* this DOESNT add the key to the hashtable |
168 | * TODO make it consistent with search_name_hashtable | 154 | * TODO make it consistent with search_name_hashtable |
169 | */ | 155 | */ |
170 | static unsigned int search_status_hashtable(const char *key) | 156 | static unsigned search_status_hashtable(const char *key) |
171 | { | 157 | { |
172 | unsigned int probe_address = 0; | 158 | unsigned probe_address = 0; |
173 | unsigned int probe_decrement = 0; | 159 | unsigned probe_decrement = 0; |
174 | 160 | ||
175 | make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME); | 161 | make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME); |
176 | while (status_hashtable[probe_address] != NULL) { | 162 | while (status_hashtable[probe_address] != NULL) { |
177 | if (strcmp(key, name_hashtable[package_hashtable[status_hashtable[probe_address]->package]->name]) == 0) { | 163 | if (strcmp(key, name_hashtable[package_hashtable[status_hashtable[probe_address]->package]->name]) == 0) { |
178 | break; | 164 | break; |
179 | } else { | 165 | } |
180 | probe_address -= probe_decrement; | 166 | probe_address -= probe_decrement; |
181 | if ((int)probe_address < 0) { | 167 | if ((int)probe_address < 0) { |
182 | probe_address += STATUS_HASH_PRIME; | 168 | probe_address += STATUS_HASH_PRIME; |
183 | } | ||
184 | } | 169 | } |
185 | } | 170 | } |
186 | return probe_address; | 171 | return probe_address; |
@@ -198,7 +183,6 @@ static int version_compare_part(const char *version1, const char *version2) | |||
198 | int tmp_int; | 183 | int tmp_int; |
199 | int ver_num1; | 184 | int ver_num1; |
200 | int ver_num2; | 185 | int ver_num2; |
201 | int ret; | ||
202 | 186 | ||
203 | if (version1 == NULL) { | 187 | if (version1 == NULL) { |
204 | version1 = xstrdup(""); | 188 | version1 = xstrdup(""); |
@@ -221,8 +205,7 @@ static int version_compare_part(const char *version1, const char *version2) | |||
221 | free(name1_char); | 205 | free(name1_char); |
222 | free(name2_char); | 206 | free(name2_char); |
223 | if (tmp_int != 0) { | 207 | if (tmp_int != 0) { |
224 | ret = tmp_int; | 208 | return tmp_int; |
225 | goto cleanup_version_compare_part; | ||
226 | } | 209 | } |
227 | 210 | ||
228 | /* Compare digits */ | 211 | /* Compare digits */ |
@@ -237,24 +220,20 @@ static int version_compare_part(const char *version1, const char *version2) | |||
237 | free(name1_char); | 220 | free(name1_char); |
238 | free(name2_char); | 221 | free(name2_char); |
239 | if (ver_num1 < ver_num2) { | 222 | if (ver_num1 < ver_num2) { |
240 | ret = -1; | 223 | return -1; |
241 | goto cleanup_version_compare_part; | ||
242 | } | 224 | } |
243 | else if (ver_num1 > ver_num2) { | 225 | if (ver_num1 > ver_num2) { |
244 | ret = 1; | 226 | return 1; |
245 | goto cleanup_version_compare_part; | ||
246 | } | 227 | } |
247 | } | 228 | } |
248 | ret = 0; | 229 | return 0; |
249 | cleanup_version_compare_part: | ||
250 | return ret; | ||
251 | } | 230 | } |
252 | 231 | ||
253 | /* if ver1 < ver2 return -1, | 232 | /* if ver1 < ver2 return -1, |
254 | * if ver1 = ver2 return 0, | 233 | * if ver1 = ver2 return 0, |
255 | * if ver1 > ver2 return 1, | 234 | * if ver1 > ver2 return 1, |
256 | */ | 235 | */ |
257 | static int version_compare(const unsigned int ver1, const unsigned int ver2) | 236 | static int version_compare(const unsigned ver1, const unsigned ver2) |
258 | { | 237 | { |
259 | char *ch_ver1 = name_hashtable[ver1]; | 238 | char *ch_ver1 = name_hashtable[ver1]; |
260 | char *ch_ver2 = name_hashtable[ver2]; | 239 | char *ch_ver2 = name_hashtable[ver2]; |
@@ -313,46 +292,31 @@ static int version_compare(const unsigned int ver1, const unsigned int ver2) | |||
313 | return result; | 292 | return result; |
314 | } | 293 | } |
315 | 294 | ||
316 | static int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator) | 295 | static int test_version(const unsigned version1, const unsigned version2, const unsigned operator) |
317 | { | 296 | { |
318 | const int version_result = version_compare(version1, version2); | 297 | const int version_result = version_compare(version1, version2); |
319 | switch (operator) { | 298 | switch (operator) { |
320 | case VER_ANY: | 299 | case VER_ANY: |
321 | return TRUE; | 300 | return TRUE; |
322 | case VER_EQUAL: | 301 | case VER_EQUAL: |
323 | if (version_result == 0) { | 302 | return (version_result == 0); |
324 | return TRUE; | 303 | case VER_LESS: |
325 | } | 304 | return (version_result < 0); |
326 | break; | 305 | case VER_LESS_EQUAL: |
327 | case VER_LESS: | 306 | return (version_result <= 0); |
328 | if (version_result < 0) { | 307 | case VER_MORE: |
329 | return TRUE; | 308 | return (version_result > 0); |
330 | } | 309 | case VER_MORE_EQUAL: |
331 | break; | 310 | return (version_result >= 0); |
332 | case VER_LESS_EQUAL: | ||
333 | if (version_result <= 0) { | ||
334 | return TRUE; | ||
335 | } | ||
336 | break; | ||
337 | case VER_MORE: | ||
338 | if (version_result > 0) { | ||
339 | return TRUE; | ||
340 | } | ||
341 | break; | ||
342 | case VER_MORE_EQUAL: | ||
343 | if (version_result >= 0) { | ||
344 | return TRUE; | ||
345 | } | ||
346 | break; | ||
347 | } | 311 | } |
348 | return FALSE; | 312 | return FALSE; |
349 | } | 313 | } |
350 | 314 | ||
351 | 315 | ||
352 | static int search_package_hashtable(const unsigned int name, const unsigned int version, const unsigned int operator) | 316 | static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator) |
353 | { | 317 | { |
354 | unsigned int probe_address = 0; | 318 | unsigned probe_address = 0; |
355 | unsigned int probe_decrement = 0; | 319 | unsigned probe_decrement = 0; |
356 | 320 | ||
357 | make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME); | 321 | make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME); |
358 | while (package_hashtable[probe_address] != NULL) { | 322 | while (package_hashtable[probe_address] != NULL) { |
@@ -393,7 +357,8 @@ static int search_for_provides(int needle, int start_at) { | |||
393 | common_node_t *p; | 357 | common_node_t *p; |
394 | for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) { | 358 | for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) { |
395 | p = package_hashtable[i]; | 359 | p = package_hashtable[i]; |
396 | if (p == NULL) continue; | 360 | if (p == NULL) |
361 | continue; | ||
397 | for (j = 0; j < p->num_of_edges; j++) | 362 | for (j = 0; j < p->num_of_edges; j++) |
398 | if (p->edge[j]->type == EDGE_PROVIDES && p->edge[j]->name == needle) | 363 | if (p->edge[j]->type == EDGE_PROVIDES && p->edge[j]->name == needle) |
399 | return i; | 364 | return i; |
@@ -421,7 +386,7 @@ static void add_edge_to_node(common_node_t *node, edge_t *edge) | |||
421 | * field contains the number of EDGE nodes which follow as part of | 386 | * field contains the number of EDGE nodes which follow as part of |
422 | * this alternative. | 387 | * this alternative. |
423 | */ | 388 | */ |
424 | static void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type) | 389 | static void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned edge_type) |
425 | { | 390 | { |
426 | char *line = xstrdup(whole_line); | 391 | char *line = xstrdup(whole_line); |
427 | char *line2; | 392 | char *line2; |
@@ -440,18 +405,14 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole | |||
440 | field += strspn(field, " "); | 405 | field += strspn(field, " "); |
441 | line2 = xstrdup(field); | 406 | line2 = xstrdup(field); |
442 | field2 = strtok_r(line2, "|", &line_ptr2); | 407 | field2 = strtok_r(line2, "|", &line_ptr2); |
443 | if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS) && | 408 | or_edge = NULL; |
444 | (strcmp(field, field2) != 0)) { | 409 | if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS) |
410 | && (strcmp(field, field2) != 0) | ||
411 | ) { | ||
445 | or_edge = xmalloc(sizeof(edge_t)); | 412 | or_edge = xmalloc(sizeof(edge_t)); |
446 | or_edge->type = edge_type + 1; | 413 | or_edge->type = edge_type + 1; |
447 | } else { | ||
448 | or_edge = NULL; | ||
449 | } | ||
450 | |||
451 | if (or_edge) { | ||
452 | or_edge->name = search_name_hashtable(field); | 414 | or_edge->name = search_name_hashtable(field); |
453 | or_edge->version = 0; // tracks the number of altenatives | 415 | or_edge->version = 0; // tracks the number of altenatives |
454 | |||
455 | add_edge_to_node(parent_node, or_edge); | 416 | add_edge_to_node(parent_node, or_edge); |
456 | } | 417 | } |
457 | 418 | ||
@@ -470,8 +431,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole | |||
470 | edge->version = search_name_hashtable("ANY"); | 431 | edge->version = search_name_hashtable("ANY"); |
471 | } else { | 432 | } else { |
472 | /* Skip leading ' ' or '(' */ | 433 | /* Skip leading ' ' or '(' */ |
473 | version += strspn(field2, " "); | 434 | version += strspn(field2, " ("); |
474 | version += strspn(version, "("); | ||
475 | /* Calculate length of any operator characters */ | 435 | /* Calculate length of any operator characters */ |
476 | offset_ch = strspn(version, "<=>"); | 436 | offset_ch = strspn(version, "<=>"); |
477 | /* Determine operator */ | 437 | /* Determine operator */ |
@@ -516,8 +476,6 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole | |||
516 | free(line2); | 476 | free(line2); |
517 | } while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL); | 477 | } while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL); |
518 | free(line); | 478 | free(line); |
519 | |||
520 | return; | ||
521 | } | 479 | } |
522 | 480 | ||
523 | static void free_package(common_node_t *node) | 481 | static void free_package(common_node_t *node) |
@@ -606,20 +564,18 @@ static int read_package_field(const char *package_buffer, char **field_name, cha | |||
606 | } | 564 | } |
607 | offset++; | 565 | offset++; |
608 | } | 566 | } |
609 | if (name_length == 0) { | 567 | *field_name = NULL; |
610 | *field_name = NULL; | 568 | if (name_length) { |
611 | } else { | ||
612 | *field_name = xstrndup(&package_buffer[offset_name_start], name_length); | 569 | *field_name = xstrndup(&package_buffer[offset_name_start], name_length); |
613 | } | 570 | } |
571 | *field_value = NULL; | ||
614 | if (value_length > 0) { | 572 | if (value_length > 0) { |
615 | *field_value = xstrndup(&package_buffer[offset_value_start], value_length); | 573 | *field_value = xstrndup(&package_buffer[offset_value_start], value_length); |
616 | } else { | ||
617 | *field_value = NULL; | ||
618 | } | 574 | } |
619 | return next_offset; | 575 | return next_offset; |
620 | } | 576 | } |
621 | 577 | ||
622 | static unsigned int fill_package_struct(char *control_buffer) | 578 | static unsigned fill_package_struct(char *control_buffer) |
623 | { | 579 | { |
624 | static const char *const field_names[] = { "Package", "Version", | 580 | static const char *const field_names[] = { "Package", "Version", |
625 | "Pre-Depends", "Depends","Replaces", "Provides", | 581 | "Pre-Depends", "Depends","Replaces", "Provides", |
@@ -646,38 +602,38 @@ static unsigned int fill_package_struct(char *control_buffer) | |||
646 | 602 | ||
647 | field_num = index_in_str_array(field_names, field_name); | 603 | field_num = index_in_str_array(field_names, field_name); |
648 | switch (field_num) { | 604 | switch (field_num) { |
649 | case 0: /* Package */ | 605 | case 0: /* Package */ |
650 | new_node->name = search_name_hashtable(field_value); | 606 | new_node->name = search_name_hashtable(field_value); |
651 | break; | 607 | break; |
652 | case 1: /* Version */ | 608 | case 1: /* Version */ |
653 | new_node->version = search_name_hashtable(field_value); | 609 | new_node->version = search_name_hashtable(field_value); |
654 | break; | 610 | break; |
655 | case 2: /* Pre-Depends */ | 611 | case 2: /* Pre-Depends */ |
656 | add_split_dependencies(new_node, field_value, EDGE_PRE_DEPENDS); | 612 | add_split_dependencies(new_node, field_value, EDGE_PRE_DEPENDS); |
657 | break; | 613 | break; |
658 | case 3: /* Depends */ | 614 | case 3: /* Depends */ |
659 | add_split_dependencies(new_node, field_value, EDGE_DEPENDS); | 615 | add_split_dependencies(new_node, field_value, EDGE_DEPENDS); |
660 | break; | 616 | break; |
661 | case 4: /* Replaces */ | 617 | case 4: /* Replaces */ |
662 | add_split_dependencies(new_node, field_value, EDGE_REPLACES); | 618 | add_split_dependencies(new_node, field_value, EDGE_REPLACES); |
663 | break; | 619 | break; |
664 | case 5: /* Provides */ | 620 | case 5: /* Provides */ |
665 | add_split_dependencies(new_node, field_value, EDGE_PROVIDES); | 621 | add_split_dependencies(new_node, field_value, EDGE_PROVIDES); |
666 | break; | 622 | break; |
667 | case 6: /* Conflicts */ | 623 | case 6: /* Conflicts */ |
668 | add_split_dependencies(new_node, field_value, EDGE_CONFLICTS); | 624 | add_split_dependencies(new_node, field_value, EDGE_CONFLICTS); |
669 | break; | 625 | break; |
670 | case 7: /* Suggests */ | 626 | case 7: /* Suggests */ |
671 | add_split_dependencies(new_node, field_value, EDGE_SUGGESTS); | 627 | add_split_dependencies(new_node, field_value, EDGE_SUGGESTS); |
672 | break; | 628 | break; |
673 | case 8: /* Recommends */ | 629 | case 8: /* Recommends */ |
674 | add_split_dependencies(new_node, field_value, EDGE_RECOMMENDS); | 630 | add_split_dependencies(new_node, field_value, EDGE_RECOMMENDS); |
675 | break; | 631 | break; |
676 | case 9: /* Enhances */ | 632 | case 9: /* Enhances */ |
677 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); | 633 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); |
678 | break; | 634 | break; |
679 | } | 635 | } |
680 | fill_package_struct_cleanup: | 636 | fill_package_struct_cleanup: |
681 | free(field_name); | 637 | free(field_name); |
682 | free(field_value); | 638 | free(field_value); |
683 | } | 639 | } |
@@ -696,11 +652,11 @@ fill_package_struct_cleanup: | |||
696 | } | 652 | } |
697 | 653 | ||
698 | /* if num = 1, it returns the want status, 2 returns flag, 3 returns status */ | 654 | /* if num = 1, it returns the want status, 2 returns flag, 3 returns status */ |
699 | static unsigned int get_status(const unsigned int status_node, const int num) | 655 | static unsigned get_status(const unsigned status_node, const int num) |
700 | { | 656 | { |
701 | char *status_string = name_hashtable[status_hashtable[status_node]->status]; | 657 | char *status_string = name_hashtable[status_hashtable[status_node]->status]; |
702 | char *state_sub_string; | 658 | char *state_sub_string; |
703 | unsigned int state_sub_num; | 659 | unsigned state_sub_num; |
704 | int len; | 660 | int len; |
705 | int i; | 661 | int i; |
706 | 662 | ||
@@ -718,13 +674,13 @@ static unsigned int get_status(const unsigned int status_node, const int num) | |||
718 | return state_sub_num; | 674 | return state_sub_num; |
719 | } | 675 | } |
720 | 676 | ||
721 | static void set_status(const unsigned int status_node_num, const char *new_value, const int position) | 677 | static void set_status(const unsigned status_node_num, const char *new_value, const int position) |
722 | { | 678 | { |
723 | const unsigned int new_value_len = strlen(new_value); | 679 | const unsigned new_value_len = strlen(new_value); |
724 | const unsigned int new_value_num = search_name_hashtable(new_value); | 680 | const unsigned new_value_num = search_name_hashtable(new_value); |
725 | unsigned int want = get_status(status_node_num, 1); | 681 | unsigned want = get_status(status_node_num, 1); |
726 | unsigned int flag = get_status(status_node_num, 2); | 682 | unsigned flag = get_status(status_node_num, 2); |
727 | unsigned int status = get_status(status_node_num, 3); | 683 | unsigned status = get_status(status_node_num, 3); |
728 | int want_len = strlen(name_hashtable[want]); | 684 | int want_len = strlen(name_hashtable[want]); |
729 | int flag_len = strlen(name_hashtable[flag]); | 685 | int flag_len = strlen(name_hashtable[flag]); |
730 | int status_len = strlen(name_hashtable[status]); | 686 | int status_len = strlen(name_hashtable[status]); |
@@ -784,11 +740,11 @@ static void index_status_file(const char *filename) | |||
784 | char *control_buffer; | 740 | char *control_buffer; |
785 | char *status_line; | 741 | char *status_line; |
786 | status_node_t *status_node = NULL; | 742 | status_node_t *status_node = NULL; |
787 | unsigned int status_num; | 743 | unsigned status_num; |
788 | 744 | ||
789 | status_file = xfopen(filename, "r"); | 745 | status_file = xfopen(filename, "r"); |
790 | while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) { | 746 | while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) { |
791 | const unsigned int package_num = fill_package_struct(control_buffer); | 747 | const unsigned package_num = fill_package_struct(control_buffer); |
792 | if (package_num != -1) { | 748 | if (package_num != -1) { |
793 | status_node = xmalloc(sizeof(status_node_t)); | 749 | status_node = xmalloc(sizeof(status_node_t)); |
794 | /* fill_package_struct doesnt handle the status field */ | 750 | /* fill_package_struct doesnt handle the status field */ |
@@ -1012,7 +968,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count) | |||
1012 | /* Create array of package numbers to check against | 968 | /* Create array of package numbers to check against |
1013 | * installed package for conflicts*/ | 969 | * installed package for conflicts*/ |
1014 | while (deb_file[i] != NULL) { | 970 | while (deb_file[i] != NULL) { |
1015 | const unsigned int package_num = deb_file[i]->package; | 971 | const unsigned package_num = deb_file[i]->package; |
1016 | conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); | 972 | conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); |
1017 | conflicts[conflicts_num] = package_num; | 973 | conflicts[conflicts_num] = package_num; |
1018 | conflicts_num++; | 974 | conflicts_num++; |
@@ -1054,7 +1010,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count) | |||
1054 | const edge_t *package_edge = package_node->edge[j]; | 1010 | const edge_t *package_edge = package_node->edge[j]; |
1055 | 1011 | ||
1056 | if (package_edge->type == EDGE_CONFLICTS) { | 1012 | if (package_edge->type == EDGE_CONFLICTS) { |
1057 | const unsigned int package_num = | 1013 | const unsigned package_num = |
1058 | search_package_hashtable(package_edge->name, | 1014 | search_package_hashtable(package_edge->name, |
1059 | package_edge->version, | 1015 | package_edge->version, |
1060 | package_edge->operator); | 1016 | package_edge->operator); |
@@ -1113,7 +1069,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count) | |||
1113 | */ | 1069 | */ |
1114 | for (j = 0; j < package_node->num_of_edges; j++) { | 1070 | for (j = 0; j < package_node->num_of_edges; j++) { |
1115 | const edge_t *package_edge = package_node->edge[j]; | 1071 | const edge_t *package_edge = package_node->edge[j]; |
1116 | unsigned int package_num; | 1072 | unsigned package_num; |
1117 | 1073 | ||
1118 | if (package_edge->type == EDGE_OR_PRE_DEPENDS || | 1074 | if (package_edge->type == EDGE_OR_PRE_DEPENDS || |
1119 | package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */ | 1075 | package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */ |
@@ -1346,11 +1302,11 @@ static void list_packages(void) | |||
1346 | } | 1302 | } |
1347 | } | 1303 | } |
1348 | 1304 | ||
1349 | static void remove_package(const unsigned int package_num, int noisy) | 1305 | static void remove_package(const unsigned package_num, int noisy) |
1350 | { | 1306 | { |
1351 | const char *package_name = name_hashtable[package_hashtable[package_num]->name]; | 1307 | const char *package_name = name_hashtable[package_hashtable[package_num]->name]; |
1352 | const char *package_version = name_hashtable[package_hashtable[package_num]->version]; | 1308 | const char *package_version = name_hashtable[package_hashtable[package_num]->version]; |
1353 | const unsigned int status_num = search_status_hashtable(package_name); | 1309 | const unsigned status_num = search_status_hashtable(package_name); |
1354 | const int package_name_length = strlen(package_name); | 1310 | const int package_name_length = strlen(package_name); |
1355 | char **remove_files; | 1311 | char **remove_files; |
1356 | char **exclude_files; | 1312 | char **exclude_files; |
@@ -1398,11 +1354,11 @@ static void remove_package(const unsigned int package_num, int noisy) | |||
1398 | set_status(status_num, "config-files", 3); | 1354 | set_status(status_num, "config-files", 3); |
1399 | } | 1355 | } |
1400 | 1356 | ||
1401 | static void purge_package(const unsigned int package_num) | 1357 | static void purge_package(const unsigned package_num) |
1402 | { | 1358 | { |
1403 | const char *package_name = name_hashtable[package_hashtable[package_num]->name]; | 1359 | const char *package_name = name_hashtable[package_hashtable[package_num]->name]; |
1404 | const char *package_version = name_hashtable[package_hashtable[package_num]->version]; | 1360 | const char *package_version = name_hashtable[package_hashtable[package_num]->version]; |
1405 | const unsigned int status_num = search_status_hashtable(package_name); | 1361 | const unsigned status_num = search_status_hashtable(package_name); |
1406 | char **remove_files; | 1362 | char **remove_files; |
1407 | char **exclude_files; | 1363 | char **exclude_files; |
1408 | char list_name[strlen(package_name) + 25]; | 1364 | char list_name[strlen(package_name) + 25]; |
@@ -1522,8 +1478,8 @@ static void data_extract_all_prefix(archive_handle_t *archive_handle) | |||
1522 | static void unpack_package(deb_file_t *deb_file) | 1478 | static void unpack_package(deb_file_t *deb_file) |
1523 | { | 1479 | { |
1524 | const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name]; | 1480 | const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name]; |
1525 | const unsigned int status_num = search_status_hashtable(package_name); | 1481 | const unsigned status_num = search_status_hashtable(package_name); |
1526 | const unsigned int status_package_num = status_hashtable[status_num]->package; | 1482 | const unsigned status_package_num = status_hashtable[status_num]->package; |
1527 | char *info_prefix; | 1483 | char *info_prefix; |
1528 | char *list_filename; | 1484 | char *list_filename; |
1529 | archive_handle_t *archive_handle; | 1485 | archive_handle_t *archive_handle; |
@@ -1614,100 +1570,90 @@ int dpkg_main(int argc, char **argv) | |||
1614 | { | 1570 | { |
1615 | deb_file_t **deb_file = NULL; | 1571 | deb_file_t **deb_file = NULL; |
1616 | status_node_t *status_node; | 1572 | status_node_t *status_node; |
1573 | char *str_f; | ||
1617 | int opt; | 1574 | int opt; |
1618 | int package_num; | 1575 | int package_num; |
1619 | int dpkg_opt = 0; | ||
1620 | int deb_count = 0; | 1576 | int deb_count = 0; |
1621 | int state_status; | 1577 | int state_status; |
1622 | int status_num; | 1578 | int status_num; |
1623 | int i; | 1579 | int i; |
1580 | enum { | ||
1581 | OPT_configure = 0x1, | ||
1582 | OPT_force_ignore_depends = 0x2, | ||
1583 | OPT_install = 0x4, | ||
1584 | OPT_list_installed = 0x8, | ||
1585 | OPT_purge = 0x10, | ||
1586 | OPT_remove = 0x20, | ||
1587 | OPT_unpack = 0x40, | ||
1588 | REQ_package_name = 0x8000, | ||
1589 | REQ_filename = 0x4000, | ||
1590 | }; | ||
1624 | 1591 | ||
1625 | name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1)); | 1592 | opt = getopt32(argc, argv, "CF:ilPru", &str_f); |
1626 | package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1)); | 1593 | if (opt & OPT_configure) opt |= REQ_package_name; // -C |
1627 | status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1)); | 1594 | if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg) |
1628 | 1595 | if (strcmp(str_f, "depends")) | |
1629 | while ((opt = getopt(argc, argv, "CF:ilPru")) != -1) { | 1596 | opt &= ~OPT_force_ignore_depends; |
1630 | switch (opt) { | ||
1631 | case 'C': // equivalent to --configure in official dpkg | ||
1632 | dpkg_opt |= dpkg_opt_configure; | ||
1633 | dpkg_opt |= dpkg_opt_package_name; | ||
1634 | break; | ||
1635 | case 'F': // equivalent to --force in official dpkg | ||
1636 | if (strcmp(optarg, "depends") == 0) { | ||
1637 | dpkg_opt |= dpkg_opt_force_ignore_depends; | ||
1638 | } | ||
1639 | break; | ||
1640 | case 'i': | ||
1641 | dpkg_opt |= dpkg_opt_install; | ||
1642 | dpkg_opt |= dpkg_opt_filename; | ||
1643 | break; | ||
1644 | case 'l': | ||
1645 | dpkg_opt |= dpkg_opt_list_installed; | ||
1646 | break; | ||
1647 | case 'P': | ||
1648 | dpkg_opt |= dpkg_opt_purge; | ||
1649 | dpkg_opt |= dpkg_opt_package_name; | ||
1650 | break; | ||
1651 | case 'r': | ||
1652 | dpkg_opt |= dpkg_opt_remove; | ||
1653 | dpkg_opt |= dpkg_opt_package_name; | ||
1654 | break; | ||
1655 | case 'u': /* Equivalent to --unpack in official dpkg */ | ||
1656 | dpkg_opt |= dpkg_opt_unpack; | ||
1657 | dpkg_opt |= dpkg_opt_filename; | ||
1658 | break; | ||
1659 | default: | ||
1660 | bb_show_usage(); | ||
1661 | } | ||
1662 | } | 1597 | } |
1598 | if (opt & OPT_install) opt |= REQ_filename; // -i | ||
1599 | //if (opt & OPT_list_installed) ... // -l | ||
1600 | if (opt & OPT_purge) opt |= REQ_package_name; // -P | ||
1601 | if (opt & OPT_remove) opt |= REQ_package_name; // -r | ||
1602 | if (opt & OPT_unpack) opt |= REQ_filename; // -u (--unpack in official dpkg) | ||
1603 | argc -= optind; | ||
1604 | argv += optind; | ||
1663 | /* check for non-option argument if expected */ | 1605 | /* check for non-option argument if expected */ |
1664 | if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) { | 1606 | if (!opt || (!argc && !(opt && OPT_list_installed))) |
1665 | bb_show_usage(); | 1607 | bb_show_usage(); |
1666 | } | 1608 | |
1609 | name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1)); | ||
1610 | package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1)); | ||
1611 | status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1)); | ||
1667 | 1612 | ||
1668 | /* puts("(Reading database ... xxxxx files and directories installed.)"); */ | 1613 | /* puts("(Reading database ... xxxxx files and directories installed.)"); */ |
1669 | index_status_file("/var/lib/dpkg/status"); | 1614 | index_status_file("/var/lib/dpkg/status"); |
1670 | 1615 | ||
1671 | /* if the list action was given print the installed packages and exit */ | 1616 | /* if the list action was given print the installed packages and exit */ |
1672 | if (dpkg_opt & dpkg_opt_list_installed) { | 1617 | if (opt & OPT_list_installed) { |
1673 | list_packages(); | 1618 | list_packages(); |
1674 | return EXIT_SUCCESS; | 1619 | return EXIT_SUCCESS; |
1675 | } | 1620 | } |
1676 | 1621 | ||
1677 | /* Read arguments and store relevant info in structs */ | 1622 | /* Read arguments and store relevant info in structs */ |
1678 | while (optind < argc) { | 1623 | while (*argv) { |
1679 | /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */ | 1624 | /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */ |
1680 | deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2)); | 1625 | deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2)); |
1681 | deb_file[deb_count] = (deb_file_t *) xzalloc(sizeof(deb_file_t)); | 1626 | deb_file[deb_count] = xzalloc(sizeof(deb_file_t)); |
1682 | if (dpkg_opt & dpkg_opt_filename) { | 1627 | if (opt & REQ_filename) { |
1683 | archive_handle_t *archive_handle; | 1628 | archive_handle_t *archive_handle; |
1684 | llist_t *control_list = NULL; | 1629 | llist_t *control_list = NULL; |
1685 | 1630 | ||
1686 | /* Extract the control file */ | 1631 | /* Extract the control file */ |
1687 | llist_add_to(&control_list, "./control"); | 1632 | llist_add_to(&control_list, "./control"); |
1688 | archive_handle = init_archive_deb_ar(argv[optind]); | 1633 | archive_handle = init_archive_deb_ar(argv[0]); |
1689 | init_archive_deb_control(archive_handle); | 1634 | init_archive_deb_control(archive_handle); |
1690 | deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); | 1635 | deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); |
1691 | if (deb_file[deb_count]->control_file == NULL) { | 1636 | if (deb_file[deb_count]->control_file == NULL) { |
1692 | bb_error_msg_and_die("cannot extract control file"); | 1637 | bb_error_msg_and_die("cannot extract control file"); |
1693 | } | 1638 | } |
1694 | deb_file[deb_count]->filename = xstrdup(argv[optind]); | 1639 | deb_file[deb_count]->filename = xstrdup(argv[0]); |
1695 | package_num = fill_package_struct(deb_file[deb_count]->control_file); | 1640 | package_num = fill_package_struct(deb_file[deb_count]->control_file); |
1696 | 1641 | ||
1697 | if (package_num == -1) { | 1642 | if (package_num == -1) { |
1698 | bb_error_msg("invalid control file in %s", argv[optind]); | 1643 | bb_error_msg("invalid control file in %s", argv[0]); |
1699 | optind++; | 1644 | argv++; |
1700 | continue; | 1645 | continue; |
1701 | } | 1646 | } |
1702 | deb_file[deb_count]->package = (unsigned int) package_num; | 1647 | deb_file[deb_count]->package = (unsigned) package_num; |
1703 | 1648 | ||
1704 | /* Add the package to the status hashtable */ | 1649 | /* Add the package to the status hashtable */ |
1705 | if ((dpkg_opt & dpkg_opt_unpack) || (dpkg_opt & dpkg_opt_install)) { | 1650 | if (opt & (OPT_unpack|OPT_install)) { |
1706 | /* Try and find a currently installed version of this package */ | 1651 | /* Try and find a currently installed version of this package */ |
1707 | status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); | 1652 | status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); |
1708 | /* If no previous entry was found initialise a new entry */ | 1653 | /* If no previous entry was found initialise a new entry */ |
1709 | if ((status_hashtable[status_num] == NULL) || | 1654 | if (status_hashtable[status_num] == NULL |
1710 | (status_hashtable[status_num]->status == 0)) { | 1655 | || status_hashtable[status_num]->status == 0 |
1656 | ) { | ||
1711 | status_node = xmalloc(sizeof(status_node_t)); | 1657 | status_node = xmalloc(sizeof(status_node_t)); |
1712 | status_node->package = deb_file[deb_count]->package; | 1658 | status_node->package = deb_file[deb_count]->package; |
1713 | /* reinstreq isnt changed to "ok" until the package control info | 1659 | /* reinstreq isnt changed to "ok" until the package control info |
@@ -1720,26 +1666,27 @@ int dpkg_main(int argc, char **argv) | |||
1720 | } | 1666 | } |
1721 | } | 1667 | } |
1722 | } | 1668 | } |
1723 | else if (dpkg_opt & dpkg_opt_package_name) { | 1669 | else if (opt & REQ_package_name) { |
1724 | deb_file[deb_count]->package = search_package_hashtable( | 1670 | deb_file[deb_count]->package = search_package_hashtable( |
1725 | search_name_hashtable(argv[optind]), | 1671 | search_name_hashtable(argv[0]), |
1726 | search_name_hashtable("ANY"), VER_ANY); | 1672 | search_name_hashtable("ANY"), VER_ANY); |
1727 | if (package_hashtable[deb_file[deb_count]->package] == NULL) { | 1673 | if (package_hashtable[deb_file[deb_count]->package] == NULL) { |
1728 | bb_error_msg_and_die("package %s is uninstalled or unknown", argv[optind]); | 1674 | bb_error_msg_and_die("package %s is uninstalled or unknown", argv[0]); |
1729 | } | 1675 | } |
1730 | package_num = deb_file[deb_count]->package; | 1676 | package_num = deb_file[deb_count]->package; |
1731 | status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]); | 1677 | status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]); |
1732 | state_status = get_status(status_num, 3); | 1678 | state_status = get_status(status_num, 3); |
1733 | 1679 | ||
1734 | /* check package status is "installed" */ | 1680 | /* check package status is "installed" */ |
1735 | if (dpkg_opt & dpkg_opt_remove) { | 1681 | if (opt & OPT_remove) { |
1736 | if ((strcmp(name_hashtable[state_status], "not-installed") == 0) || | 1682 | if (strcmp(name_hashtable[state_status], "not-installed") == 0 |
1737 | (strcmp(name_hashtable[state_status], "config-files") == 0)) { | 1683 | || strcmp(name_hashtable[state_status], "config-files") == 0 |
1684 | ) { | ||
1738 | bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]); | 1685 | bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]); |
1739 | } | 1686 | } |
1740 | set_status(status_num, "deinstall", 1); | 1687 | set_status(status_num, "deinstall", 1); |
1741 | } | 1688 | } |
1742 | else if (dpkg_opt & dpkg_opt_purge) { | 1689 | else if (opt & OPT_purge) { |
1743 | /* if package status is "conf-files" then its ok */ | 1690 | /* if package status is "conf-files" then its ok */ |
1744 | if (strcmp(name_hashtable[state_status], "not-installed") == 0) { | 1691 | if (strcmp(name_hashtable[state_status], "not-installed") == 0) { |
1745 | bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]); | 1692 | bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]); |
@@ -1748,12 +1695,12 @@ int dpkg_main(int argc, char **argv) | |||
1748 | } | 1695 | } |
1749 | } | 1696 | } |
1750 | deb_count++; | 1697 | deb_count++; |
1751 | optind++; | 1698 | argv++; |
1752 | } | 1699 | } |
1753 | deb_file[deb_count] = NULL; | 1700 | deb_file[deb_count] = NULL; |
1754 | 1701 | ||
1755 | /* Check that the deb file arguments are installable */ | 1702 | /* Check that the deb file arguments are installable */ |
1756 | if ((dpkg_opt & dpkg_opt_force_ignore_depends) != dpkg_opt_force_ignore_depends) { | 1703 | if (!(opt & OPT_force_ignore_depends)) { |
1757 | if (!check_deps(deb_file, 0, deb_count)) { | 1704 | if (!check_deps(deb_file, 0, deb_count)) { |
1758 | bb_error_msg_and_die("dependency check failed"); | 1705 | bb_error_msg_and_die("dependency check failed"); |
1759 | } | 1706 | } |
@@ -1762,25 +1709,25 @@ int dpkg_main(int argc, char **argv) | |||
1762 | /* TODO: install or remove packages in the correct dependency order */ | 1709 | /* TODO: install or remove packages in the correct dependency order */ |
1763 | for (i = 0; i < deb_count; i++) { | 1710 | for (i = 0; i < deb_count; i++) { |
1764 | /* Remove or purge packages */ | 1711 | /* Remove or purge packages */ |
1765 | if (dpkg_opt & dpkg_opt_remove) { | 1712 | if (opt & OPT_remove) { |
1766 | remove_package(deb_file[i]->package, 1); | 1713 | remove_package(deb_file[i]->package, 1); |
1767 | } | 1714 | } |
1768 | else if (dpkg_opt & dpkg_opt_purge) { | 1715 | else if (opt & OPT_purge) { |
1769 | purge_package(deb_file[i]->package); | 1716 | purge_package(deb_file[i]->package); |
1770 | } | 1717 | } |
1771 | else if (dpkg_opt & dpkg_opt_unpack) { | 1718 | else if (opt & OPT_unpack) { |
1772 | unpack_package(deb_file[i]); | 1719 | unpack_package(deb_file[i]); |
1773 | } | 1720 | } |
1774 | else if (dpkg_opt & dpkg_opt_install) { | 1721 | else if (opt & OPT_install) { |
1775 | unpack_package(deb_file[i]); | 1722 | unpack_package(deb_file[i]); |
1776 | /* package is configured in second pass below */ | 1723 | /* package is configured in second pass below */ |
1777 | } | 1724 | } |
1778 | else if (dpkg_opt & dpkg_opt_configure) { | 1725 | else if (opt & OPT_configure) { |
1779 | configure_package(deb_file[i]); | 1726 | configure_package(deb_file[i]); |
1780 | } | 1727 | } |
1781 | } | 1728 | } |
1782 | /* configure installed packages */ | 1729 | /* configure installed packages */ |
1783 | if (dpkg_opt & dpkg_opt_install) { | 1730 | if (opt & OPT_install) { |
1784 | for (i = 0; i < deb_count; i++) | 1731 | for (i = 0; i < deb_count; i++) |
1785 | configure_package(deb_file[i]); | 1732 | configure_package(deb_file[i]); |
1786 | } | 1733 | } |