Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 5 Apr 2001 18:23:38 -0000 1.2 @@ -60,10 +60,19 @@ Returns a list of valid file type keys. } { - return [util_memoize [list db_list unused "select file_type_key from apm_package_file_types"]] + return [util_memoize [list db_list file_type_keys "select file_type_key from apm_package_file_types"]] } +ad_proc -public apm_db_type_keys {} { + + Returns a list of valid database type keys. + +} { + return [util_memoize [list db_list db_type_keys "select db_type_key from apm_package_db_types"]] +} + + ad_proc -public apm_package_info_file_path { { -path "" @@ -156,7 +165,7 @@ { -file_id "" } - version_id path file_type + version_id path file_type db_type } { Adds one file into the specified version. @@ -172,7 +181,8 @@ file_id => :file_id, version_id => :version_id, path => :path, - file_type => :file_type + file_type => :file_type, + db_type => :db_type ); end; }] @@ -278,7 +288,8 @@ set components [split $relative_path "/"] set relative_path [join [lrange $components 2 [llength $components]] "/"] set type [apm_guess_file_type $package_key $relative_path] - apm_file_add $version_id $relative_path $type + set db_type [apm_guess_db_type $package_key $relative_path] + apm_file_add $version_id $relative_path $type $db_type } # Remove stale files. @@ -312,12 +323,14 @@ ad_proc -public apm_version_file_list { { - -type "" + -type "" -db_type "" } version_id } { Returns a list of paths to files of a given type (or all files, if - $type is not specified) in a version. + $type is not specified) which support a given database (if specified) in a version. @param type Optionally specifiy what type of files to check, for instance "tcl_procs" + @param db_type Optionally specifiy what type of database support to check, for instance + "postgresql" @param version_id The version to retrieve the file list from. } { @@ -326,10 +339,15 @@ } else { set type_sql "" } + if { ![empty_string_p $db_type] } { + set db_type_sql "and db_type = :db_type" + } else { + set db_type_sql "" + } return [db_list path_select " select path from apm_package_files where version_id = :version_id - $type_sql order by path + $type_sql $db_type_sql order by path "] } @@ -347,6 +365,9 @@ files.
  • Files with extension .sqlj are considered sqlj_code files.
  • Files with extension .info are considered package specification files. +
  • Files with extension .xql are considered query files. +
  • Files with extension .java are considered java code files. +
  • Files with extension .jar are considered java archive files.
  • Files with a path component named doc are considered documentation files.
  • Files with extension .pl or .sh or @@ -358,8 +379,10 @@ level of the package, are considered documentation files.
  • Files with a path component named www or admin-www are considered content-page files. -
  • Files ending in -procs.tcl or -init.tcl are considered +
  • Files ending in -procs(-)+()*.tcl) or -init.tcl are considered Tcl procedure or Tcl initialization files, respectively. +
  • File ending in .tcl are considered Tcl utility script files (normally + found only in the bootstrap installer). Rules are applied in this order (stopping with the first match). @@ -369,10 +392,17 @@ set extension [file extension $path] set type "" + # DRB: someone named a file "acs-mail-create-packages.sql" rather than + # the conventional "acs-mail-packages-create.sql", causing it to be + # recognized as a data_model_create file, causing it to be explicitly + # run by the installer (the author intended it to be included by + # acs-mail-create.sql only). I've tightened up the regexp below to + # avoid this problem, along with renaming the file... + if { [string equal $extension ".sql"] } { if { [lsearch -glob $components "*upgrade-*-*"] >= 0 } { set type "data_model_upgrade" - } elseif { [regexp -- "$package_key-(create|drop)" [file tail $path] "" kind] } { + } elseif { [regexp -- "$package_key-(create|drop)\.sql" [file tail $path] "" kind] } { set type "data_model_$kind" } else { set type "data_model" @@ -381,6 +411,12 @@ set type "sqlj_code" } elseif { [string equal $extension ".info"] } { set type "package_spec" + } elseif { [string equal $extension ".xql"] } { + set type "query_file" + } elseif { [string equal $extension ".java"] } { + set type "java_code" + } elseif { [string equal $extension ".jar"] } { + set type "java_archive" } elseif { [lsearch $components "doc"] >= 0 } { set type "documentation" } elseif { [string equal $extension ".pl"] || \ @@ -396,14 +432,69 @@ } elseif { [lsearch $components "www"] >= 0 || [lsearch $components "admin-www"] >= 0 } { set type "content_page" } else { - if { [string equal $extension ".tcl"] && \ - [regexp -- {-(procs|init)\.tcl$} [file tail $path] "" kind] } { - set type "tcl_$kind" + if { [string equal $extension ".tcl"] } { + if { [regexp -- {-(procs|init)(-[0-9a-zA-Z]*)?\.tcl$} [file tail $path] "" kind] } { + set type "tcl_$kind" + } else { + set type "tcl_util" + } } } return $type } + +ad_proc -private apm_guess_db_type { package_key path } { + + Guesses and returns the database type key corresponding to a particular path + (or an empty string if none is known). $path should be + relative to the package directory (e.g., www/index.tcl + for /packages/bboard/admin-www/index.tcl. + + We consider two cases: + + 1. Data model files. + + If the path contains a string matching "sql/" followed by a database type known + to this version of OpenACS, the file is assumed to be specific to that database type. + The empty string is returned for all other data model files. + + Example: "sql/postgresql/apm-create.sql" is assumed to be the PostgreSQL-specific + file used to create the APM datamodel. + + 2. Other files. + + If the file name contains a dash and database type, the file is assumed to be + specific to that database type. + + Example: "tcl/10-database-postgresql-proc.tcl" is asusmed to be the file that + defines the PostgreSQL-specific portions of the database API. + +} { + set components [split $path "/"] + + if { [string match "data_model*" [apm_guess_file_type $package_key $path]] } { + set sql_index [lsearch $components "sql"] + if { $sql_index >= 0 } { + set db_dir [lindex $components [expr $sql_index + 1]] + foreach known_database_type [db_known_database_types] { + if { [string match [lindex $known_database_type 0] $db_dir] } { + return $db_dir + } + } + } + return "" + } + + set file_name [file tail $path] + foreach known_database_type [db_known_database_types] { + if { [string match "*-[lindex $known_database_type 0]\.*" $file_name] } { + return [lindex $known_database_type 0] + } + } + return "" +} + ad_proc -private apm_ignore_file_p { path } { Return 1 if $path should, in general, be ignored for package operations.