Changeset 142074 for trunk/base


Ignore:
Timestamp:
Nov 3, 2015, 7:41:54 AM (4 years ago)
Author:
jeremyhu@…
Message:

Update checksum suggestion to include the union of Portfile types and default types

File:
1 edited

Legend:

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

    r141176 r142074  
    232232
    233233    # store the calculated checksums to avoid repeated calculations
    234     set sums ""
     234    array set calculated_checksums_array {}
    235235
    236236    # if everything is fine with the syntax, keep on and check the checksum of
     
    252252            }
    253253
    254             if {[llength $all_dist_files] > 1} {
    255                 lappend sums $distfile
    256             }
    257 
    258254            # check that there is at least one checksum for the distfile.
    259255            if {![info exists checksums_array($distfile)] || [llength $checksums_array($distfile)] < 1} {
    260256                ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]"
    261257                set fail yes
    262 
    263                 # no checksums specified; output the default set
    264                 foreach type $default_checksum_types {
    265                     lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
    266                 }
    267 
    268258            } else {
    269259                # retrieve the list of types/values from the array.
    270260                set portfile_checksums $checksums_array($distfile)
     261                set calculated_checksums {}
    271262
    272263                # iterate on this list to check the actual values.
    273264                foreach {type sum} $portfile_checksums {
    274265                    set calculated_sum [calc_$type $fullpath]
    275                     lappend sums [format "%-8s%s" $type $calculated_sum]
     266                    lappend calculated_checksums $type
     267                    lappend calculated_checksums $calculated_sum
    276268
    277269                    # Used for regression testing
     
    289281                    }
    290282                }
     283
     284                # Save our calculated checksums in case we need them later
     285                set calculated_checksums_array($distfile) $calculated_checksums
     286
    291287                if {[tbool fail] && ![regexp {\.html?$} ${distfile}] &&
    292288                    ![catch {strsed [exec [findBinary file $portutil::autoconf::file_path] $fullpath --brief --mime] {s/;.*$//}} mimetype]
     
    320316        } else {
    321317            # Show the desired checksum line for easy cut-paste
    322             ui_info "The correct checksum line may be:"
    323             #ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
    324 
    325             set default_sums {}
     318            # based on the previously calculated values, plus our default types
     319            set sums {}
     320
    326321            foreach distfile $all_dist_files {
    327322                if {[llength $all_dist_files] > 1} {
    328                     lappend default_sums $distfile
    329                 }
    330 
    331                 # get the full path of the distfile.
    332                 set fullpath [file join $distpath $distfile]
    333                 if {![file isfile $fullpath]} {
    334                     if {!$usealtworkpath && [file isfile "${altprefix}${fullpath}"]} {
    335                         set fullpath "${altprefix}${fullpath}"
    336                     } else {
    337                         return -code error "$distfile does not exist in $distpath"
     323                    lappend sums $distfile
     324                }
     325
     326                set missing_types $default_checksum_types
     327
     328                # Append the string for the calculated types and note any of
     329                # our default types that were already calculated
     330                if {[info exists calculated_checksums_array($distfile)] && [llength $calculated_checksums_array($distfile)]} {
     331                    set calculated_checksums $calculated_checksums_array($distfile)
     332                    foreach {type sum} $calculated_checksums {
     333                        lappend sums [format "%-8s%s" $type $sum]
     334
     335                        set found [lsearch -exact ${missing_types} ${type}];
     336                        if { ${found} != -1} {
     337                            set missing_types [lreplace ${missing_types} ${found} ${found}]
     338                        }
    338339                    }
    339340                }
    340341
    341                 foreach type $default_checksum_types {
    342                     lappend default_sums [format "%-8s%s" $type [calc_$type $fullpath]]
    343                 }
    344             }
    345 
    346             ui_info [format "%-20s%s" "checksums" [join $default_sums [format " \\\n%-20s" ""]]]
     342                # Append the string for any of our default types that were
     343                # note previously calculated
     344                if {[llength $missing_types]} {
     345                    # get the full path of the distfile.
     346                    set fullpath [file join $distpath $distfile]
     347                    if {![file isfile $fullpath]} {
     348                        if {!$usealtworkpath && [file isfile "${altprefix}${fullpath}"]} {
     349                            set fullpath "${altprefix}${fullpath}"
     350                        } else {
     351                            return -code error "$distfile does not exist in $distpath"
     352                        }
     353                    }
     354
     355                    foreach type $missing_types {
     356                        lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
     357                    }
     358                }
     359            }
     360
     361            ui_info "The correct checksum line may be:"
     362            ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
    347363        }
    348364
Note: See TracChangeset for help on using the changeset viewer.