The MinGW.org Installation Manager Tool
Révision | cdc3a9f611a084122f61c57b5ae66b885c4a6a4a (tree) |
---|---|
l'heure | 2011-06-14 04:00:14 |
Auteur | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Implement --reinstall option.
@@ -1,3 +1,24 @@ | ||
1 | +2011-06-13 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Implement --reinstall option. | |
4 | + | |
5 | + * src/pkgopts.h (OPTION_REINSTALL): New macro; define it. | |
6 | + (OPTION_GENERIC, OPTION_SHIFT_MASK): Likewise. | |
7 | + (OPTION_EXTRA_FLAGS): New field; declare it. | |
8 | + | |
9 | + * src/clistub.c (options): Add "reinstall". | |
10 | + (OPTION_GENERIC): Use it where appropriate; within its scope... | |
11 | + (OPTION_STORAGE_CLASS): Improve descriptive comments; add handling for | |
12 | + default case of flag type options requiring an alignment shift. | |
13 | + | |
14 | + * src/pkgexec.cpp: Remove previous "always reinstall" kludge. | |
15 | + (pkgOptionSelected, PKG_OPTION_REINSTALL): Remove obsolete macros. | |
16 | + (pkgActionItem::Execute): Check for "upgrade" request on any package | |
17 | + which is already up to date; report this state, otherwise... | |
18 | + [OPTION_REINSTALL || ACTION_UPGRADE]: Mark package as "removed", to | |
19 | + avoid bail-out on "package already installed", when calling... | |
20 | + (pkgInstall): ...this. | |
21 | + | |
1 | 22 | 2011-06-12 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 23 | |
3 | 24 | Don't require -vv to report progress of update operation. |
@@ -356,17 +356,19 @@ int main( int argc, char **argv ) | ||
356 | 356 | struct option options[] = |
357 | 357 | { |
358 | 358 | /* Option Name Argument Category Store To Return Value |
359 | - * -------------- ------------------ -------- -------------- | |
359 | + * -------------- ------------------ -------- ---------------- | |
360 | 360 | */ |
361 | - { "version", no_argument, NULL, 'V' }, | |
362 | - { "help", no_argument, NULL, 'h' }, | |
363 | - { "verbose", optional_argument, NULL, OPTION_VERBOSE }, | |
361 | + { "version", no_argument, NULL, 'V' }, | |
362 | + { "help", no_argument, NULL, 'h' }, | |
363 | + { "verbose", optional_argument, NULL, OPTION_VERBOSE }, | |
364 | + | |
365 | + { "reinstall", no_argument, &optref, OPTION_REINSTALL }, | |
364 | 366 | |
365 | 367 | # if DEBUG_ENABLED( DEBUG_TRACE_DYNAMIC ) |
366 | 368 | /* The "--trace" option is supported only when dynamic tracing |
367 | 369 | * debugging support has been compiled in. |
368 | 370 | */ |
369 | - { "trace", required_argument, &optref, OPTION_TRACE }, | |
371 | + { "trace", required_argument, &optref, OPTION_TRACE }, | |
370 | 372 | # endif |
371 | 373 | |
372 | 374 | /* This list must be terminated by a null definition... |
@@ -424,20 +426,52 @@ int main( int argc, char **argv ) | ||
424 | 426 | ++parsed_options.flags[OPTION_FLAGS].numeric; |
425 | 427 | break; |
426 | 428 | |
427 | - case 0: | |
429 | + case OPTION_GENERIC: | |
428 | 430 | switch( optref & OPTION_STORAGE_CLASS ) |
429 | 431 | { |
432 | + /* This represents a generic option specification, | |
433 | + * allowing for storage of a option argument of the | |
434 | + * specified class into a specified option slot... | |
435 | + */ | |
436 | + unsigned shift; | |
437 | + | |
430 | 438 | case OPTION_STORE_STRING: |
439 | + /* This is a simple store of a option argument | |
440 | + * which represents a character string. | |
441 | + */ | |
431 | 442 | parsed_options.flags[optref & 0xfff].string = optarg; |
432 | 443 | break; |
433 | 444 | |
434 | 445 | case OPTION_STORE_NUMBER: |
446 | + /* This is also a simple store of the argument value, | |
447 | + * in this case interpreted as a number. | |
448 | + */ | |
435 | 449 | parsed_options.flags[optref & 0xfff].numeric = xatoi( optarg ); |
436 | 450 | break; |
437 | 451 | |
438 | 452 | case OPTION_MERGE_NUMBER: |
453 | + /* In this case, we combine the value of the argument, | |
454 | + * again interpreted as a number, with the original value | |
455 | + * stored in the option slot, forming the bitwise logical | |
456 | + * .OR. of the pair of values. | |
457 | + */ | |
439 | 458 | parsed_options.flags[optref & 0xfff].numeric |= xatoi( optarg ); |
440 | 459 | break; |
460 | + | |
461 | + default: | |
462 | + /* This is a mask and store operation for a specified | |
463 | + * bit-field within the first pair of flags slots; in | |
464 | + * this case, the optref value itself specifies a 12-bit | |
465 | + * value, a 12-bit combining mask, and an alignment shift | |
466 | + * count between 0 and 52, in 4-bit increments. | |
467 | + */ | |
468 | + if( (shift = (optref & OPTION_SHIFT_MASK) >> 22) < 53 ) | |
469 | + { | |
470 | + uint64_t value = optref & 0xfff; | |
471 | + uint64_t mask = (optref & 0xfff000) >> 12; | |
472 | + *(uint64_t *)(parsed_options.flags) &= ~(mask << shift); | |
473 | + *(uint64_t *)(parsed_options.flags) |= value << shift; | |
474 | + } | |
441 | 475 | } |
442 | 476 | break; |
443 | 477 |
@@ -31,16 +31,9 @@ | ||
31 | 31 | #include "pkgkeys.h" |
32 | 32 | #include "pkginfo.h" |
33 | 33 | #include "pkgtask.h" |
34 | +#include "pkgopts.h" | |
34 | 35 | #include "pkgproc.h" |
35 | 36 | |
36 | -/* FIXME: temporarily establish "install" behaviour as if the | |
37 | - * "--reinstall" option is selected; remove this kludge, when we | |
38 | - * have an effective "uninstall" implementation, and have provided | |
39 | - * a mechanism for specifying options. | |
40 | - */ | |
41 | -#define pkgOptionSelected( OPT ) OPT | |
42 | -#define PKG_OPTION_REINSTALL true | |
43 | - | |
44 | 37 | EXTERN_C const char *action_name( unsigned long index ) |
45 | 38 | { |
46 | 39 | /* Define the keywords used on the mingw-get command line, |
@@ -412,24 +405,46 @@ void pkgActionItem::Execute() | ||
412 | 405 | */ |
413 | 406 | init_rites_pending = self_upgrade_rites( tarname ); |
414 | 407 | |
415 | - if( (current->flags & ACTION_REMOVE) == ACTION_REMOVE ) | |
416 | - { | |
417 | - /* The selected package has been marked for removal, either explicitly, | |
418 | - * or as an implicit prerequisite for upgrade. | |
408 | + /* If we are performing an upgrade... | |
409 | + */ | |
410 | + if( ((current->flags & ACTION_MASK) == ACTION_UPGRADE) | |
411 | + /* | |
412 | + * ...and the latest version of the package is already installed... | |
413 | + */ | |
414 | + && (current->Selection() == current->Selection( to_remove )) | |
415 | + /* | |
416 | + * ...and the `--reinstall' option hasn't been specified... | |
417 | + */ | |
418 | + && (pkgOptions()->Test( OPTION_REINSTALL ) == 0) ) | |
419 | + /* | |
420 | + * ...then simply report the up-to-date status... | |
419 | 421 | */ |
420 | - pkgRemove( current ); | |
421 | - } | |
422 | + dmh_notify( DMH_INFO, "package %s is up to date\n", tarname ); | |
422 | 423 | |
423 | - if( (current->flags & ACTION_INSTALL) == ACTION_INSTALL ) | |
424 | - { | |
425 | - /* The selected package has been marked for installation, either explicitly, | |
426 | - * or implicitly to complete a package upgrade. | |
424 | + else | |
425 | + { /* ...otherwise, proceed to perform remove and install | |
426 | + * operations, as appropriate. | |
427 | 427 | */ |
428 | - pkgXmlNode *tmp = current->Selection( to_remove ); | |
429 | - if( pkgOptionSelected( PKG_OPTION_REINSTALL ) ) | |
430 | - current->selection[ to_remove ] = NULL; | |
431 | - pkgInstall( current ); | |
432 | - current->selection[ to_remove ] = tmp; | |
428 | + if( (current->flags & ACTION_REMOVE) == ACTION_REMOVE ) | |
429 | + { | |
430 | + /* The selected package has been marked for removal, | |
431 | + * either explicitly, or as an implicit prerequisite for upgrade. | |
432 | + */ | |
433 | + pkgRemove( current ); | |
434 | + } | |
435 | + | |
436 | + if( (current->flags & ACTION_INSTALL) == ACTION_INSTALL ) | |
437 | + { | |
438 | + /* The selected package has been marked for installation, | |
439 | + * either explicitly, or implicitly to complete a package upgrade. | |
440 | + */ | |
441 | + pkgXmlNode *tmp = current->Selection( to_remove ); | |
442 | + if( pkgOptions()->Test( OPTION_REINSTALL ) | |
443 | + || ((current->flags & ACTION_MASK) == ACTION_UPGRADE) ) | |
444 | + current->selection[ to_remove ] = NULL; | |
445 | + pkgInstall( current ); | |
446 | + current->selection[ to_remove ] = tmp; | |
447 | + } | |
433 | 448 | } |
434 | 449 | } |
435 | 450 | /* Proceed to the next package, if any, with scheduled actions. |
@@ -28,11 +28,16 @@ | ||
28 | 28 | */ |
29 | 29 | #define PKGOPTS_H 1 |
30 | 30 | |
31 | +#include <stdint.h> /* required for uint64_t typedef */ | |
32 | + | |
33 | +#define OPTION_GENERIC 0 | |
34 | + | |
31 | 35 | enum |
32 | 36 | { /* Specification of symbolic names (keys) for each of the individual |
33 | 37 | * entries in the options parameter array. |
34 | 38 | */ |
35 | 39 | OPTION_FLAGS, |
40 | + OPTION_EXTRA_FLAGS, | |
36 | 41 | OPTION_DEBUGLEVEL, |
37 | 42 | |
38 | 43 | /* This final entry specifies the size of the parameter array which |
@@ -60,6 +65,7 @@ struct pkgopts | ||
60 | 65 | |
61 | 66 | /* Bit-mapped control tags used by the CLI options parsing code... |
62 | 67 | */ |
68 | +#define OPTION_SHIFT_MASK (0x0000000f << 24) | |
63 | 69 | #define OPTION_STORAGE_CLASS (0x00000007 << 28) |
64 | 70 | /* |
65 | 71 | * ...to determine how option arguments are to be inserted into the |
@@ -78,6 +84,8 @@ struct pkgopts | ||
78 | 84 | #define OPTION_VERBOSE (0x00000003) |
79 | 85 | #define OPTION_VERBOSE_MAX (0x00000003) |
80 | 86 | |
87 | +#define OPTION_REINSTALL (0x00000010) | |
88 | + | |
81 | 89 | #if __cplusplus |
82 | 90 | /* |
83 | 91 | * We provide additional features for use in C++ modules. |