📄 inf.tcl
字号:
infputs "INF Processing: will not add display warnings file $warningsFile: $controlvar specified but infVals($controlvar) = 0"
}
}
if {$displayWarning != 0} {
if [catch {open [cdromRootDirGet]\\RESOURCE\\INF\\$warningsFile r} warningsFileId] {
infputs "INF processing: Cannot open warnings file $warningsFile"
return
}
set warningMessage [read $warningsFileId]
messageBox $warningMessage
}
}
#############################################################################
#
# filesCopyLine- copies a file from the values specified from an inf file line
#
# Copies a source file to a destination file. The format of the line read
# from the inf file is as follows (optional parameters in brackets):
#
# source path, destination path, [option], [OS version], [control var]
#
# source path : path of the source file to be copied
# destination path : path of the destination file
# [option] : none | update | overwrite. Set to none by default.
# [OS version] : NT3x, NT4x, or WIN95. Specifies to copy the file only if the
# current OS being used for installation is that which is
# specified.
# If no value is specified the icon will be added for any OS.
# [control var] : conditional control variable allowing file to be copied.
# infVals(control var) must exist and be set to any value other
# than 0.
#
# If [control var] is specified, the global variable infVars(control var)
# must exist and be set to a value other than 0. Otherwise the source file
# will not be copied. This allows for conditional control of copying the source
# file.
#
# SYNOPSIS
# filesCopyLine <line>
#
# PARAMETERS:
# line : a comma delimited line containing the path and values of the file to
# be copied.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc filesCopyLine {line} {
global ctrlVals
global infVals
set sourcePath [nthValueFromCommaDelimitedLine $line 1]
set destinationPath [nthValueFromCommaDelimitedLine $line 2]
set option [nthValueFromCommaDelimitedLine $line 3]
set osversion [nthValueFromCommaDelimitedLine $line 4]
set controlvar [nthValueFromCommaDelimitedLine $line 5]
if {[string compare $option no_value]==0} {
set option none
}
if {[isUnix]} {
set sourcePath [dosToUnix $sourcePath]
set destinationPath [dosToUnix $destinationPath]
}
set docopy 1
# check the os version
switch -exact -- $osversion {
no_value { set docopy 1 }
default {
if {[string compare $osversion $ctrlVals(version)]==0} {
set docopy 1
} else {
set docopy 0
infputs "INF Processing: will not copy file $sourcePath: osversion does not match OS: $osversion"
}
}
}
# check the control variable
if {$docopy == 1} {
if {[string compare $controlvar no_value] != 0} {
if {![info exists infVals($controlvar)]} {
# control variable is specified but does not exist
set docopy 0
infputs "INF processing: will not copy $sourcePath: $controlvar specified but infVals($controlvar) not set"
} elseif {$infVals($controlvar)==0} {
# control variable is set to 0
set docopy 0
infputs "INF processing: will not copy $sourcePath: specified but infVals($controlvar) = 0"
}
}
}
if {$docopy != 0} {
infputs "INF processing: copying file: $sourcePath to $destinationPath"
if {[fileDup $sourcePath $destinationPath $option] == 0} {
infputs "INF processing: could not copy $sourcePath"
}
}
}
#############################################################################
#
# processInfSection - reads and processes an inf file section.
#
# Processes an inf section until the next section or end of file is
# reached. The function to process each data line must be specified.
#
# SYNOPSIS
# processInfSection <addFunction> [prodIndex]
#
# PARAMETERS:
# addFunction : the function that processes each individual line.
# prodIndex : optional product Index. Necessary for the ArFlags section.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc processInfSection {addFunction {prodIndex 0}} {
set sectionOver 0
while {$sectionOver == 0} {
set line [readLine]
set lineType [getLineType $line]
if {[string compare $lineType section_name] == 0} {
set sectionOver 1
} elseif {[string compare $lineType comment] == 0} {
# comment, do nothing
} elseif {[string compare $lineType end_of_file] == 0} {
return
} else {
if {[string compare $addFunction arFlagsLine] == 0} {
# ArFlags is the only function that requires prodIndex
$addFunction $line $prodIndex
} else {
$addFunction $line
}
# check for end of file
if {[endOfFile]} {
return
}
}
}
}
#############################################################################
#
# searchAndProcessSection - searches for and processes an inf file section.
#
# Searches for and processes the specified section of the inf file. The
# procedure first processes the Strings section of the inf file if it has
# not been done already.
#
# SYNOPSIS
# searchAndProcessSection <section> <fileName> [prodIndex]
#
# PARAMETERS:
# section : the name of the INF section to be processed.
# fileName : the name of the INF file.
# prodIndex : optional product Index. Necessary for the ArFlags section.
#
# RETURNS:
# 0 if processing the section was unsuccessful.
# 1 if successful.
#
# ERRORS: N/A
#
proc searchAndProcessSection {section fileName {prodIndex 0}} {
global searchedForStringsSection
if {![info exists searchedForStringsSection($fileName)]} {
set searchedForStringsSection($fileName) 1
searchAndProcessSection Strings $fileName
}
if {![openFile $fileName]} {
infputs "INF processing: cannot open $fileName"
return 0
}
while {[endOfFile] == 0} {
set line [readLine]
set lineType [getLineType $line]
switch -exact -- $lineType {
comment {
# do nothing
}
section_name {
set sectionName [extractSectionName $line]
if {[string compare $sectionName $section] == 0} {
switch -exact -- $sectionName {
AddRegistry {
processInfSection addRegistryLine
}
AddIcon {
processInfSection addIconLine
}
AddService {
processInfSection addServiceLine
}
Strings {
processInfSection addStringsLine
}
FilesCopy {
processInfSection filesCopyLine
}
ArFlags {
processInfSection arFlagsLine $prodIndex
}
CheckPatch {
processInfSection checkPatchLine
}
WarningsFile {
processInfSection warningsFileLine
}
InstallLast {
# no lines necessary to process. Simply return
# 1 since this section name is found.
}
default {
infputs "INF processing: invalid sectionName specified: $sectionName"
closeFile
return 0
}
}
closeFile
return 1
}
}
default {
# data, skip over
}
}
}
closeFile
return 0
}
#############################################################################
#
# chooseInfFile - returns a path to an inf filename.
#
# Given the product index, returns the path to the inf file for the product.
# The inf file resides in RESOURCE\INF and its filename must be
# [PRODUCT NAME].INF (all uppercase).
#
# SYNOPSIS
# chooseInfFile <prodIndex>
#
# PARAMETERS:
# prodIndex : the product index.
#
# RETURNS:
# The path to to the product's inf file.
#
# ERRORS: N/A
#
proc chooseInfFile {prodIndex} {
return [cdFileNameGet [file join RESOURCE INF \
[string toupper [productInfoGet name $prodIndex].INF]\
]]
}
#############################################################################
#
# selectedProductsProcessInfFile - processes the specified INF section for
# all selected products.
#
# This procedure processes the specified INF section for all the products
# the user has selected to install. The special generic file
# ALLPRODUCTS.INF is processed first to carry out actions that should be
# done for any product.
#
# SYNOPSIS
# selectedProductsProcessInffile <section>
#
# PARAMETERS:
# section : name of the INF section to process.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc selectedProductsProcessInfFile {section} {
searchAndProcessSection $section [cdFileNameGet [file join RESOURCE \
INF ALLPRODUCTS.INF]]
foreach prodIndex [cdInfoGet selectedProdIndexList] {
# extract inf file
# extractInfFile [productInfoGet name $prodIndex]/setup.inf
searchAndProcessSection $section [chooseInfFile $prodIndex] $prodIndex
}
}
#############################################################################
#
# extractInfFile - extracts the inf file from WIND.000.
#
# Extracts the specified inf file from WIND.000 and places it in the
# temporary directory.
#
# SYNOPSIS
# extractInfFile <infFile>
#
# PARAMETERS:
# infFile : name of the INF file to extract.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc extractInfFile {infFile} {
set zipFile [cdromZipDirGet]/WIND.000
if {[file exists $zipFile]} {
if ![catch {setupUnzip -o -qq -d [tempDirGet] $zipFile $infFile} retVal] {
} else {
infputs "INF processing: cannot extract $infFile: reason: $retVal"
}
}
}
#############################################################################
#
# infputs - wrapper for puts function.
#
# Wrapper for the puts function. Only prints out the specified string
# if the environment variable INF_DEBUG exists and is set to a nonzero value.
#
# SYNOPSIS
# infputs <line>
#
# PARAMETERS:
# line : string to output.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc infputs {line} {
global env
global setupVals
if {[info exists env(INF_DEBUG)] && $env(INF_DEBUG) != 0} {
if {[info exists setupVals(DBGLOG_FD)]} {
puts $setupVals(DBGLOG_FD) $line
} else {
puts $line
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -