OSDN Git Service

Correct sequence of installation/removal progress reporting.
[mingw/mingw-get.git] / src / pkgunst.cpp
index 6b0e551..d2821ca 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2011, MinGW Project
+ * Copyright (C) 2011, 2012, MinGW Project
  *
  *
  * Implementation of the primary package removal methods.
@@ -105,7 +105,7 @@ unsigned long pkgActionItem::SetAuthorities( pkgActionItem *current )
         * package which has been identified as "installed"...
         */
        const char *tarname = ref->GetPropVal( tarname_key, value_unknown );
-       DEBUG_INVOKE_IF( DEBUGLEVEL & DEBUG_TRACE_INIT,
+       DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_INIT ),
            dmh_printf( "%s: selected for %s\n",
              (tarname = ref->GetPropVal( tarname_key, value_unknown )),
              (current->flags & ACTION_INSTALL) ? "upgrade" : "removal"
@@ -118,7 +118,7 @@ unsigned long pkgActionItem::SetAuthorities( pkgActionItem *current )
        {
          /* ...and then, having confirmed its validity...
           */
-         DEBUG_INVOKE_IF( DEBUGLEVEL & DEBUG_TRACE_INIT,
+         DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_INIT ),
              dmh_printf( "%s: marked for %s\n",
                ref->GetPropVal( tarname_key, value_unknown ),
                (current->flags & ACTION_INSTALL) ? "upgrade" : "removal"
@@ -254,7 +254,7 @@ int pkg_rmdir( const char *sysroot, const char *pathname )
     char fullpath[ mkpath( NULL, sysroot, pathname, NULL ) ];
     mkpath( fullpath, sysroot, pathname, NULL );
 
-    DEBUG_INVOKE_IF( DEBUGLEVEL & DEBUG_TRACE_TRANSACTIONS,
+    DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_TRANSACTIONS ),
        dmh_printf( "  %s: rmdir\n", fullpath )
       );
 
@@ -286,7 +286,7 @@ int pkg_unlink( const char *sysroot, const char *pathname )
     char filepath[ mkpath( NULL, sysroot, pathname, NULL ) ];
     mkpath( filepath, sysroot, pathname, NULL );
 
-    DEBUG_INVOKE_IF( DEBUGLEVEL & DEBUG_TRACE_TRANSACTIONS,
+    DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_TRANSACTIONS ),
        dmh_printf( "  %s: unlink file\n", filepath )
       );
 
@@ -312,6 +312,13 @@ EXTERN_C void pkgRemove( pkgActionItem *current )
     const char *tarname = pkg->GetPropVal( tarname_key, value_unknown );
     pkgXmlNode *sysroot = sysroot_lookup( pkg, tarname );
 
+    /* If the package we are about to remove has an associated
+     * pre-remove script, now is the time to invoke it...
+     */
+    pkg->InvokeScript( "pre-remove" );
+
+    /* ...before we proceed to removal of actual package content.
+     */
     dmh_printf( " removing %s %s\n", pkg->GetName(), tarname );
 
     /* Removal of virtual (meta) packages is comparitively simple;
@@ -517,6 +524,10 @@ EXTERN_C void pkgRemove( pkgActionItem *current )
        sysroot->SetAttribute( modified_key, value_yes );
       }
     }
+    /* After package removal has been completed, we invoke any
+     * post-remove script which may be associated with the package.
+     */
+    pkg->InvokeScript( "post-remove" );
   }
   else if( (pkg != NULL) && current->HasAttribute( ACTION_DOWNLOAD ) )
   {