Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.189.2.171 -r1.189.2.172 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Nov 2023 15:55:08 -0000 1.189.2.171 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 26 Feb 2024 11:09:06 -0000 1.189.2.172 @@ -3239,7 +3239,7 @@ set sv 1 try { - exec -ignorestderr diff -f $old_f $new_f + exec -ignorestderr [util::which diff] -f $old_f $new_f } on error {output} { } on ok {output} { } @@ -3445,37 +3445,53 @@ @author Gustaf Neumann } { - switch -- $::tcl_platform(platform) { - windows { - # - # Notice: Windows has an alternative search environment - # via registry. Maybe it is necessary in the future - # to locate the program via registry (sketch below) - # - # package require registry - # set key {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths} - # set entries [registry keys $key $prog.*] - # if {[llength $entries]>0} { - # set fullkey "$key\\[lindex $entries 0]" - # return [registry get $fullkey ""] - # } - # return "" - # - set searchdirs [split $::env(PATH) \;] - set exts [list .exe .dll .com .bat] - } - default { - set searchdirs [split $::env(PATH) :] - set exts [list ""] - } + set key ::acs::which($prog) + + if {[info exists $key]} { + return [set $key] } - foreach dir $searchdirs { - set fullname [ad_file join $dir $prog] - foreach ext $exts { - if {[ad_file executable $fullname$ext]} { - return $fullname$ext + if {$prog ne ""} { + + switch -- $::tcl_platform(platform) { + windows { + # + # Notice: Windows has an alternative search environment + # via registry. Maybe it is necessary in the future + # to locate the program via registry (sketch below) + # + # package require registry + # set key {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths} + # set entries [registry keys $key $prog.*] + # if {[llength $entries]>0} { + # set fullkey "$key\\[lindex $entries 0]" + # return [registry get $fullkey ""] + # } + # return "" + # + set searchdirs [split $::env(PATH) \;] + set exts [list .exe .dll .com .bat] } + default { + set searchdirs [split $::env(PATH) :] + set exts [list ""] + } + } + set names [lmap ext $exts {set _ $prog$ext}] + if {[ad_file pathtype $prog] ne "relative"} { + set fullNames $names + } else { + set fullNames {} + foreach dir $searchdirs { + foreach name $names { + lappend fullNames [ad_file join $dir $name] + } + } } + foreach fullName $fullNames { + if {[ad_file executable $fullName]} { + return [set $key $fullName] + } + } } return "" } Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -r1.71.2.59 -r1.71.2.60 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 23 Feb 2024 13:14:08 -0000 1.71.2.59 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 26 Feb 2024 11:09:06 -0000 1.71.2.60 @@ -1549,40 +1549,100 @@ # This test could be used to make sure binaries in use in the code are # actually available to the system. # -# aa_register_case -cats { -# smoke production_safe -# } -procs { -# util::which -# apm_tar_cmd -# apm_gzip_cmd -# db_get_pgbin -# db_name -# } acs_tcl_exec_dependencies { -# Test external command dependencies for this package. -# } { -# set commands [list \ -# [::util::which [apm_tar_cmd]] \ -# [::util::which [apm_gzip_cmd]] \ -# [parameter::get -parameter "HtmlDocBin" -default "/usr/bin/htmldoc"] \ -# [::util::which pdfinfo] \ -# [::util::which diff] \ -# [::util::which dot] \ -# [::util::which gzip] \ -# [::util::which curl] \ -# ] -# if {[db_name] eq "PostgreSQL"} { -# # -# # On a Posgtgres-enabled installation, we also want psql. -# # -# lappend commands [file join [db_get_pgbin] psql] -# } +ad_proc -private _acs_tcl__acs_tcl_external_dependencies_helper {} { +} { + lappend required \ + [apm_gzip_cmd] \ + [apm_tar_cmd] \ + [image::identify_binary] \ + [image::convert_binary] \ + convert \ + curl \ + egrep \ + file \ + gzip \ + gzip \ + identify \ + tar + + lappend optional \ + [parameter::get -parameter "HtmlDocBin" -default "htmldoc"] \ + aspell \ + clamdscan \ + date \ + diff \ + dot \ + find \ + hostname \ + ispell \ + openssl \ + pdfinfo \ + qrencode \ + tail \ + tesseract \ + tidy \ + uptime \ + wget \ + xargs \ + zdump + + if {[db_name] eq "PostgreSQL"} { + # + # On a Posgtgres-enabled installation, we also want psql. + # + lappend required [file join [db_get_pgbin] psql] + } + return [list required $required optional $optional] +} -# foreach cmd $commands { -# aa_true "'$cmd' is executable" [file executable $cmd] -# } -# } +aa_register_case -cats { + smoke production_safe +} -procs { + util::which + apm_tar_cmd + apm_gzip_cmd + db_get_pgbin + db_name + image::identify_binary + image::convert_binary +} acs_tcl_exec_required_dependencies { + Test availability of required external commands. +} { + set d [_acs_tcl__acs_tcl_external_dependencies_helper] + foreach cmd [dict get $d required] { + set fullCmd [::util::which $cmd] + aa_true "'$cmd' exists" {$fullCmd ne ""} + if {$fullCmd ne ""} { + aa_true "'$cmd' is executable" [file executable $fullCmd] + } + } +} + +aa_register_case -cats { + smoke production_safe +} -error_level warning -procs { + util::which + apm_tar_cmd + apm_gzip_cmd + db_get_pgbin + db_name + image::identify_binary + image::convert_binary +} acs_tcl_exec_optional_dependencies { + Test availability of optional external commands. +} { + set d [_acs_tcl__acs_tcl_external_dependencies_helper] + + foreach cmd [dict get $d optional] { + set fullCmd [::util::which $cmd] + aa_true "'$cmd' exists" {$fullCmd ne ""} + if {$fullCmd ne ""} { + aa_true "'$cmd' is executable" [file executable $fullCmd] + } + } +} # Local variables: # mode: tcl # tcl-indent-level: 4