Ignore:
Timestamp:
Oct 28, 2002, 9:34:43 PM (16 years ago)
Author:
kevin
Message:

Store variants in state file. Print error if state exists with different
set of variants.

File:
1 edited

Legend:

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

    r1164 r1169  
    505505        }
    506506       
    507         if {[check_statefile $name $target_state_fd]} {
     507        if {[check_statefile target $name $target_state_fd]} {
    508508            set result 0
    509509            ui_debug "Skipping completed $name ($portname)"
     
    543543        if {$result == 0} {
    544544            if {[$this get runtype] != "always"} {
    545                 write_statefile $name $target_state_fd
     545                write_statefile target $name $target_state_fd
    546546            }
    547547        } else {
     
    635635
    636636# check_statefile
    637 # Check completed state of target $name
    638 proc check_statefile {name fd} {
     637# Check completed/selected state of target/variant $name
     638proc check_statefile {class name fd} {
    639639    global portpath workdir
    640640   
    641641    seek $fd 0
    642642    while {[gets $fd line] >= 0} {
    643         if {[string equal $line $name]} {
    644             return 1
    645         }
     643                if {$line == "$class: $name"} {
     644                        return 1
     645                }
    646646    }
    647647    return 0
     
    650650# write_statefile
    651651# Set target $name completed in the state file
    652 proc write_statefile {name fd} {
    653     if {[check_statefile $name $fd]} {
    654         return 0
     652proc write_statefile {class name fd} {
     653    if {[check_statefile $class $name $fd]} {
     654                return 0
    655655    }
    656656    seek $fd 0 end
    657     puts $fd $name
     657    puts $fd "$class: $name"
    658658    flush $fd
     659}
     660
     661# check_statefile_variants
     662# Check that recorded selection of variants match the current selection
     663proc check_statefile_variants {variations fd} {
     664        upvar $variations upvariations
     665       
     666    seek $fd 0
     667    while {[gets $fd line] >= 0} {
     668                if {[regexp "variant: (.*)" $line match name]} {
     669                        set oldvariations([string range $name 1 end]) [string range $name 0 0]
     670                }
     671    }
     672
     673        set mismatch 0
     674        if {[array size oldvariations] > 0} {
     675                if {[array size oldvariations] != [array size upvariations]} {
     676                        set mismatch 1
     677                } else {
     678                        foreach key [array names upvariations *] {
     679                                if {$upvariations($key) != $oldvariations($key)} {
     680                                        set mismatch 1
     681                                        break
     682                                }
     683                        }
     684                }
     685        }
     686
     687        return $mismatch
    659688}
    660689
     
    738767}
    739768
    740 proc eval_variants {variations} {
     769proc eval_variants {variations target} {
    741770    global all_variants
    742771    set dlist $all_variants
     772        set result 0
    743773    upvar $variations upvariations
    744774    set chosen [choose_variants $dlist upvariations]
     
    756786   
    757787    dlist_evaluate $newlist generic_get_next
     788       
     789        # Make sure the variations match those stored in the statefile.
     790        # If they don't match, print an error indicating a 'port clean'
     791        # should be performed.  Skip this test if the statefile is empty.
     792        # Also skip this test if performing a clean so we don't shoot
     793        # ourselves in the foot.
     794
     795        if {$target != "clean"} {
     796                set state_fd [open_statefile]
     797       
     798                if {[check_statefile_variants upvariations $state_fd]} {
     799                        ui_error "Requested variants do not match original selection.\nPlease perform 'port clean'."
     800                        set result 1
     801                } else {
     802                        # Write variations out to the statefile
     803                        foreach key [array names upvariations *] {
     804                                write_statefile variant $upvariations($key)$key $state_fd
     805                        }
     806                }
     807               
     808                close $state_fd
     809        }
     810       
     811        return $result
    758812}
    759813
Note: See TracChangeset for help on using the changeset viewer.