Ignore:
Timestamp:
May 1, 2009, 5:41:02 PM (11 years ago)
Author:
jmr@…
Message:

Rewrite logic for skipping install and activate targets when the port is
already installed or active. Fixes #16260. Also removes the need to use -f
when explicitly running a target prior to install for an installed port.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r50193 r50490  
    11891189
    11901190proc target_run {ditem} {
    1191     global target_state_fd portpath portname portversion portrevision portvariants ports_force variations workpath ports_trace PortInfo ports_dryrun ports_dry_last_skipped errorisprivileges
     1191    global target_state_fd portname workpath ports_trace PortInfo ports_dryrun ports_dry_last_skipped errorisprivileges
    11921192    set result 0
    11931193    set skipped 0
     
    12071207        if {$result == 0} {
    12081208            # Skip the step if required and explain why through ui_debug.
    1209             # 1st case: the step was already done (as mentioned in the state file)
     1209            # check if the step was already done (as mentioned in the state file)
    12101210            if {[ditem_key $ditem state] != "no"
    12111211                    && [check_statefile target $name $target_state_fd]} {
    12121212                ui_debug "Skipping completed $name ($portname)"
    12131213                set skipped 1
    1214             # 2nd case: the step is not to always be performed
    1215             # and this exact port/version/revision/variants is already installed
    1216             # and user didn't mention -f
    1217             # and portfile didn't change since installation.
    1218             } elseif {[ditem_key $ditem runtype] != "always"
    1219               && [registry_exists $portname $portversion $portrevision $portvariants]
    1220               && !([info exists ports_force] && $ports_force == "yes")} {
    1221                        
    1222                 # Did the Portfile change since installation?
    1223                 set regref [registry_open $portname $portversion $portrevision $portvariants]
    1224            
    1225                 set installdate [registry_prop_retr $regref date]
    1226                 if { $installdate != 0
    1227                   && $installdate < [file mtime ${portpath}/Portfile]} {
    1228                     ui_debug "Portfile changed since installation"
    1229                 } else {
    1230                     # Say we're skipping.
    1231                     set skipped 1
    1232                
    1233                     ui_debug "Skipping $name ($portname) since this port is already installed"
    1234                 }
    1235            
    1236                 # Something to close the registry entry may be called here, if it existed.
    1237                 # 3rd case: the same port/version/revision/Variants is already active
    1238                 # and user didn't mention -f
    1239             } elseif {$name == "org.macports.activate"
    1240               && [registry_exists $portname $portversion $portrevision $portvariants]
    1241               && !([info exists ports_force] && $ports_force == "yes")} {
    1242            
    1243                 # Is port active?
    1244                 set regref [registry_open $portname $portversion $portrevision $portvariants]
    1245            
    1246                 if { [registry_prop_retr $regref active] != 0 } {
    1247                     # Say we're skipping.
    1248                     set skipped 1
    1249                
    1250                     ui_msg "Skipping $name ($portname $portvariants) since this port is already active"
    1251                 }
    1252                
    12531214            }
    12541215           
     
    14571418
    14581419proc eval_targets {target} {
    1459     global targets target_state_fd portname errorisprivileges
     1420    global targets target_state_fd portname portversion portrevision portvariants ports_dryrun user_options errorisprivileges
    14601421    set dlist $targets
    14611422    set errorisprivileges "no"
     1423   
     1424    # the statefile will likely be autocleaned away after install,
     1425    # so special-case ignore already-completed install and activate
     1426    if {[registry_exists $portname $portversion $portrevision $portvariants]} {
     1427        if {$target == "install"} {
     1428            ui_debug "Skipping $target ($portname) since this port is already installed"
     1429            return 0
     1430        } elseif {$target == "activate"} {
     1431            set regref [registry_open $portname $portversion $portrevision $portvariants]
     1432            if {[registry_prop_retr $regref active] != 0} {
     1433                # Something to close the registry entry may be called here, if it existed.
     1434                ui_debug "Skipping $target ($portname @${portversion}_${portrevision}${portvariants}) since this port is already active"
     1435            } else {
     1436                # do the activate here since target_run doesn't know how to selectively ignore the preceding steps
     1437                if {[info exists ports_dryrun] && $ports_dryrun == "yes"} {
     1438                    ui_msg "For $portname: skipping $target (dry run)"
     1439                } else {
     1440                    registry_activate $portname ${portversion}_${portrevision}${portvariants} [array get user_options]
     1441                }
     1442            }
     1443            return 0
     1444        }
     1445    }
    14621446   
    14631447    # Select the subset of targets under $target
Note: See TracChangeset for help on using the changeset viewer.