- unsigned long fallback = action;
- if( (action & ACTION_MASK) == ACTION_INSTALL )
- fallback = with_download( ACTION_UPGRADE ) | with_flags( action );
-
- /* Again, we recursively resolve any dependencies
- * for the scheduled upgrade.
- */
- ResolveDependencies( upgrade, Schedule( fallback, latest ));
+ if( (action & ACTION_MASK) == ACTION_UPGRADE )
+ /*
+ * ...we must recursively resolve any dependencies...
+ */
+ ResolveDependencies(
+ upgrade, Schedule( with_download( action ), latest )
+ );
+ else
+ {
+ /* ...but, we decline to proceed with ACTION_INSTALL
+ * unless the --reinstall option is enabled...
+ */
+ if( pkgOptions()->Test( OPTION_REINSTALL ) )
+ {
+ /* ...in which case, we resolve dependencies for,
+ * and reschedule a reinstallation of the currently
+ * installed version...
+ */
+ latest.SelectPackage( installed );
+ ResolveDependencies(
+ installed, Schedule( with_download( action ), latest )
+ );
+ }
+ else
+ { /* ...otherwise, we reformulate the appropriate
+ * fully qualified package name...
+ */
+ const char *extname = ( component != NULL )
+ ? component->GetPropVal( class_key, "" )
+ : "";
+ char full_package_name[2 + strlen( name ) + strlen( extname )];
+ sprintf( full_package_name, *extname ? "%s-%s" : "%s", name, extname );
+ /*
+ * ...which we then incorporate into an advisory
+ * diagnostic message, which serves both to inform
+ * the user of this error condition, and also to
+ * suggest appropriate corrective action.
+ */
+ dmh_control( DMH_BEGIN_DIGEST );
+ dmh_notify( DMH_ERROR, "%s: package is already installed\n",
+ full_package_name
+ );
+ dmh_notify( DMH_ERROR, "use 'mingw-get upgrade %s' to upgrade it\n",
+ full_package_name
+ );
+ dmh_notify( DMH_ERROR, "or 'mingw-get install --reinstall %s'\n",
+ full_package_name
+ );
+ dmh_notify( DMH_ERROR, "to reinstall the currently installed version\n"
+ );
+ dmh_control( DMH_END_DIGEST );
+ }
+ }