| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.00-init/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 95/12/06 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Jens Hamisch, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: |
| 14 |
# Sub-Command: |
| 15 |
# |
| 16 |
# Comment: %C{ |
| 17 |
# This module defines all patterns used further in the |
| 18 |
# testsuite |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
# |
| 24 |
# Check setup |
| 25 |
# |
| 26 |
|
| 27 |
send_user "\tInitializing the testsuite ...\n" |
| 28 |
|
| 29 |
# excepted information to run the testsuite |
| 30 |
set TCLSH $env(TCLSH) |
| 31 |
send_user "\tTCLSH is '$TCLSH'\n" |
| 32 |
set MODULECMD $env(MODULECMD) |
| 33 |
send_user "\tMODULECMD is '$MODULECMD'\n" |
| 34 |
|
| 35 |
|
| 36 |
# Modules release number |
| 37 |
set major_minor_rel [join [lrange [split $install_version .] 0 1] .] |
| 38 |
|
| 39 |
set cache_mcookie_version 5.3 |
| 40 |
|
| 41 |
# test kind of sh-shell we have |
| 42 |
if {[file type /bin/sh] eq {link}} { |
| 43 |
set sh_kind [file readlink /bin/sh] |
| 44 |
} else { |
| 45 |
set sh_kind sh |
| 46 |
} |
| 47 |
|
| 48 |
# extract and format os name |
| 49 |
set os_name [string tolower [lindex [split $tcl_platform(os) _] 0]] |
| 50 |
|
| 51 |
# get current terminal width |
| 52 |
proc getTtyCols {} { |
| 53 |
set nbcols {} |
| 54 |
|
| 55 |
switch -- $::os_name { |
| 56 |
{sunos} { |
| 57 |
catch {regexp {columns = (\d+);} [exec stty] match nbcols} errMsg |
| 58 |
} |
| 59 |
default { |
| 60 |
catch {set nbcols [lindex [exec stty size] 1]} errMsg |
| 61 |
} |
| 62 |
} |
| 63 |
return $nbcols |
| 64 |
} |
| 65 |
set nbcols [getTtyCols] |
| 66 |
if {$nbcols ne {} && $nbcols ne {0}} { |
| 67 |
set term_cols $nbcols |
| 68 |
set msg_disp_cols $nbcols |
| 69 |
send_user "\tTerminal has $msg_disp_cols columns\n" |
| 70 |
} else { |
| 71 |
send_user "\tFail to detect terminal column number.\n" |
| 72 |
if {[catch {exec stty rows 60 cols 120} errMsg]} { |
| 73 |
send_user "\tFail to set specific terminal size: $errMsg\n" |
| 74 |
set msg_disp_cols 80 |
| 75 |
send_user "\tFallback to $msg_disp_cols columns\n" |
| 76 |
} else { |
| 77 |
set term_cols 120 |
| 78 |
set msg_disp_cols 120 |
| 79 |
send_user "\tSuccessfully set terminal to 120 columns.\n" |
| 80 |
} |
| 81 |
} |
| 82 |
unset nbcols |
| 83 |
|
| 84 |
proc find_bin {name} { |
| 85 |
set path {} |
| 86 |
|
| 87 |
if {[info exists ::env(PATH)]} { |
| 88 |
foreach dir [split $::env(PATH) ":"] { |
| 89 |
if {[file executable "$dir/$name"]} { |
| 90 |
set path "$dir/$name" |
| 91 |
break |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
return $path |
| 97 |
} |
| 98 |
|
| 99 |
# check SIP is enabled or not on OS X |
| 100 |
if {$os_name eq "darwin"} { |
| 101 |
catch { |
| 102 |
regexp {System Integrity Protection status: enabled.} [exec csrutil status] csrutil_enabled |
| 103 |
} errMsg |
| 104 |
} |
| 105 |
if {[info exists csrutil_enabled]} { |
| 106 |
set sip_enabled 1 |
| 107 |
unset csrutil_enabled |
| 108 |
} else { |
| 109 |
set sip_enabled 0 |
| 110 |
} |
| 111 |
|
| 112 |
# grab fish shell version to check if greater or equal to 3.1 |
| 113 |
if {[set fishbin [lindex [auto_execok fish] 0]] ne {}} { |
| 114 |
regexp {version (.+)$} [exec $fishbin --version] match fish_version |
| 115 |
set fish_version_ge31 [expr {[lindex [lsort -dictionary [list $fish_version 3.1.0]] 0] eq {3.1.0}}] |
| 116 |
set fish_version_ge32 [expr {[lindex [lsort -dictionary [list $fish_version 3.2.0]] 0] eq {3.2.0}}] |
| 117 |
set fish_version_ge40 [expr {[lindex [lsort -dictionary [list $fish_version 4.0.0]] 0] eq {4.0.0}}] |
| 118 |
} |
| 119 |
|
| 120 |
# find ksh flavor |
| 121 |
if {[set kshbin [lindex [auto_execok ksh] 0]] ne {}} { |
| 122 |
set ksh_is_mksh [expr {[string first MIRBSD [exec -ignorestderr $kshbin -c "echo \$KSH_VERSION"]] != -1}] |
| 123 |
} else { |
| 124 |
set ksh_is_mksh 0 |
| 125 |
} |
| 126 |
|
| 127 |
# is FPATH set during autoinit for zsh shell |
| 128 |
set install_setzshfpath [expr {$install_zshcompletiondir eq {} ? {y} : {n}}] |
| 129 |
if {$install_setzshfpath eq {y}} { |
| 130 |
set install_zshcompletiondir $install_initdir/zsh-functions |
| 131 |
} |
| 132 |
|
| 133 |
# locate siteconfig file |
| 134 |
set siteconfig_file "$install_etcdir/siteconfig.tcl" |
| 135 |
set siteconfig_filere [regsub -all "\(\[.+?\]\)" $siteconfig_file {\\\1}] |
| 136 |
|
| 137 |
# determine if siteconfig forces stderr terminal attachment state |
| 138 |
proc siteconfig_isStderrTty {} { |
| 139 |
interp create _siteconfig |
| 140 |
interp eval _siteconfig set ::siteconfig_file "{$::siteconfig_file}" |
| 141 |
set is_stderr_tty [interp eval _siteconfig { |
| 142 |
set is_stderr_tty 0 |
| 143 |
if {[file readable $::siteconfig_file]} { |
| 144 |
# evaluate siteconfig file to check initStateIsStderrTty procedure |
| 145 |
catch { |
| 146 |
source $::siteconfig_file |
| 147 |
if {[info procs initStateIsStderrTty] eq "initStateIsStderrTty"} { |
| 148 |
set is_stderr_tty [initStateIsStderrTty] |
| 149 |
} |
| 150 |
} errorMsg |
| 151 |
} |
| 152 |
return $is_stderr_tty |
| 153 |
}] |
| 154 |
interp delete _siteconfig |
| 155 |
return $is_stderr_tty |
| 156 |
} |
| 157 |
|
| 158 |
# determine if stdin is attached to a tty |
| 159 |
set is_stdin_tty [expr {![catch {fconfigure stdin -mode}]}] |
| 160 |
|
| 161 |
# locate Modules Tcl extension library used during testsuite |
| 162 |
if {$install_libtclenvmodules eq {y}} { |
| 163 |
set tclextlib_file lib/libtclenvmodules$install_shlib_suffix |
| 164 |
set closedirlib_file lib/libtestutil-closedir$install_shlib_suffix |
| 165 |
set getpwuidlib_file lib/libtestutil-getpwuid$install_shlib_suffix |
| 166 |
set getgroupslib_file lib/libtestutil-getgroups$install_shlib_suffix |
| 167 |
set 0getgroupslib_file lib/libtestutil-0getgroups$install_shlib_suffix |
| 168 |
set dupgetgroupslib_file lib/libtestutil-dupgetgroups$install_shlib_suffix |
| 169 |
set getgrgidlib_file lib/libtestutil-getgrgid$install_shlib_suffix |
| 170 |
set timelib_file lib/libtestutil-time$install_shlib_suffix |
| 171 |
set mktimelib_file lib/libtestutil-mktime$install_shlib_suffix |
| 172 |
} |
| 173 |
|
| 174 |
# check file permission capabilities |
| 175 |
set test_perms_dir "$env(TESTSUITEDIR)/etc" |
| 176 |
set test_perms_file "$test_perms_dir/modulerc" |
| 177 |
set orig_perms [file attributes $test_perms_dir -permissions] |
| 178 |
catch {file attributes $test_perms_dir -permissions "ugo-rx"} |
| 179 |
set new_perms [file attributes $test_perms_dir -permissions] |
| 180 |
if {$new_perms eq $orig_perms} { |
| 181 |
set is_file_perms_editable 0 |
| 182 |
} else { |
| 183 |
set is_file_perms_editable 1 |
| 184 |
|
| 185 |
# check if file is readable in a locked directory |
| 186 |
if {[catch { |
| 187 |
set fid [open $test_perms_file r] |
| 188 |
close $fid |
| 189 |
}]} { |
| 190 |
set is_locked_dir_file_readable 0 |
| 191 |
} else { |
| 192 |
set is_locked_dir_file_readable 1 |
| 193 |
} |
| 194 |
file attributes $test_perms_dir -permissions $orig_perms |
| 195 |
|
| 196 |
# check if file is still readable if locked |
| 197 |
set orig_perms [file attributes $test_perms_file -permissions] |
| 198 |
file attributes $test_perms_file -permissions "ugo-rx" |
| 199 |
if {[catch { |
| 200 |
set fid [open $test_perms_file r] |
| 201 |
close $fid |
| 202 |
}]} { |
| 203 |
set is_locked_file_readable 0 |
| 204 |
} else { |
| 205 |
set is_locked_file_readable 1 |
| 206 |
} |
| 207 |
file attributes $test_perms_file -permissions $orig_perms |
| 208 |
} |
| 209 |
unset test_perms_dir |
| 210 |
unset test_perms_file |
| 211 |
unset orig_perms |
| 212 |
unset new_perms |
| 213 |
|
| 214 |
# check if module command is defined prior running tests |
| 215 |
set is_modules_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined module}]}] |
| 216 |
set is_modules_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish module}]}] |
| 217 |
send_user "\tModules is defined in SH env prior tests: $is_modules_defined\n" |
| 218 |
send_user "\tModules is defined in FISH env prior tests: $is_modules_defined_fish\n" |
| 219 |
set is_mogui_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined mogui}]}] |
| 220 |
set is_mogui_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish mogui}]}] |
| 221 |
send_user "\tMoGui is defined in SH env prior tests: $is_mogui_defined\n" |
| 222 |
send_user "\tMoGui is defined in FISH env prior tests: $is_mogui_defined_fish\n" |
| 223 |
|
| 224 |
# check if symbolic link registered in git repository have been effectively |
| 225 |
# created as symbolic link to determine if they are supported on filesystem |
| 226 |
set is_symlink_supported [file isdirectory $env(TESTSUITEDIR)/modulefiles/symlink] |
| 227 |
|
| 228 |
# check if underlying filesystem is case-insensitive |
| 229 |
set is_filesystem_icase [file exists $env(TESTSUITEDIR)/modulefiles.2/ICASE/prereq] |
| 230 |
|
| 231 |
set is_global_rc_file [file isfile $install_etcdir/rc] |
| 232 |
send_user "\tGlobal RC file is [expr {$is_global_rc_file ? {present} : {absent}}]\n" |
| 233 |
|
| 234 |
# check x11 capabilities |
| 235 |
# check where to find the 'xrdb' binary on this system |
| 236 |
set xrdb_notfound_msg {Command 'xrdb' cannot be found} |
| 237 |
set xrdb [auto_execok xrdb] |
| 238 |
if {![string length $xrdb]} { |
| 239 |
set is_xrdb_avail 0 |
| 240 |
set xrdb_issue_msg $xrdb_notfound_msg |
| 241 |
} elseif {[catch {exec $xrdb -query} errMsg]} { |
| 242 |
set is_xrdb_avail 0 |
| 243 |
set xrdb_issue_msg $errMsg |
| 244 |
} else { |
| 245 |
set is_xrdb_avail 1 |
| 246 |
set xrdb_issue_msg $xrdb_notfound_msg |
| 247 |
} |
| 248 |
send_user "\tX11 setup is [expr {$is_xrdb_avail ? {KO} : {OK}}]\n" |
| 249 |
|
| 250 |
# check if domainname binary is available on this system |
| 251 |
set domainname [auto_execok domainname] |
| 252 |
|
| 253 |
# display result of id command |
| 254 |
set idoutput [exec id] |
| 255 |
send_user "\tid output is '$idoutput'\n" |
| 256 |
|
| 257 |
# get current working directory |
| 258 |
set ORIG_CWD [pwd] |
| 259 |
|
| 260 |
# get current username and groups |
| 261 |
set username [exec id -u -n] |
| 262 |
set userid [exec id -u] |
| 263 |
send_user "\tCurrent username is '$username'\n" |
| 264 |
set group_name_fetch_failed 0 |
| 265 |
if {[catch { |
| 266 |
# correctly split groups in case some contain a space character (like on Cygwin/MSYS platforms) |
| 267 |
set usergroups [lsort [split [string range [exec id -G -n -z] 0 end-1] \0]] |
| 268 |
} errMsg]} { |
| 269 |
# fallback to a more generic groups retrieval (in case '-z' option not supported on id) |
| 270 |
if {[catch { |
| 271 |
set usergroups [lsort [exec id -G -n]] |
| 272 |
} errMsg]} { |
| 273 |
set group_name_fetch_failed 1 |
| 274 |
# fallback in case all group names could not be resolved by 'id' command |
| 275 |
# it happens especially when running testsuite through mockbuild |
| 276 |
foreach grpinfo [split [string range [lindex [split $idoutput] 2] 7 end] ,] { |
| 277 |
if {[set idx [string first ( $grpinfo]] != -1} { |
| 278 |
set grp [string range $grpinfo $idx+1 end-1] |
| 279 |
} else { |
| 280 |
set grp $grpinfo |
| 281 |
} |
| 282 |
lappend usergroups $grp |
| 283 |
} |
| 284 |
set usergroups [lsort $usergroups] |
| 285 |
} |
| 286 |
} |
| 287 |
send_user "\tGroups of current user are '$usergroups'\n" |
| 288 |
set userfgroup [lindex $usergroups 0] |
| 289 |
|
| 290 |
set is_mogui_avail [string length [lindex [auto_execok mogui-cmd] 0]] |
| 291 |
|
| 292 |
# Dictionary-style string comparison |
| 293 |
# Use dictionary sort of lsort proc to compare two strings in the "string |
| 294 |
# compare" fashion (returning -1, 0 or 1). Tcl dictionary-style comparison |
| 295 |
# enables to compare software versions (ex: "1.10" is greater than "1.8") |
| 296 |
proc cmpversion {str1 str2} { |
| 297 |
if {$str1 eq $str2} { |
| 298 |
return 0 |
| 299 |
# put both strings in a list, then lsort it and get first element |
| 300 |
} elseif {[lindex [lsort -dictionary [list $str1 $str2]] 0] eq $str1} { |
| 301 |
return -1 |
| 302 |
} else { |
| 303 |
return 1 |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
# report current system information |
| 308 |
send_user "\tMachine hardware name is '$tcl_platform(machine)'\n" |
| 309 |
send_user "\tOS code name is '$tcl_platform(os)'\n" |
| 310 |
send_user "\tOS cleaned name is '$os_name'\n" |
| 311 |
send_user "\tOS version is '$tcl_platform(osVersion)'\n" |
| 312 |
send_user "\tPlatform name is '$tcl_platform(platform)'\n" |
| 313 |
|
| 314 |
# report LSB information |
| 315 |
set lsb_cmd [auto_execok lsb_release] |
| 316 |
if {![string length $lsb_cmd]} { |
| 317 |
send_user "\tNo 'lsb_release' command available\n" |
| 318 |
set lsb_id {} |
| 319 |
set lsb_codename {} |
| 320 |
set lsb_release {} |
| 321 |
} else { |
| 322 |
set lsb_id [exec $lsb_cmd -s -i] |
| 323 |
set lsb_codename [exec $lsb_cmd -s -c] |
| 324 |
set lsb_release [exec $lsb_cmd -s -r] |
| 325 |
send_user "\tLSB id is '$lsb_id'\n" |
| 326 |
send_user "\tLSB release is '$lsb_release'\n" |
| 327 |
send_user "\tLSB codename is '$lsb_codename'\n" |
| 328 |
} |
| 329 |
|
| 330 |
# fetch tclsh version used to adapt tests producing different output depending on this version |
| 331 |
catch {set tclsh_version [exec $TCLSH << {puts [info tclversion]}]} errMsg |
| 332 |
if {[info exists tclsh_version]} { |
| 333 |
send_user "\ttclsh version is $tclsh_version\n" |
| 334 |
} else { |
| 335 |
set tclsh_version 8.6 |
| 336 |
send_user "\tFail to detect tclsh version. Fallback to $tclsh_version version\n$errMsg" |
| 337 |
} |
| 338 |
|
| 339 |
# does configured pager tool allow for pagination |
| 340 |
set pager_dfl_use [expr {[file tail $install_pager] ni {{} cat}}] |
| 341 |
|
| 342 |
|
| 343 |
# |
| 344 |
# Regular expressions matching error and warning outputs |
| 345 |
# |
| 346 |
|
| 347 |
set messages "(\[^(\]+)\[(\]\[0-9\]+\[)\]" |
| 348 |
set error_msgs "ERROR" |
| 349 |
set warn_msgs "WARNING" |
| 350 |
set prob_msgs "$messages:PROB:\[0-9\]+" |
| 351 |
set verb_msgs "$messages:VERB:\[0-9\]+" |
| 352 |
set moderr_msgs "Module $error_msgs" |
| 353 |
set modwarn_msgs "Module $warn_msgs" |
| 354 |
set cacheerr_msgs "Cache $error_msgs" |
| 355 |
set info_msgs "INFO" |
| 356 |
set timer_msgs TIMER |
| 357 |
|
| 358 |
# Used as a line separator inside modules |
| 359 |
set modlin "\[-\]+" |
| 360 |
set sep_line [string repeat - 67] |
| 361 |
|
| 362 |
# List of supported shells |
| 363 |
set sh_shells [list sh bash ksh zsh] |
| 364 |
set csh_shells [list csh tcsh] |
| 365 |
set real_shells [concat $sh_shells $csh_shells [list fish]] |
| 366 |
set other_shells [list tcl cmd perl python ruby lisp cmake r pwsh] |
| 367 |
set supported_shells [concat $real_shells $other_shells] |
| 368 |
|
| 369 |
# Common messages |
| 370 |
set vers_reportre {Modules Release [0-9a-zA-Z\.\+\-_/]+ \([0-9\-]{10}\)} |
| 371 |
set no_loaded {No Modulefiles Currently Loaded.} |
| 372 |
set no_matchingloaded {No Matching Modulefiles Currently Loaded.} |
| 373 |
set cur_loaded {Currently Loaded Modulefiles:} |
| 374 |
set cur_matchingloaded {Currently Loaded Matching Modulefiles:} |
| 375 |
set msg_invcmdname {invalid command name} |
| 376 |
set msg_patheqsep {cannot handle path equals to separator string} |
| 377 |
set msg_multipatheqsep {cannot handle multiple paths equal to separator string} |
| 378 |
set msg_needenvvarname {should get an environment variable name} |
| 379 |
set msg_needenvvarval {should get a value for environment variable} |
| 380 |
set msg_validenvvarname {should get a valid environment variable name} |
| 381 |
set msg_valididxvalue {should get valid number as index value} |
| 382 |
set msg_nonemptydelim {should get a non-empty path delimiter} |
| 383 |
set msg_nomodnameinarg {No module name defined in argument} |
| 384 |
set msg_invversspec {Invalid version specifier} |
| 385 |
set msg_filenameempty {File name empty} |
| 386 |
set msg_collnameempty {Invalid empty collection name} |
| 387 |
set msg_nomodpath {No module path defined} |
| 388 |
set msg_nomodloaded {No module has been loaded} |
| 389 |
set datetimere {[0-9/]{10} [0-9:]{8}} |
| 390 |
set avail_long_headerre "- Package/Alias $modlin.- Versions $modlin.- Last mod. $modlin" |
| 391 |
set list_long_headerre "- Package $modlin.- Versions $modlin.- Last mod. $modlin" |
| 392 |
set savelist_long_headerre "- Collection $modlin.- Last mod. $modlin" |
| 393 |
|
| 394 |
# Common error responses |
| 395 |
set err_path "$error_msgs: Unable to locate a modulefile for " |
| 396 |
set err_file "$error_msgs: No such file or directory on " |
| 397 |
set warn_file "$warn_msgs: No such file or directory on " |
| 398 |
set err_illdir "$error_msgs: [expr {[cmpversion $tclsh_version 9.0] > -1 ? {Is} : {Illegal operation on}}] a directory on " |
| 399 |
set err_notadir "$error_msgs: Not a directory on " |
| 400 |
set err_nomodpath "$error_msgs: $msg_nomodpath" |
| 401 |
set err_magicns "$moderr_msgs: Magic cookie '#%Module' missing\nIn " |
| 402 |
set err_magic "$moderr_msgs: Magic cookie '#%Module' missing\n In " |
| 403 |
set err_magivnovers "$moderr_msgs: Modules version requirement missing\n In " |
| 404 |
set err_contactns "Please contact <root@localhost>" |
| 405 |
set err_contact " $err_contactns" |
| 406 |
set err_typehelp " Try 'module --help' for more information." |
| 407 |
set err_loinconsist "$error_msgs: Loaded environment state is inconsistent" |
| 408 |
set err_emptymodname "$error_msgs: Invalid empty module name" |
| 409 |
set err_emptycollname "$error_msgs: $msg_collnameempty" |
| 410 |
set err_emptydirname "$error_msgs: Invalid empty directory name" |
| 411 |
set err_emptyfilename "$error_msgs: $msg_filenameempty" |
| 412 |
set err_unsatreload "$error_msgs: Cannot reload modules, some of their constraints are not satisfied" |
| 413 |
set err_nodefault "$error_msgs: No default version defined for " |
| 414 |
set err_evalabort "$error_msgs: Module evaluation aborted" |
| 415 |
set warn_evalabort "$warn_msgs: Module evaluation aborted" |
| 416 |
set err_specmodname "$error_msgs: $msg_nomodnameinarg " |
| 417 |
set err_specvers "$error_msgs: $msg_invversspec " |
| 418 |
set err_rangevers "$error_msgs: Invalid version range " |
| 419 |
set err_stickyunload "$::error_msgs: Unload of sticky module skipped" |
| 420 |
set warn_stickyunload "$::warn_msgs: Unload of sticky module skipped" |
| 421 |
set err_stickyunloadf "$::warn_msgs: Unload of sticky module forced" |
| 422 |
set err_superstickyunload "$::error_msgs: Unload of super-sticky module skipped" |
| 423 |
set warn_superstickyunload "$::warn_msgs: Unload of super-sticky module skipped" |
| 424 |
set err_reqfull "$::error_msgs: Module version must be specified to load module" |
| 425 |
set err_nomodloaded "$error_msgs: $msg_nomodloaded" |
| 426 |
set err_modfromdiffpathloaded "$error_msgs: Module already loaded from a different modulepath" |
| 427 |
set err_save_emptyenv "$::error_msgs: Nothing to save in a collection" |
| 428 |
set err_save_unsat "$::error_msgs: Cannot save collection, some module constraints are not satisfied" |
| 429 |
set warn_nostash "$::warn_msgs: No specific environment to save" |
| 430 |
set warn_cache_nowritable "$::warn_msgs: Cannot remove cache file, directory is not writable" |
| 431 |
set warn_cache_build_nowritable "$::warn_msgs: Cannot build cache file, directory is not writable" |
| 432 |
set warn_cache_nothingtorec "$::warn_msgs: Nothing to record in cache file" |
| 433 |
set warn_issue_logging "$::warn_msgs: Issue occurred when logging information" |
| 434 |
|
| 435 |
set x11_warn_prefix "$error_msgs: X11 resources cannot be edited, issue spotted" |
| 436 |
set xrdb_warn "$x11_warn_prefix\n$error_msgs: $xrdb_notfound_msg" |
| 437 |
if {!$is_xrdb_avail} { |
| 438 |
set x11_warn "$x11_warn_prefix\n$error_msgs: $xrdb_issue_msg" |
| 439 |
} |
| 440 |
set domainname_warn "$error_msgs: Command 'domainname' cannot be found" |
| 441 |
set lsb_cmd_err "$error_msgs: Command 'lsb_release' cannot be found" |
| 442 |
|
| 443 |
|
| 444 |
proc err_conflict {args} { |
| 445 |
return "$::error_msgs: Module cannot be loaded due to a conflict. |
| 446 |
HINT: Might try \"module unload [join $args { }]\" first." |
| 447 |
} |
| 448 |
|
| 449 |
proc err_conloi {args} { |
| 450 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 451 |
return "$::error_msgs: Conflicting [join $args { and }] $is loading" |
| 452 |
} |
| 453 |
|
| 454 |
proc err_conloif {args} { |
| 455 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 456 |
return "$::warn_msgs: Conflicting [join $args { and }] $is loading" |
| 457 |
} |
| 458 |
|
| 459 |
proc err_conlo {args} { |
| 460 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 461 |
return "$::error_msgs: Conflicting [join $args { and }] $is loaded" |
| 462 |
} |
| 463 |
|
| 464 |
proc err_conlof {args} { |
| 465 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 466 |
return "$::warn_msgs: Conflicting [join $args { and }] $is loaded" |
| 467 |
} |
| 468 |
|
| 469 |
proc err_conun {args} { |
| 470 |
return "$::error_msgs: Unload of conflicting [join $args { and }] failed" |
| 471 |
} |
| 472 |
|
| 473 |
proc err_conunf {args} { |
| 474 |
return "$::warn_msgs: Unload of conflicting [join $args { and }] failed" |
| 475 |
} |
| 476 |
|
| 477 |
proc err_prereq {args} { |
| 478 |
return "$::error_msgs: Module cannot be loaded due to missing prereq. |
| 479 |
HINT: the following module must be loaded first: [join $args]" |
| 480 |
} |
| 481 |
|
| 482 |
proc err_prereq_path {args} { |
| 483 |
return "$::error_msgs: Module cannot be loaded due to missing prereq (specific path). |
| 484 |
HINT: the following module must be loaded first: [join $args]" |
| 485 |
} |
| 486 |
|
| 487 |
proc err_prereqor {args} { |
| 488 |
return "$::error_msgs: Module cannot be loaded due to missing prereq. |
| 489 |
HINT: at least one of the following modules must be loaded first: $args" |
| 490 |
} |
| 491 |
|
| 492 |
proc err_prereqor_path {args} { |
| 493 |
return "$::error_msgs: Module cannot be loaded due to missing prereq (specific path). |
| 494 |
HINT: at least one of the following modules must be loaded first: $args" |
| 495 |
} |
| 496 |
|
| 497 |
proc err_prerequn {args} { |
| 498 |
return "$::error_msgs: Module cannot be unloaded due to a prereq. |
| 499 |
HINT: Might try \"module unload $args\" first." |
| 500 |
} |
| 501 |
|
| 502 |
proc err_deplo {args} { |
| 503 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 504 |
return "$::error_msgs: Dependent [join $args { and }] $is loaded" |
| 505 |
} |
| 506 |
|
| 507 |
proc err_deploi {args} { |
| 508 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 509 |
return "$::error_msgs: Dependent [join $args { and }] $is loading" |
| 510 |
} |
| 511 |
|
| 512 |
proc err_deplof {args} { |
| 513 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 514 |
return "$::warn_msgs: Dependent [join $args { and }] $is loaded" |
| 515 |
} |
| 516 |
|
| 517 |
proc err_deploif {args} { |
| 518 |
set is [expr {[llength $args] > 1 ? {are} : {is}}] |
| 519 |
return "$::warn_msgs: Dependent [join $args { and }] $is loading" |
| 520 |
} |
| 521 |
|
| 522 |
proc err_reqlo {args} { |
| 523 |
return "$::error_msgs: Load of requirement [join $args { or }] failed" |
| 524 |
} |
| 525 |
|
| 526 |
proc err_reqlo_path {args} { |
| 527 |
return "$::error_msgs: Load of requirement [join $args { or }] (specific path) failed" |
| 528 |
} |
| 529 |
|
| 530 |
proc err_reqlof {args} { |
| 531 |
return "$::warn_msgs: Load of requirement [join $args { or }] failed" |
| 532 |
} |
| 533 |
|
| 534 |
proc err_reqlof_path {args} { |
| 535 |
return "$::warn_msgs: Load of requirement [join $args { or }] (specific path) failed" |
| 536 |
} |
| 537 |
|
| 538 |
proc err_reqmis {args} { |
| 539 |
return "$::error_msgs: Requirement [join $args { or }] is not loaded" |
| 540 |
} |
| 541 |
|
| 542 |
proc err_reqmis_path {args} { |
| 543 |
return "$::error_msgs: Requirement [join $args { or }] (specific path) is not loaded" |
| 544 |
} |
| 545 |
|
| 546 |
proc err_reqmisf {args} { |
| 547 |
return "$::warn_msgs: Requirement [join $args { or }] is not loaded" |
| 548 |
} |
| 549 |
|
| 550 |
proc err_reqmisf_path {args} { |
| 551 |
return "$::warn_msgs: Requirement [join $args { or }] (specific path) is not loaded" |
| 552 |
} |
| 553 |
|
| 554 |
proc err_depun {mod} { |
| 555 |
return "$::error_msgs: Unload of dependent $mod failed" |
| 556 |
} |
| 557 |
|
| 558 |
proc err_depunf {mod} { |
| 559 |
return "$::warn_msgs: Unload of dependent $mod failed" |
| 560 |
} |
| 561 |
|
| 562 |
proc err_urequn {mod} { |
| 563 |
return "$::warn_msgs: Unload of useless requirement $mod failed" |
| 564 |
} |
| 565 |
|
| 566 |
proc err_depre {mod} { |
| 567 |
return "$::error_msgs: Reload of dependent $mod failed" |
| 568 |
} |
| 569 |
|
| 570 |
proc err_depref {mod} { |
| 571 |
return "$::warn_msgs: Reload of dependent $mod failed" |
| 572 |
} |
| 573 |
|
| 574 |
proc err_stickydepre {mod} { |
| 575 |
return "$::error_msgs: Reload of sticky dependent $mod failed" |
| 576 |
} |
| 577 |
|
| 578 |
proc err_depreun {mod} { |
| 579 |
return [err_depun $mod] |
| 580 |
} |
| 581 |
|
| 582 |
proc err_depreunf {mod} { |
| 583 |
return [err_depunf $mod] |
| 584 |
} |
| 585 |
|
| 586 |
proc err_swoff {mod} { |
| 587 |
return "$::error_msgs: Unload of switched-off $mod failed" |
| 588 |
} |
| 589 |
|
| 590 |
proc err_swon {mod} { |
| 591 |
return "$::error_msgs: Load of switched-on $mod failed" |
| 592 |
} |
| 593 |
|
| 594 |
proc err_conflocked {option} { |
| 595 |
return "$::error_msgs: Configuration option '$option' is locked" |
| 596 |
} |
| 597 |
|
| 598 |
proc moderr_minverreq {modfile minver} { |
| 599 |
return "$::moderr_msgs: Modulefile requires at least Modules version $minver\n In '$modfile'\n$::err_contact" |
| 600 |
} |
| 601 |
|
| 602 |
proc moderr_minverreqns {modfile minver} { |
| 603 |
return "$::moderr_msgs: Modulefile requires at least Modules version $minver\nIn '$modfile'\n$::err_contactns" |
| 604 |
} |
| 605 |
|
| 606 |
proc modwarn_minverreqns {modfile minver} { |
| 607 |
return "$::modwarn_msgs: Modulefile requires at least Modules version $minver\nIn '$modfile'\n$::err_contactns" |
| 608 |
} |
| 609 |
|
| 610 |
proc collerr_minverreqns {collfile minver} { |
| 611 |
return "$::error_msgs: Collection $collfile requires at least Modules version $minver" |
| 612 |
} |
| 613 |
|
| 614 |
proc cacheerr_magic {cachefile} { |
| 615 |
return "$::cacheerr_msgs: Magic cookie '#%Module' missing\n In '$cachefile'\n$::err_contact" |
| 616 |
} |
| 617 |
|
| 618 |
proc cacheerr_misverreq {cachefile} { |
| 619 |
return "$::cacheerr_msgs: Modules version requirement missing\n In '$cachefile'\n$::err_contact" |
| 620 |
} |
| 621 |
|
| 622 |
proc cacheerr_minverreq {cachefile minver} { |
| 623 |
return "$::cacheerr_msgs: Cache file requires at least Modules version $minver\n In '$cachefile'\n$::err_contact" |
| 624 |
} |
| 625 |
|
| 626 |
proc moderr_missingmcookiens {modfile} { |
| 627 |
return $::err_magicns'$modfile'\n$::err_contactns |
| 628 |
} |
| 629 |
proc moderr_missingmcookie {modfile} { |
| 630 |
return $::err_magic'$modfile'\n$::err_contact |
| 631 |
} |
| 632 |
|
| 633 |
proc couldnotopen_nofile {file} { |
| 634 |
return "couldn't open \"$file\": no such file or directory" |
| 635 |
} |
| 636 |
|
| 637 |
proc couldnotopen_permdenied {file} { |
| 638 |
return "couldn't open \"$file\": permission denied" |
| 639 |
} |
| 640 |
|
| 641 |
proc err_couldnotopen_permdenied {file} { |
| 642 |
return "$::error_msgs: [couldnotopen_permdenied $file]" |
| 643 |
} |
| 644 |
|
| 645 |
proc couldnotexec_nofile {file} { |
| 646 |
return "couldn't execute \"$file\": no such file or directory" |
| 647 |
} |
| 648 |
|
| 649 |
proc warn_couldnotexec_nofile {file} { |
| 650 |
return "$::warn_msgs: [couldnotexec_nofile $file]" |
| 651 |
} |
| 652 |
|
| 653 |
proc err_permdenied {modfile} { |
| 654 |
return "$::error_msgs: Permission denied on '$modfile'" |
| 655 |
} |
| 656 |
|
| 657 |
proc err_accessdenied {mod {extramsg {}} {pad { }}} { |
| 658 |
set msg "$::error_msgs: Access to module $mod is denied" |
| 659 |
if {$extramsg ne {}} { |
| 660 |
append msg "\n$pad$extramsg" |
| 661 |
} |
| 662 |
return $msg |
| 663 |
} |
| 664 |
|
| 665 |
proc err_accessnearlydenied {date {extramsg {}}} { |
| 666 |
set msg "$::warn_msgs: Access to module will be denied starting '$date'" |
| 667 |
if {$extramsg ne {}} { |
| 668 |
append msg "\n$extramsg" |
| 669 |
} |
| 670 |
return $msg |
| 671 |
} |
| 672 |
|
| 673 |
proc err_unablelocate {mod} { |
| 674 |
return "$::error_msgs: Unable to locate a modulefile for '$mod'" |
| 675 |
} |
| 676 |
|
| 677 |
proc err_noloaded {mod} { |
| 678 |
return "$::error_msgs: No loaded version found for '$mod' module" |
| 679 |
} |
| 680 |
|
| 681 |
proc err_invalvarval {vrname vrvalue vrvalues {padding {}}} { |
| 682 |
return "$::error_msgs: Invalid value '$vrvalue' for variant '$vrname'\n${padding}Allowed values are: $vrvalues" |
| 683 |
} |
| 684 |
|
| 685 |
proc err_novarval {vrname vrvalues {padding {}}} { |
| 686 |
return "$::error_msgs: No value specified for variant '$vrname'\n${padding}Allowed values are: $vrvalues" |
| 687 |
} |
| 688 |
|
| 689 |
proc err_novariantname {vrspec} { |
| 690 |
return "$::error_msgs: No variant name defined in argument '$vrspec'" |
| 691 |
} |
| 692 |
|
| 693 |
proc err_nofreevarval {vrname} { |
| 694 |
return "$::error_msgs: No value specified for variant '$vrname'" |
| 695 |
} |
| 696 |
|
| 697 |
proc invalid_variant_name {vrname} { |
| 698 |
return "Invalid variant name '$vrname'" |
| 699 |
} |
| 700 |
|
| 701 |
proc err_varspec {vrspec} { |
| 702 |
return "$::error_msgs: Invalid variant specification '$vrspec'" |
| 703 |
} |
| 704 |
|
| 705 |
proc err_boolvarval {vrname {padding {}}} { |
| 706 |
return "No value should be defined for boolean variant '$vrname'" |
| 707 |
} |
| 708 |
|
| 709 |
proc err_booldflvarval {vrname {padding {}}} { |
| 710 |
return "Boolean value is expected as default value for variant '$vrname'" |
| 711 |
} |
| 712 |
|
| 713 |
proc err_boolonnonbool {vrname {padding {}}} { |
| 714 |
return "Boolean value defined on non-boolean variant '$vrname'" |
| 715 |
} |
| 716 |
|
| 717 |
proc err_unkvar {vrname} { |
| 718 |
return "$::error_msgs: Unknown variant '$vrname' specified" |
| 719 |
} |
| 720 |
|
| 721 |
proc err_invopt {opt} { |
| 722 |
return "$::error_msgs: Invalid option '$opt'\n$::err_typehelp" |
| 723 |
} |
| 724 |
|
| 725 |
proc err_invcmd {cmd} { |
| 726 |
return "$::error_msgs: Invalid command '$cmd'\n$::err_typehelp" |
| 727 |
} |
| 728 |
|
| 729 |
proc info_alreadyloaded {mod} { |
| 730 |
return "$::info_msgs: Module '$mod' is already loaded" |
| 731 |
} |
| 732 |
|
| 733 |
proc info_notloaded {mod} { |
| 734 |
return "$::info_msgs: Module '$mod' is not loaded" |
| 735 |
} |
| 736 |
|
| 737 |
proc err_othervariantloaded {vrlist {setsgr 0} {is_loading 0}} { |
| 738 |
if {$setsgr} { |
| 739 |
set vrdesiglist {} |
| 740 |
foreach vr $vrlist { |
| 741 |
lappend vrdesiglist [sgr 93]$vr[sgr 0] |
| 742 |
} |
| 743 |
set vrdesig [sgr 2]\{[sgr 22][join $vrdesiglist [sgr 2]:[sgr 22]][sgr 2]\}[sgr 22] |
| 744 |
} else { |
| 745 |
set vrdesig "{[join $vrlist :]}" |
| 746 |
} |
| 747 |
set state [expr {$is_loading ? {loading} : {loaded}}] |
| 748 |
return "$::error_msgs: Variant $vrdesig is already $state" |
| 749 |
} |
| 750 |
|
| 751 |
proc err_extraspec {xtspec} { |
| 752 |
return "$::error_msgs: Invalid extra specification '$xtspec'" |
| 753 |
} |
| 754 |
|
| 755 |
proc err_extraspecifier {xtspec} { |
| 756 |
return "$::error_msgs: Invalid extra specifier '$xtspec'\n Valid extra\ |
| 757 |
specifiers are: always-load append-path chdir complete conflict\ |
| 758 |
depends-on depends-on-any envvar family incompat load load-any\ |
| 759 |
prepend-path prereq prereq-all prereq-any provide provided-alias\ |
| 760 |
pushenv remove-path require set-alias set-function setenv switch\ |
| 761 |
switch-on switch-off tag try-load uncomplete unload unset-alias\ |
| 762 |
unset-function unsetenv use variant" |
| 763 |
} |
| 764 |
|
| 765 |
proc err_xtspec_notallowed {} { |
| 766 |
return "$::error_msgs: No extra specification allowed on this command" |
| 767 |
} |
| 768 |
|
| 769 |
proc err_tagmanset {tag} { |
| 770 |
return "$::error_msgs: Tag '$tag' cannot be manually set" |
| 771 |
} |
| 772 |
|
| 773 |
proc err_misoptval {opt} { |
| 774 |
return "$::error_msgs: Missing value for '$opt' option" |
| 775 |
} |
| 776 |
|
| 777 |
proc err_unsupportedshell {shell} { |
| 778 |
return "$::error_msgs: Unsupported shell type '$shell'" |
| 779 |
} |
| 780 |
|
| 781 |
proc err_unsupportedopt {opt subcmd} { |
| 782 |
return "$::error_msgs: Unsupported option '$opt' on $subcmd sub-command" |
| 783 |
} |
| 784 |
|
| 785 |
proc err_coll_notfound {coll {target {}}} { |
| 786 |
if {$target ne {}} { |
| 787 |
set targetmsg "(for target \"$target\") " |
| 788 |
} else { |
| 789 |
set targetmsg {} |
| 790 |
} |
| 791 |
return "$::error_msgs: Collection $coll ${targetmsg}cannot be found" |
| 792 |
} |
| 793 |
|
| 794 |
proc err_coll_notvalid {coll} { |
| 795 |
return "$::error_msgs: $coll is not a valid collection" |
| 796 |
} |
| 797 |
|
| 798 |
proc err_stash_index {idx} { |
| 799 |
return "$::error_msgs: Invalid stash index '$idx'" |
| 800 |
} |
| 801 |
|
| 802 |
proc err_stash_name {name} { |
| 803 |
return "$::error_msgs: Invalid stash collection name '$name'" |
| 804 |
} |
| 805 |
|
| 806 |
proc msg_named_coll {{matching 0} {target {}}} { |
| 807 |
if {$matching} { |
| 808 |
set msg {Matching named } |
| 809 |
} else { |
| 810 |
set msg {Named } |
| 811 |
} |
| 812 |
append msg {collection list} |
| 813 |
if {$target ne {}} { |
| 814 |
append msg " (for target \"$target\")" |
| 815 |
} |
| 816 |
append msg : |
| 817 |
return $msg |
| 818 |
} |
| 819 |
|
| 820 |
proc msg_no_named_coll {{matching 0} {target {}}} { |
| 821 |
if {$matching} { |
| 822 |
set msg {No matching } |
| 823 |
} else { |
| 824 |
set msg {No } |
| 825 |
} |
| 826 |
append msg {named collection} |
| 827 |
if {$target ne {}} { |
| 828 |
append msg " (for target \"$target\")" |
| 829 |
} |
| 830 |
append msg . |
| 831 |
return $msg |
| 832 |
} |
| 833 |
|
| 834 |
proc msg_stash_coll {{target {}}} { |
| 835 |
set msg {Stash collection list} |
| 836 |
if {$target ne {}} { |
| 837 |
append msg " (for target \"$target\")" |
| 838 |
} |
| 839 |
append msg : |
| 840 |
return $msg |
| 841 |
} |
| 842 |
|
| 843 |
proc msg_no_stash_coll {{target {}}} { |
| 844 |
set msg {No stash collection} |
| 845 |
if {$target ne {}} { |
| 846 |
append msg " (for target \"$target\")" |
| 847 |
} |
| 848 |
append msg . |
| 849 |
return $msg |
| 850 |
} |
| 851 |
|
| 852 |
proc msg_modwarn {msg cmdline modfile linenum {pad {}} {procname {}} {contact {}} {custom {}} {custom2 {while executing}}} { |
| 853 |
return [msg_moderr $msg $cmdline $modfile $linenum $pad $procname $contact $custom $custom2 {Module WARNING}] |
| 854 |
} |
| 855 |
|
| 856 |
proc msg_moderr {msg cmdline modfile linenum {pad {}} {procname {}} {contact {}} {custom {}} {custom2 {while executing}} {title {Module ERROR}}} { |
| 857 |
|
| 858 |
set linefile [expr {$procname ne {} || $linenum eq {} ? {} : " line $linenum"}] |
| 859 |
set errcontact [expr {$contact eq {} ? $::err_contactns : "Please contact <$contact>"}] |
| 860 |
set res "$title: $msg |
| 861 |
$pad $custom2 |
| 862 |
$pad\"$cmdline\"" |
| 863 |
if {$procname ne {}} { |
| 864 |
append res " |
| 865 |
$pad (procedure \"$procname\" line $linenum) |
| 866 |
$pad invoked from within |
| 867 |
$pad\"$procname\"" |
| 868 |
} |
| 869 |
if {$custom ne {}} { |
| 870 |
foreach custline [split $custom \n] { |
| 871 |
append res "\n$pad$custline" |
| 872 |
} |
| 873 |
} |
| 874 |
append res " |
| 875 |
$pad (file \"$modfile\"$linefile) |
| 876 |
$pad$errcontact" |
| 877 |
return $res |
| 878 |
} |
| 879 |
|
| 880 |
proc msg_cacheerr {msg cmdline modfile linenum {custom {while executing}}} { |
| 881 |
set res "$::cacheerr_msgs: $msg |
| 882 |
$custom |
| 883 |
\"$cmdline\"" |
| 884 |
append res " |
| 885 |
(file \"$modfile\" line $linenum) |
| 886 |
$::err_contactns" |
| 887 |
return $res |
| 888 |
} |
| 889 |
|
| 890 |
proc is_conf_enabled {args} { |
| 891 |
foreach conf $args { |
| 892 |
if {[set ::install_$conf] ne {y}} { |
| 893 |
return 0 |
| 894 |
} |
| 895 |
} |
| 896 |
return 1 |
| 897 |
} |
| 898 |
|
| 899 |
proc if_implicitdefault {then {else {}}} { |
| 900 |
return [expr {$::install_implicitdefault eq {y} ? $then : $else}] |
| 901 |
} |
| 902 |
|
| 903 |
proc if_availindepth {then {else {}}} { |
| 904 |
return [expr {$::install_availindepth eq {y} ? $then : $else}] |
| 905 |
} |
| 906 |
|
| 907 |
proc if_searchcontains {then {else {}}} { |
| 908 |
return [expr {$::install_searchmatch eq {contains} ? $then : $else}] |
| 909 |
} |
| 910 |
|
| 911 |
proc if_configlocked {option then {else {}}} { |
| 912 |
return [expr {[is_config_locked $option] ? $then : $else}] |
| 913 |
} |
| 914 |
|
| 915 |
proc is_config_locked {option} { |
| 916 |
return [expr {[lsearch -exact $::install_lockedconfigs $option] != -1}] |
| 917 |
} |
| 918 |
|
| 919 |
proc is_real_shell {shell} { |
| 920 |
return [expr {[lsearch -exact $::real_shells $shell] != -1}] |
| 921 |
} |
| 922 |
|
| 923 |
# helper procedures to format block message output |
| 924 |
proc msg_block_content {args} { |
| 925 |
set msg {} |
| 926 |
foreach arg $args { |
| 927 |
set first 1 |
| 928 |
set padding { } |
| 929 |
|
| 930 |
set max_idx [expr {$::msg_disp_cols - [string length $padding]}] |
| 931 |
set linelist [list] |
| 932 |
foreach line [split $arg \n] { |
| 933 |
set lineadd {} |
| 934 |
while {$lineadd ne $line} { |
| 935 |
# no split if no whitespace found to slice |
| 936 |
if {[string length $line] > $max_idx && [set cut_idx [string\ |
| 937 |
last { } $line $max_idx]] != -1} { |
| 938 |
set lineadd [string range $line 0 [expr {$cut_idx-1}]] |
| 939 |
set line [string range $line [expr {$cut_idx+1}] end] |
| 940 |
} else { |
| 941 |
set lineadd $line |
| 942 |
} |
| 943 |
lappend linelist $lineadd |
| 944 |
if {$first} { |
| 945 |
set first 0 |
| 946 |
incr max_idx -[string length $padding] |
| 947 |
} |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
# display each line |
| 952 |
set first 1 |
| 953 |
foreach line $linelist { |
| 954 |
append msg \n |
| 955 |
if {$first} { |
| 956 |
set first 0 |
| 957 |
} else { |
| 958 |
append msg $padding |
| 959 |
} |
| 960 |
append msg "$padding$line" |
| 961 |
} |
| 962 |
} |
| 963 |
return $msg |
| 964 |
} |
| 965 |
|
| 966 |
proc msg_load {mod args} { |
| 967 |
set msg "Loading $mod" |
| 968 |
append msg [eval msg_block_content $args] |
| 969 |
return $msg |
| 970 |
} |
| 971 |
|
| 972 |
proc msg_unload {mod args} { |
| 973 |
set msg "Unloading $mod" |
| 974 |
append msg [eval msg_block_content $args] |
| 975 |
return $msg |
| 976 |
} |
| 977 |
|
| 978 |
proc msg_switch {old new args} { |
| 979 |
set msg "Switching from $old to $new" |
| 980 |
append msg [eval msg_block_content $args] |
| 981 |
return $msg |
| 982 |
} |
| 983 |
|
| 984 |
proc msg_refresh {mod args} { |
| 985 |
set msg "Refreshing $mod" |
| 986 |
append msg [eval msg_block_content $args] |
| 987 |
return $msg |
| 988 |
} |
| 989 |
|
| 990 |
proc msg_tag {mod args} { |
| 991 |
set msg "Tagging $mod" |
| 992 |
append msg [eval msg_block_content $args] |
| 993 |
return $msg |
| 994 |
} |
| 995 |
|
| 996 |
proc msg_lint {mod args} { |
| 997 |
set msg "Linting $mod" |
| 998 |
append msg [eval msg_block_content $args] |
| 999 |
return $msg |
| 1000 |
} |
| 1001 |
|
| 1002 |
proc msg_delete {mod args} { |
| 1003 |
set msg "Deleting $mod" |
| 1004 |
append msg [eval msg_block_content $args] |
| 1005 |
return $msg |
| 1006 |
} |
| 1007 |
|
| 1008 |
proc msg_create {mod args} { |
| 1009 |
set msg "Creating $mod" |
| 1010 |
append msg [eval msg_block_content $args] |
| 1011 |
return $msg |
| 1012 |
} |
| 1013 |
|
| 1014 |
proc msg_top_load {mod unlist reqlolist deprelist args} { |
| 1015 |
lassign [mix_depre_depun_list $deprelist {}] deprelist depunlist |
| 1016 |
|
| 1017 |
if {[llength $depunlist]} { |
| 1018 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1019 |
} |
| 1020 |
if {[llength $unlist]} { |
| 1021 |
lappend args "Unloading conflict: [join $unlist]" |
| 1022 |
} |
| 1023 |
if {[llength $reqlolist]} { |
| 1024 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1025 |
} |
| 1026 |
if {[llength $deprelist]} { |
| 1027 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1028 |
} |
| 1029 |
return [eval msg_load "{$mod}" $args] |
| 1030 |
} |
| 1031 |
|
| 1032 |
proc msg_top_load_conun_noauto {mod depunlist unlist urequnlist reqlolist deprelist args} { |
| 1033 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1034 |
|
| 1035 |
if {[llength $depunlist]} { |
| 1036 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1037 |
} |
| 1038 |
if {[llength $unlist]} { |
| 1039 |
lappend args "Unloading conflict: [join $unlist]" |
| 1040 |
} |
| 1041 |
if {[llength $urequnlist]} { |
| 1042 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1043 |
} |
| 1044 |
if {[llength $reqlolist]} { |
| 1045 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1046 |
} |
| 1047 |
if {[llength $deprelist]} { |
| 1048 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1049 |
} |
| 1050 |
return [eval msg_load "{$mod}" $args] |
| 1051 |
} |
| 1052 |
|
| 1053 |
proc msg_top_load_conun {mod depunlist unlist urequnlist reqlolist deprelist args} { |
| 1054 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1055 |
|
| 1056 |
if {[llength $depunlist]} { |
| 1057 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1058 |
} |
| 1059 |
if {[llength $unlist]} { |
| 1060 |
lappend args "Unloading conflict: [join $unlist]" |
| 1061 |
} |
| 1062 |
if {[llength $reqlolist]} { |
| 1063 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1064 |
} |
| 1065 |
if {[llength $urequnlist]} { |
| 1066 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1067 |
} |
| 1068 |
if {[llength $deprelist]} { |
| 1069 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1070 |
} |
| 1071 |
return [eval msg_load "{$mod}" $args] |
| 1072 |
} |
| 1073 |
|
| 1074 |
proc msg_top_unload {mod depunlist urequnlist deprelist args} { |
| 1075 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1076 |
if {[llength $depunlist]} { |
| 1077 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1078 |
} |
| 1079 |
if {[llength $urequnlist]} { |
| 1080 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1081 |
} |
| 1082 |
if {[llength $deprelist]} { |
| 1083 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1084 |
} |
| 1085 |
return [eval msg_unload "{$mod}" $args] |
| 1086 |
} |
| 1087 |
|
| 1088 |
proc msg_top_switch_noauto {old new depunlist urequnlist unlist reqlolist deprelist args} { |
| 1089 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1090 |
|
| 1091 |
if {[llength $depunlist]} { |
| 1092 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1093 |
} |
| 1094 |
if {[llength $unlist]} { |
| 1095 |
lappend args "Unloading conflict: [join $unlist]" |
| 1096 |
} |
| 1097 |
if {[llength $urequnlist]} { |
| 1098 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1099 |
} |
| 1100 |
if {[llength $reqlolist]} { |
| 1101 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1102 |
} |
| 1103 |
if {[llength $deprelist]} { |
| 1104 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1105 |
} |
| 1106 |
return [eval msg_switch "{$old}" "{$new}" $args] |
| 1107 |
} |
| 1108 |
|
| 1109 |
proc msg_top_switch {old new depunlist urequnlist unlist reqlolist deprelist args} { |
| 1110 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1111 |
|
| 1112 |
if {[llength $depunlist]} { |
| 1113 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1114 |
} |
| 1115 |
if {[llength $unlist]} { |
| 1116 |
lappend args "Unloading conflict: [join $unlist]" |
| 1117 |
} |
| 1118 |
if {[llength $reqlolist]} { |
| 1119 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1120 |
} |
| 1121 |
if {[llength $urequnlist]} { |
| 1122 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1123 |
} |
| 1124 |
if {[llength $deprelist]} { |
| 1125 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1126 |
} |
| 1127 |
return [eval msg_switch "{$old}" "{$new}" $args] |
| 1128 |
} |
| 1129 |
|
| 1130 |
proc msg_top_switch_conun {old new depunlist urequnlist unlist reqlolist deprelist args} { |
| 1131 |
lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist |
| 1132 |
|
| 1133 |
if {[llength $depunlist]} { |
| 1134 |
lappend args "Unloading dependent: [join $depunlist]" |
| 1135 |
} |
| 1136 |
if {[llength $unlist]} { |
| 1137 |
lappend args "Unloading conflict: [join $unlist]" |
| 1138 |
} |
| 1139 |
if {[llength $urequnlist]} { |
| 1140 |
lappend args "Unloading useless requirement: [join $urequnlist]" |
| 1141 |
} |
| 1142 |
if {[llength $reqlolist]} { |
| 1143 |
lappend args "Loading requirement: [join $reqlolist]" |
| 1144 |
} |
| 1145 |
if {[llength $deprelist]} { |
| 1146 |
lappend args "Reloading dependent: [join $deprelist]" |
| 1147 |
} |
| 1148 |
return [eval msg_switch "{$old}" "{$new}" $args] |
| 1149 |
} |
| 1150 |
|
| 1151 |
proc mix_depre_depun_list {deprelist depunlist} { |
| 1152 |
# dependent reload unload phase appears with dependent unload (in actual unload order) |
| 1153 |
# if some dependent fail to unload, 1 unload list and 1 reload list could be passed |
| 1154 |
if {[llength $deprelist] == 2 && [llength [set depreun [lindex $deprelist 0]]] !=\ |
| 1155 |
[llength [set deprelo [lindex $deprelist 1]]]} { |
| 1156 |
set depunlist [concat $depreun $depunlist] |
| 1157 |
set deprelist $deprelo |
| 1158 |
} else { |
| 1159 |
set depunlist [concat [lreverse $deprelist] $depunlist] |
| 1160 |
} |
| 1161 |
return [list $deprelist $depunlist] |
| 1162 |
} |
| 1163 |
|
| 1164 |
proc sgr {code} { |
| 1165 |
return "\033\\\[${code}m" |
| 1166 |
} |
| 1167 |
|
| 1168 |
# escape regexp chars in string |
| 1169 |
proc escre {str} { |
| 1170 |
return [string map {<EXM> (.*)+} [regsub -all {([.?*()+\[\]$])} $str {\\\1}]] |
| 1171 |
} |
| 1172 |
|
| 1173 |
proc create_stash_coll {content} { |
| 1174 |
set colldir $::env(HOME)/.module |
| 1175 |
if {![file exists $colldir]} { |
| 1176 |
file mkdir $colldir |
| 1177 |
} |
| 1178 |
set coll stash-[clock milliseconds] |
| 1179 |
if {[info exists ::env(MODULES_COLLECTION_TARGET)]} { |
| 1180 |
append coll .$::env(MODULES_COLLECTION_TARGET) |
| 1181 |
} |
| 1182 |
send_user "\tCreating stash collection $colldir/$coll\n" |
| 1183 |
set fid [open $colldir/$coll w] |
| 1184 |
puts $fid $content |
| 1185 |
close $fid |
| 1186 |
} |
| 1187 |
|
| 1188 |
proc delete_last_stash_coll {} { |
| 1189 |
set collfile [lindex [lsort [glob $::env(HOME)/.module/stash-*]] 0] |
| 1190 |
send_user "\tDeleting stash collection $collfile\n" |
| 1191 |
file delete $collfile |
| 1192 |
} |
| 1193 |
|
| 1194 |
# fetch stash collections |
| 1195 |
proc get_all_stash_colls {} { |
| 1196 |
return [glob -types f $::env(HOME)/.module/stash-*] |
| 1197 |
} |
| 1198 |
|
| 1199 |
proc get_last_stash_coll {} { |
| 1200 |
return [lindex [lsort [get_all_stash_colls]] end] |
| 1201 |
} |
| 1202 |
|
| 1203 |
proc create_dummy_cachefile {mp} { |
| 1204 |
set cachefile $mp/.modulecache |
| 1205 |
send_user "\tCreating dummy cache file $cachefile\n" |
| 1206 |
set fid [open $cachefile w] |
| 1207 |
puts $fid "#%Module$::cache_mcookie_version" |
| 1208 |
close $fid |
| 1209 |
} |
| 1210 |
|
| 1211 |
proc create_dummy_modulefile {modfile} { |
| 1212 |
send_user "\tCreating dummy module file $modfile\n" |
| 1213 |
set fid [open $modfile w] |
| 1214 |
puts $fid {#%Module} |
| 1215 |
close $fid |
| 1216 |
} |
| 1217 |
|
| 1218 |
# create test modulefiles on the fly as those files finishing by a space character cannot |
| 1219 |
# be recorded in git repository (checkout will fail on Windows platform) |
| 1220 |
proc create_endspace_test_modulefiles {} { |
| 1221 |
set mp $::modpath.2 |
| 1222 |
set module {space y } |
| 1223 |
|
| 1224 |
file mkdir $mp/$module |
| 1225 |
|
| 1226 |
set fid [open $mp/$module/.modulerc w] |
| 1227 |
puts $fid {#%Module |
| 1228 |
module-version {space y /1 } {n } |
| 1229 |
module-version {space y /2.2} default |
| 1230 |
module-alias {space y /a } {space y /1 } |
| 1231 |
module-virtual {space y /v } {./1 }} |
| 1232 |
close $fid |
| 1233 |
|
| 1234 |
foreach f [list {1 } 2.2 2.5 2.7 2.10] { |
| 1235 |
set fid [open $mp/$module/$f w] |
| 1236 |
puts $fid {#%Module |
| 1237 |
module-whatis [module-info name]} |
| 1238 |
close $fid |
| 1239 |
} |
| 1240 |
|
| 1241 |
# do not rely on cache if prebuilt |
| 1242 |
ignore_modulecache_if_built |
| 1243 |
} |
| 1244 |
|
| 1245 |
proc delete_endspace_test_modulefiles {} { |
| 1246 |
set mp $::modpath.2 |
| 1247 |
set module {space y } |
| 1248 |
foreach f [list .modulerc {1 } 2.2 2.5 2.7 2.10] { |
| 1249 |
file delete $mp/$module/$f |
| 1250 |
} |
| 1251 |
file delete $mp/$module |
| 1252 |
|
| 1253 |
# can reuse prebuilt cache if any now temporary modules are deleted |
| 1254 |
end_ignore_modulecache_if_built |
| 1255 |
} |
| 1256 |
|
| 1257 |
# ensure next tests will ignore cache files if modulecache have been built |
| 1258 |
proc ignore_modulecache_if_built {} { |
| 1259 |
if {[info exists ::env(TESTSUITE_ENABLE_MODULECACHE)]} { |
| 1260 |
send_user "\tIgnore module cache files on next tests\n" |
| 1261 |
setenv_var MODULES_IGNORE_CACHE 1 |
| 1262 |
} |
| 1263 |
} |
| 1264 |
|
| 1265 |
proc end_ignore_modulecache_if_built {} { |
| 1266 |
if {[info exists ::env(TESTSUITE_ENABLE_MODULECACHE)]} { |
| 1267 |
send_user "\tUse cache files again on next tests\n" |
| 1268 |
unsetenv_var MODULES_IGNORE_CACHE |
| 1269 |
} |
| 1270 |
} |