⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filecopy.tcl

📁 WIND_MEDIA_LIBRARY_3_0_3补丁
💻 TCL
📖 第 1 页 / 共 4 页
字号:
# RETURNS: the toolset list, each tool separated by | and sorted so that
#          substrings come last
#          defaultSet if the makefile directories do not exist or no
#          TOOL=<tool> lines are found.  
#
# ERRORS: N/A
#

proc toolsetExtract {} {
    global setupVals

    set toolPattern "TOOL\[ \t\]*=\[ \t\]*"
    set toolFamilyList {gnu diab}
    set toolset ""

    set defaultSet $setupVals(toolSet)

    # save the current directory
    set curDir [pwd]

    set toolDir [file join [destDirGet] target h tool]
    set toolDirExists 0

    if {[file exists $toolDir]} {
        set makefileDir $toolDir

        # get the tool families, which are the directories
        # under target\h\tool except "common"

        if {[catch {
            # catch file operation errors just in case

            cd $toolDir   
            set toolFamilyDirs [glob -nocomplain *]

            } error]} {
            dbgputs "toolsetExtract error: $error"
            uninstLog setupLog "archive error: $error"
            cd $curDir
            return $defaultSet            
        }

        if {$toolFamilyDirs != ""} {
            set toolFamilyList ""
            foreach toolFamily $toolFamilyDirs {
                if {$toolFamily != "common"} {
                    lappend toolFamilyList $toolFamily
                }
            }
        }        
        cd $curDir

        set toolDirExists 1
    } else {
        set makefileDir [file join [destDirGet] target h make]
        if {![file exists $makefileDir]} {
            set errorString "target makefile directories do not exist"
            dbgputs "toolsetExtract error: $errorString"
            uninstLog setupLog  "archive error: $errorString"

            # if makefile directories do not exist, return a default toolset
            # so that Setup can continue

            return $defaultSet
        }    
    }

    if {[catch {   
        # catch file operation errors just in case

        foreach toolFamily $toolFamilyList {
            cd $makefileDir

            if {$toolDirExists == 1} {
                if {[file exists $toolFamily] && 
                    [file isdirectory $toolFamily]} {
                cd $toolFamily
                } else {
                    continue
                }
            }

            foreach f [glob -nocomplain "make.*$toolFamily*"] {
                set fd [open $f r]
                foreach line [split [read $fd] \n] {
                    # skip comments

                    if {[string first \# [string trimleft $line]] == 0} {
                        continue
                    }

                    if {[regexp "($toolPattern)(.*)" $line match toolstring tool]} {
                        # the lsubstringAppend procedure is used to add the
                        # tool string to the toolset list, to ensure that 
                        # substrings of any string in the list are added after
                        # those strings. This is because the toolset is used
                        # as a pattern matcher during archiving to strip out
                        # any existing cpu variant from the "tool" string.
                        # Regexp will match the first string found, so we 
                        # don't want only "sfgnu" extracted out of 
                        # "sfgnule_vr54xx" for example (refer to 
                        # newLibUpdateHelper in LIBUPDTE.TCL).

                        set toolset [lsubstringAppend $toolset $tool]

                        # make sure each tool in the set is unique
                        set toolset [lunique $toolset]
                    }
                }
                close $fd
            }
        }

        # end of catch

        } error]} {
        dbgputs "toolsetExtract error: $error"
        uninstLog setupLog "archive error: $error"
        cd $curDir
        return $defaultSet
    } 
    

    # go back to the current directory
    cd $curDir

    regsub -all " " $toolset "|" toolset

    if {$toolset == ""} {
        set errorString "TOOL settings not found or target makefiles do not exist"
        dbgputs "toolsetExtract error: $errorString"
        uninstLog setupLog "archive error: $errorString"
        return $defaultSet
    }

    return $toolset
}


##############################################################################
#
# archListPut - save the object filename
#
# This procedure checks the provided filename for a special pattent.  If
# matches, the filename will be saved in a global array for later archiving
# step.  The keys of this associated array are the object location, and product
# index.
#
# SYNOPSIS
# archListPut <fileName> <index>
#
# PARAMETERS:
#    fileName : a path filename
#    index : an index to a current product
#
# RETURNS: N/A
#
# ERRORS: N/A
#

proc archListPut {fileName index} {
    global setup_objects
    global setup_libraries
    global newArchive
    global setupVals

    # toolset and typeset can be a set of strings "|" together
    # "sfgnule|gnu..."

    set toolset $setupVals(toolset)
    set typeset "vx"

    if {[regexp "^.*/lib/obj(.*)($toolset)($typeset)(.*)/(.*$)" $fileName \
         junk cpu tool type typex tailFileName] == "1"} {

        set objDir "$index,obj,$cpu,$tool,$type,$typex"

        if [info exists setup_objects($objDir)] {
            if {[lsearch $setup_objects($objDir) $tailFileName] == "-1"} {
                lappend setup_objects($objDir) $tailFileName
            }
        } else {
            set setup_objects($objDir) [list $tailFileName]
        }
    }

    if {[regexp "^.*/lib/lib(.*)($toolset)($typeset)(.*).a" $fileName \
         junk cpu tool type typex] == "1"} {

        set objLib "$index,obj,$cpu,$tool,$type,$typex"
        set setup_libraries($objLib) lib$cpu$tool$type$typex.a
    }


    # For archiving format target/lib/PPC/ppc604/gnu/objcplus/foo.o

    if {[regexp "^.*/lib/(.*)/(.*)/(.*)/obj(.*)/(.*$)" $fileName \
         junk family cpu tool type tailFileName] == "1"} {
 
        set newArchive 1
        set objDir "$index,obj,$family,$cpu,$tool,$type"

        if [info exists setup_objects($objDir)] {
            if {[lsearch $setup_objects($objDir) $tailFileName] == "-1"} {
                lappend setup_objects($objDir) $tailFileName
            }
        } else {
            set setup_objects($objDir) [list $tailFileName]
        }
    }

    if {[regexp "^.*/lib/(.*)/(.*)/(.*)/lib(.*).a" $fileName \
         junk family cpu tool type] == "1"} {

        set objLib "$index,obj,$family,$cpu,$tool,$type"
        set setup_libraries($objLib) lib$type.a
    }
}

##############################################################################
#
# processInstall - process the return value from filesCopy routine
#
# SYNOPSIS
# processInstall <retVal>
#
# PARAMETERS: The return value from call to setupFileExtract in filesCopy
#
# RETURNS: string "break" if EOF encountered, else "NULL".
#
# ERRORS: N/A
#

proc processInstall {retVal fileName prodIndex} {
    global ctrlVals setupVals
    global current_file multipleVersion
    global overwritePolicy donotOverwrite

    set f [destDirGet]/$fileName

    switch $retVal {
        OK {
            uninstLog file "wind_base\t$fileName"

            # Build archList for later updating the archirve.

            archListPut $fileName $prodIndex
            setupFileNext
        }

        EXIST_AND_SAME {
            # Workaround the problem that the base product is
            # reinstalled, and messup the libraries.
            archListPut $fileName $prodIndex

            setupFileNext
        }

        EXIST_AND_NEWER {

            if { [isGUImode] } {
                # do not overwrite if auto install
                if { $ctrlVals(useInputScript) } {
                    archListPut $fileName $prodIndex; \
                    setupFileNext
                    return NULL
                }
            }

            if { [info exists overwritePolicy(ALL)] && $overwritePolicy(ALL) } {
                backup $fileName; \
                set newerFileArray($fileName) ""; \

                set fileRm [fileRemove $f]
                if { $fileRm == "IGNORE"} {
                    setupFileNext
                } elseif { $fileRm == 0 } { 
                    # for TEXT mode, if return value = 0, exit SETUP
                    if { ![isGUImode] } { return 0 }
                }
            } elseif { [info exists donotOverwrite(ALL)] && $donotOverwrite(ALL) } {
                archListPut $fileName $prodIndex; \
                setupFileNext

            } else {

                if { [isGUImode] } {
                    messageBeep -exclamation
                    set ret [dialog file_exists_newer_warn "Setup" \
                                [strTableGet FILESCOPY_FILE_EXISTS_NEWER_WARN] \
                                question 0]
                } else {
                    puts "\n\n[strTableGet FILESCOPY_FILE_EXISTS_NEWER_WARN]\n\n\
                          Choose 0: overwrite the existing file.\n\
                          Choose 1: do not overwrite the existing file.\n\
                          Choose 2: overwrite ALL files, do not prompt about\
                                    this again.
                          Choose 3: do not overwrite ANY newer files, do not\
                                    prompt about this again."
                    set ret [prompt]
                }

                switch -regexp -- $ret {
                    0  {backup $fileName; \
                        set newerFileArray($fileName) ""; \

                        set fileRm [fileRemove $f]

                        while { $fileRm == "RETRY" } {
                            set fileRm [fileRemove $f]
                        }

                        if { $fileRm == "IGNORE" } {
                            setupFileNext
                        } elseif { $fileRm == 0 } { 
                            # for TEXT mode, if return value = 0, exit SETUP
                            if { ![isGUImode] } { return 0 }
                        }
                    } 
                    1  {archListPut $fileName $prodIndex; \
                        setupFileNext
                    }
                    2  {set overwritePolicy(ALL) 1; \
                        backup $fileName; \
                        set newerFileArray($fileName) ""; \

                        set fileRm [fileRemove $f]
                        if { $fileRm == "IGNORE"} {
                            setupFileNext
                        } elseif { $fileRm == 0 } { 
                            # for TEXT mode, if return value = 0, exit SETUP
                            if { ![isGUImode] } { return 0 }
                        }
                    }
                    3  {set donotOverwrite(ALL) 1; \
                        archListPut $fileName $prodIndex; \
                        setupFileNext
                    }
                    "[eE][xX][iI][tT]"  { return 0 } # TEXTmode exit
                }
            }
        }

        EXIST_AND_OLDER {
           backup $fileName; \

           set fileRm [fileRemove $f]
           if { $fileRm == "IGNORE"} {
               setupFileNext
           } elseif { $fileRm == 0 } { 
               # for TEXT mode, if return value = 0, exit SETUP
               if { ![isGUImode] } { return 0 }
           }
        }

        MULTIPLE_VERSION {
            # Setup detected that the file being install has more
            # than one versions on the CD-ROM.

            if ![file exists $f._${prodIndex}_] {
                uninstLog setup "\t$f._${prodIndex}_: does not exist"
                setupFileNext
                return NULL
            }

            if {![info exists multipleVersion($fileName)]} {
                set multipleVersion($fileName) $prodIndex
            } else {
                # Check to see if there is a duplicate prodIndex
                set indexLocate [lsearch -exact \
                    $multipleVersion($fileName) $prodIndex]

                if {$indexLocate == -1} {
                    lappend multipleVersion($fileName) $prodIndex
                }
            }

            setupFileNext
        }

        NOT_FOUND {
            set msg [strTableGet FILESCOPY_DEFLATE_ERROR]
            set logMsg "\terror: cannot copy $fileName: not found"

            if { [isGUImode] } {
                if { $ctrlVals(useInputScript) } {
                    autoSetupLog "$logMsg"
                    autoSetupLog "Application Exit\n"
                    set setupVals(cancel) 1                
                    applicationExit
                    return 0
                }
            }

            if { [isGUImode] } {
                set ret [dialog re_ig_cancel "Setup" $msg question 0]
            } else {
                puts "\n\n$msg\n\nChoose 0: Retry\nChoose 1: Ignore\nChoose 2: Abort\n"
                set ret [prompt]
            }
            switch -- $ret {
                0 { return NULL }
                1 {
                    lastErrorSet $logMsg
                    uninstLog setup $logMsg
                    setupFileNext
                }
                2 {
                    # if TEXT mode, exit
                    if { ![isGUImode] } { return 0 }

                    quitCallback
                }
            }
        }

        ZIP_ERROR {
            set logMsg "\terror: can not copy $fileName: zip error"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -