OSDN Git Service

Rationalise implementation and usage of --all-related option.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 12 Mar 2012 22:13:58 +0000 (22:13 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 12 Mar 2012 22:13:58 +0000 (22:13 +0000)
ChangeLog
src/climain.cpp
src/clistub.c
src/pkgopts.h

index 3562cb7..f8fceea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2012-03-12  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
+       Rationalise implementation and usage of --all-related option.
+
+       * src/pkgopts.h: Update copyright notice; add year 2012.
+       (OPTION_RECURSIVE, OPTION_ALL_RELATED): New constants; define them.
+       (pkgOpts::SetFlags): New method; declare and implement it inline.
+
+       * src/clistub.c: Update copyright notice; add year 2012.
+       (options) [recursive, all-related]: Redefine in terms of...
+       (OPTION_RECURSIVE, OPTION_ALL_RELATED): ...these.
+       (help_text): Update appropriately.
+
+       * src/climain.cpp: Update copyright notice; add year 2012.
+       (climain) [all-related]: Associate its use exclusively with...
+       (source, licence): ...these package processing operations; use...
+       (pkgOptions::SetFlags): ...this, to propagate its effect.
+
+2012-03-12  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
        Don't report failed downloads in respect of virtual packages.
 
        * src/pkginet.cpp (pkgActionItem::DownloadArchiveFiles): Clear...
index 20e1213..34f30a8 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, MinGW Project
+ * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
  *
  *
  * Implementation of the main program function, which is invoked by
@@ -230,10 +230,16 @@ EXTERN_C int climain( int argc, char **argv )
             * for tracking packages as processed.
             */
            pkgProcessedArchives = NULL;
-           if( pkgOptions()->Test( OPTION_ALL_DEPS ) == OPTION_ALL_DEPS )
+           if( pkgOptions()->Test( OPTION_ALL_RELATED ) )
            {
-             /* The "--all-related" option is in effect; for each
-              * package identified on the command line...
+             /* The "--all-related" option is in effect; ensure
+              * that all dependencies will be evaluated, as if to
+              * perform a recursive reinstall...
+              */
+             pkgOptions()->SetFlags( OPTION_ALL_DEPS );
+             /*
+              * ...then, for each package which is identified on
+              * the command line...
               */
              while( --argc )
                /*
index 8345b94..6d5ff62 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, MinGW Project
+ * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
  *
  *
  * Initiation stub for command line invocation of mingw-get
@@ -194,6 +194,11 @@ static const char *help_text =
 "                    for which the most recent release is\n"
 "                    already installed\n"
 "\n"
+"  --recursive       Extend the scope of \"install --reinstall\"\n"
+"                    or of \"upgrade\", such that the operation\n"
+"                    is applied recursively to all prerequisites\n"
+"                    of all packages named on the command line\n"
+"\n"
 "  --download-only   Download the package archive files which\n"
 "                    would be required to complete the specified\n"
 "                    install, upgrade, or source operation, but\n"
@@ -207,7 +212,6 @@ static const char *help_text =
 "                    download any package file, or otherwise\n"
 "                    proceed with the operation\n"
 "\n"
-"  --recursive\n"
 "  --all-related     When performing source or licence operations,\n"
 "                    causes mingw-get to retrieve, and optionally to\n"
 "                    unpack the source or licence archives for all\n"
@@ -396,12 +400,12 @@ int main( int argc, char **argv )
       { "help",           no_argument,         NULL,      'h'                },
       { "verbose",        optional_argument,   NULL,      OPTION_VERBOSE     },
 
-      { "recursive",      no_argument,         &optref,   OPTION_ALL_DEPS    },
+      { "recursive",      no_argument,         &optref,   OPTION_RECURSIVE   },
       { "reinstall",      no_argument,         &optref,   OPTION_REINSTALL   },
       { "download-only",  no_argument,         &optref,   OPTION_DNLOAD_ONLY },
       { "print-uris",     no_argument,         &optref,   OPTION_PRINT_URIS  },
 
-      { "all-related",    no_argument,         &optref,   OPTION_ALL_DEPS    },
+      { "all-related",    no_argument,         &optref,   OPTION_ALL_RELATED },
 
 #     if DEBUG_ENABLED( DEBUG_TRACE_DYNAMIC )
        /* The "--trace" option is supported only when dynamic tracing
index a219c75..7ea3bdf 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2011, MinGW Project
+ * Copyright (C) 2011, 2012, MinGW Project
  *
  *
  * Public declarations of the data structures, values and functions
@@ -89,7 +89,9 @@ struct pkgopts
 #define OPTION_DOWNLOAD_ONLY   (0x00000030)
 #define OPTION_PRINT_URIS      (0x00000070)
 
+#define OPTION_RECURSIVE       (0x00000080)
 #define OPTION_ALL_DEPS        (0x00000090)
+#define OPTION_ALL_RELATED     (0x00000100)
 
 #if __cplusplus
 /*
@@ -128,6 +130,22 @@ class pkgOpts : protected pkgopts
        */
       return this ? (flags[index].numeric & mask) : 0;
     }
+    inline void SetFlags( unsigned value )
+    {
+      /* This is a mask and store operation, to set a specified
+       * bit-field within the first pair of flags slots; it mimics
+       * the options setting operation performed in the CLI start-up
+       * code, where the input value represents a 12-bit flag code,
+       * packaged with a 12-bit combining mask, and an alignment
+       * shift count between 0 and 52, in 4-bit increments.
+       */
+      unsigned shift;
+      if( (shift = (value & OPTION_SHIFT_MASK) >> 22) < 53 )
+      {
+       *(uint64_t *)(flags) &= ~((uint64_t)((value & 0xfff000) >> 12) << shift);
+       *(uint64_t *)(flags) |= (uint64_t)(value) << shift;
+      }
+    }
 };
 
 /* Access modes for the following global options accessor function.