• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Installation Manager Tool


Commit MetaInfo

Révisioncdc3a9f611a084122f61c57b5ae66b885c4a6a4a (tree)
l'heure2011-06-14 04:00:14
AuteurKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Message de Log

Implement --reinstall option.

Change Summary

Modification

--- a/ChangeLog
+++ b/ChangeLog
@@ -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+
122 2011-06-12 Keith Marshall <keithmarshall@users.sourceforge.net>
223
324 Don't require -vv to report progress of update operation.
--- a/src/clistub.c
+++ b/src/clistub.c
@@ -356,17 +356,19 @@ int main( int argc, char **argv )
356356 struct option options[] =
357357 {
358358 /* Option Name Argument Category Store To Return Value
359- * -------------- ------------------ -------- --------------
359+ * -------------- ------------------ -------- ----------------
360360 */
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 },
364366
365367 # if DEBUG_ENABLED( DEBUG_TRACE_DYNAMIC )
366368 /* The "--trace" option is supported only when dynamic tracing
367369 * debugging support has been compiled in.
368370 */
369- { "trace", required_argument, &optref, OPTION_TRACE },
371+ { "trace", required_argument, &optref, OPTION_TRACE },
370372 # endif
371373
372374 /* This list must be terminated by a null definition...
@@ -424,20 +426,52 @@ int main( int argc, char **argv )
424426 ++parsed_options.flags[OPTION_FLAGS].numeric;
425427 break;
426428
427- case 0:
429+ case OPTION_GENERIC:
428430 switch( optref & OPTION_STORAGE_CLASS )
429431 {
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+
430438 case OPTION_STORE_STRING:
439+ /* This is a simple store of a option argument
440+ * which represents a character string.
441+ */
431442 parsed_options.flags[optref & 0xfff].string = optarg;
432443 break;
433444
434445 case OPTION_STORE_NUMBER:
446+ /* This is also a simple store of the argument value,
447+ * in this case interpreted as a number.
448+ */
435449 parsed_options.flags[optref & 0xfff].numeric = xatoi( optarg );
436450 break;
437451
438452 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+ */
439458 parsed_options.flags[optref & 0xfff].numeric |= xatoi( optarg );
440459 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+ }
441475 }
442476 break;
443477
--- a/src/pkgexec.cpp
+++ b/src/pkgexec.cpp
@@ -31,16 +31,9 @@
3131 #include "pkgkeys.h"
3232 #include "pkginfo.h"
3333 #include "pkgtask.h"
34+#include "pkgopts.h"
3435 #include "pkgproc.h"
3536
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-
4437 EXTERN_C const char *action_name( unsigned long index )
4538 {
4639 /* Define the keywords used on the mingw-get command line,
@@ -412,24 +405,46 @@ void pkgActionItem::Execute()
412405 */
413406 init_rites_pending = self_upgrade_rites( tarname );
414407
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...
419421 */
420- pkgRemove( current );
421- }
422+ dmh_notify( DMH_INFO, "package %s is up to date\n", tarname );
422423
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.
427427 */
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+ }
433448 }
434449 }
435450 /* Proceed to the next package, if any, with scheduled actions.
--- a/src/pkgopts.h
+++ b/src/pkgopts.h
@@ -28,11 +28,16 @@
2828 */
2929 #define PKGOPTS_H 1
3030
31+#include <stdint.h> /* required for uint64_t typedef */
32+
33+#define OPTION_GENERIC 0
34+
3135 enum
3236 { /* Specification of symbolic names (keys) for each of the individual
3337 * entries in the options parameter array.
3438 */
3539 OPTION_FLAGS,
40+ OPTION_EXTRA_FLAGS,
3641 OPTION_DEBUGLEVEL,
3742
3843 /* This final entry specifies the size of the parameter array which
@@ -60,6 +65,7 @@ struct pkgopts
6065
6166 /* Bit-mapped control tags used by the CLI options parsing code...
6267 */
68+#define OPTION_SHIFT_MASK (0x0000000f << 24)
6369 #define OPTION_STORAGE_CLASS (0x00000007 << 28)
6470 /*
6571 * ...to determine how option arguments are to be inserted into the
@@ -78,6 +84,8 @@ struct pkgopts
7884 #define OPTION_VERBOSE (0x00000003)
7985 #define OPTION_VERBOSE_MAX (0x00000003)
8086
87+#define OPTION_REINSTALL (0x00000010)
88+
8189 #if __cplusplus
8290 /*
8391 * We provide additional features for use in C++ modules.