[43726] trunk/base

jmr at macports.org jmr at macports.org
Sat Dec 13 18:14:00 PST 2008


Revision: 43726
          http://trac.macports.org/changeset/43726
Author:   jmr at macports.org
Date:     2008-12-13 18:14:00 -0800 (Sat, 13 Dec 2008)
Log Message:
-----------
Apply (manually) gwhitney's dry-run patch from #11892.

Modified Paths:
--------------
    trunk/base/doc/port.1
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/port/port.tcl
    trunk/base/src/port1.0/portutil.tcl

Modified: trunk/base/doc/port.1
===================================================================
--- trunk/base/doc/port.1	2008-12-14 02:00:00 UTC (rev 43725)
+++ trunk/base/doc/port.1	2008-12-14 02:14:00 UTC (rev 43726)
@@ -235,6 +235,8 @@
 In batch and interactive mode, exit on the first error encountered. Otherwise, errors during batch execution are simply reported.
 .It Fl p
 Despite any errors encountered, proceed to process multiple ports and commands.
+.It Fl y
+Perform a dry run. All of the steps to build the ports and their dependencies are computed, but not actually performed. With the verbose flag, every step is reported; otherwise there is just one message per port, which allows you to easily determine the recursive deps of a port (and the order in which they will be built).
 .It Fl t
 enable trace mode debug facilities on platforms that support it (Mac OS X). This feature is two-folded. It consists in automatically detecting and reporting undeclared dependencies based on what files the port reads or what programs the port executes. In verbose mode, it will also report unused dependencies for each stage of the port installation. It also consists in forbidding and reporting file creation and file writes outside allowed directories (temporary directories and ${workpath}).
 .El

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2008-12-14 02:00:00 UTC (rev 43725)
+++ trunk/base/src/macports1.0/macports.tcl	2008-12-14 02:14:00 UTC (rev 43726)
@@ -1940,6 +1940,11 @@
 
     # set to no-zero is epoch overrides version
     set epoch_override 0
+    # Is this a dry run?
+    set is_dryrun no
+    if {[info exists options(ports_dryrun)] && $options(ports_dryrun) eq "yes"} {
+        set is_dryrun yes
+    }
 
     # check if the port is in tree
     if {[catch {mportsearch $portname false exact} result]} {
@@ -2061,7 +2066,9 @@
                             || [rpm-vercomp $revision_installed $revision_active] != 0
                             || [string compare $variant_installed $variant_active] != 0)} {
             # deactivate version
-            if {[catch {portimage::deactivate $active_name ${version_active}_${revision_active}${variant_active} $optionslist} result]} {
+            if {$is_dryrun eq "yes"} {
+                ui_msg "Skipping deactivate $active_name @${version_active}_${revision_active} (dry run)"
+            } elseif {[catch {portimage::deactivate $active_name ${version_active}_${revision_active}${variant_active} $optionslist} result]} {
                 global errorInfo
                 ui_debug "$errorInfo"
                 ui_error "Deactivating $active_name @${version_active}_${revision_active} failed: $result"
@@ -2070,7 +2077,9 @@
         }
         if { [lindex $num 4] == 0 && 0 == [string compare "image" ${macports::registry.installtype}] } {
             # activate the latest installed version
-            if {[catch {portimage::activate $iname ${version_installed}_${revision_installed}$variant $optionslist} result]} {
+            if {$is_dryrun eq "yes"} {
+                ui_msg "Skipping activate $iname @${version_installed}_${revision_installed} (dry run)"
+            } elseif {[catch {portimage::activate $iname ${version_installed}_${revision_installed}$variant $optionslist} result]} {
                 global errorInfo
                 ui_debug "$errorInfo"
                 ui_error "Activating $iname @${version_installed}_${revision_installed} failed: $result"
@@ -2210,7 +2219,9 @@
         # we have to force the uninstall in case of dependents
         set force_cur [info exists options(ports_force)]
         set options(ports_force) yes
-        if {[catch {portuninstall::uninstall $iname ${version_installed}_$revision_installed$oldvariant [array get options]} result]} {
+        if {$is_dryrun eq "yes"} {
+            ui_msg "Skipping uninstall $iname @${version_installed}_$revision_installed$oldvariant (dry run)"
+        } elseif {[catch {portuninstall::uninstall $iname ${version_installed}_$revision_installed$oldvariant [array get options]} result]} {
             global errorInfo
             ui_debug "$errorInfo"
             ui_error "Uninstall $iname ${version_installed}_$revision_installed$oldvariant failed: $result"
@@ -2221,7 +2232,9 @@
         }
     } else {
         # XXX deactivate version_installed
-        if {[catch {portimage::deactivate $iname ${version_installed}_$revision_installed$oldvariant $optionslist} result]} {
+        if {$is_dryrun eq "yes"} {
+            ui_msg "Skipping deactivate $iname @${version_installed}_$revision_installed (dry run)"
+        } elseif {[catch {portimage::deactivate $iname ${version_installed}_$revision_installed$oldvariant $optionslist} result]} {
             global errorInfo
             ui_debug "$errorInfo"
             ui_error "Deactivating $iname ${version_installed}_$revision_installed failed: $result"
@@ -2234,7 +2247,9 @@
         }
     }
 
-    if {[catch {set result [mportexec $workername install]} result]} {
+    if {$is_dryrun eq "yes"} {
+        ui_msg "Skipping activate $portname @${version_in_tree}_$revision_in_tree$oldvariant (dry run)"
+    } elseif {[catch {set result [mportexec $workername install]} result]} {
         global errorInfo
         ui_debug "$errorInfo"
         ui_error "Couldn't activate $portname ${version_in_tree}_$revision_in_tree$oldvariant: $result"
@@ -2243,7 +2258,9 @@
     
     if { [info exists uninstall_later] && $uninstall_later == yes } {
         ui_debug "Uninstalling $iname ${version_installed}_$revision_installed$oldvariant"
-        if {[catch {portuninstall::uninstall $iname ${version_installed}_$revision_installed$oldvariant $optionslist} result]} {
+        if {$is_dryrun eq "yes"} {
+            ui_msg "Skipping uninstall $iname @${version_installed}_$revision_installed$oldvariant (dry run)"
+        } elseif {[catch {portuninstall::uninstall $iname ${version_installed}_$revision_installed$oldvariant $optionslist} result]} {
             global errorInfo
             ui_debug "$errorInfo"
             ui_error "Uninstall $iname ${version_installed}_$revision_installed$oldvariant failed: $result"

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2008-12-14 02:00:00 UTC (rev 43725)
+++ trunk/base/src/port/port.tcl	2008-12-14 02:14:00 UTC (rev 43726)
@@ -44,7 +44,7 @@
 proc print_usage {args} {
     global cmdname
     set syntax {
-        [-bcdfiknopqRstuvx] [-D portdir] [-F cmdfile] action [privopts] [actionflags]
+        [-bcdfiknopqRstuvxy] [-D portdir] [-F cmdfile] action [privopts] [actionflags]
         [[portname|pseudo-portname|port-url] [@version] [+-variant]... [option=value]...]...
     }
 
@@ -2877,6 +2877,9 @@
                     t {
                         set global_options(ports_trace) yes
                     }
+                    y {
+                        set global_options(ports_dryrun) yes
+                    }
                     F {
                         # Name a command file to process
                         advance

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2008-12-14 02:00:00 UTC (rev 43725)
+++ trunk/base/src/port1.0/portutil.tcl	2008-12-14 02:14:00 UTC (rev 43726)
@@ -1178,9 +1178,11 @@
 
 
 ########### Internal Dependency Manipulation Procedures ###########
+global ports_dry_last_skipped
+set ports_dry_last_skipped ""
 
 proc target_run {ditem} {
-    global target_state_fd portpath portname portversion portrevision portvariants ports_force variations workpath ports_trace PortInfo
+    global target_state_fd portpath portname portversion portrevision portvariants ports_force variations workpath ports_trace PortInfo ports_dryrun ports_dry_last_skipped
     set result 0
     set skipped 0
     set procedure [ditem_key $ditem procedure]
@@ -1244,6 +1246,18 @@
                 
             }
             
+            # Of course, if this is a dry run, don't do the task:
+            if {[info exists ports_dryrun] && $ports_dryrun == "yes"} {
+                # only one message per portname
+                if {$portname != $ports_dry_last_skipped} {
+                    ui_msg "For $portname: skipping $name (dry run)"
+                    set ports_dry_last_skipped $portname
+                } else {
+                    ui_info "    .. and skipping $name"
+                }
+                set skipped 1
+            }
+            
             # otherwise execute the task.
             if {$skipped == 0} {
                 set target [ditem_key $ditem provides]
@@ -1709,7 +1723,7 @@
 }
 
 proc check_variants {variations target} {
-    global ports_force PortInfo
+    global ports_force ports_dryrun PortInfo
     upvar $variations upvariations
     set result 0
     set portname $PortInfo(name)
@@ -1731,7 +1745,7 @@
         if {[check_statefile_variants upvariations $state_fd]} {
             ui_error "Requested variants do not match original selection.\nPlease perform 'port clean $portname' or specify the force option."
             set result 1
-        } else {
+        } elseif {!([info exists ports_dryrun] && $ports_dryrun == "yes")} {
             # Write variations out to the statefile
             foreach key [array names upvariations *] {
             write_statefile variant $upvariations($key)$key $state_fd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081213/e796337b/attachment.html>


More information about the macports-changes mailing list