Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl,v diff -u -r1.108.2.17 -r1.108.2.18 --- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 12 Aug 2014 19:25:51 -0000 1.108.2.17 +++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 12 Aug 2014 19:30:57 -0000 1.108.2.18 @@ -24,7 +24,7 @@ } { if { $path eq "" } { - set path "[apm_workspace_install_dir]" + set path [apm_workspace_install_dir] } ### Scan for all unregistered .info files. @@ -34,50 +34,50 @@ # Loop through all directories in the /packages directory, searching each for a # .info file. foreach dir [lsort [glob -nocomplain "$path/*"]] { - set package_key [file tail $dir] - if { ![file isdirectory $dir] } { - continue - } - if { [apm_ignore_file_p $dir] } { - apm_callback_and_log $callback "Skipping the directory \"$package_key\"." - continue - } + set package_key [file tail $dir] + if { ![file isdirectory $dir] } { + continue + } + if { [apm_ignore_file_p $dir] } { + apm_callback_and_log $callback "Skipping the directory \"$package_key\"." + continue + } - # At this point, we should have a directory that is equivalent to a package_key. - if { [apm_package_installed_p $package_key] } { - if {$new_p} { - continue - } - } - - # Locate the .info file for this package. - if { [catch { set info_file [apm_package_info_file_path -path $path $package_key] } error] } { - apm_callback_and_log -severity Warning $callback "Unable to locate specification file for package $package_key: $error" - continue - } - # We found the .info file. - lappend new_spec_files $info_file - } + # At this point, we should have a directory that is equivalent to a package_key. + if { [apm_package_installed_p $package_key] } { + if {$new_p} { + continue + } + } + # Locate the .info file for this package. + if { [catch { set info_file [apm_package_info_file_path -path $path $package_key] } error] } { + apm_callback_and_log -severity Warning $callback "Unable to locate specification file for package $package_key: $error" + continue + } + # We found the .info file. + lappend new_spec_files $info_file + } + if { [llength $new_spec_files] == 0 } { - ns_log Notice "apm_scan_packages: No new packages found." + ns_log Notice "apm_scan_packages: No new packages found." } return $new_spec_files } - + ad_proc -public apm_dependency_provided_p { { - -dependency_list [list] + -dependency_list [list] } dependency_uri dependency_version } { Returns 1 if the current system provides the dependency inquired about. Returns -1 if the version number is too low. Returns 0 otherwise. @param dependency_list Specify this if you want to a check a list of dependencies of form - {dependency_name dependency_version} in addition to querying the database for what the - system currently provides. + {dependency_name dependency_version} in addition to querying the database for what the + system currently provides. @param dependency_uri The dependency that is being checked. @param dependency_version The version of the dependency being checked. } { @@ -86,41 +86,41 @@ set found_p 0 ns_log Debug "apm_dependency_provided_p: Scanning for $dependency_uri version $dependency_version" db_foreach apm_dependency_check {} { - if { $version_p >= 0 } { - ns_log Debug "apm_dependency_provided_p: Dependency satisfied by previously installed package" - set found_p 1 - } elseif { $version_p == -1 } { - set old_version_p 1 - } + if { $version_p >= 0 } { + ns_log Debug "apm_dependency_provided_p: Dependency satisfied by previously installed package" + set found_p 1 + } elseif { $version_p == -1 } { + set old_version_p 1 + } } # Can't return while inside a db_foreach. if {$found_p} { - return 1 + return 1 } if { $dependency_list ne "" } { - # They provided a list of provisions. - foreach prov $dependency_list { - if {$dependency_uri eq [lindex $prov 0]} { + # They provided a list of provisions. + foreach prov $dependency_list { + if {$dependency_uri eq [lindex $prov 0]} { set provided_version [lindex $prov 1] set provided_p [db_string version_greater_p {}] if { $provided_p >= 0 } { - ns_log Debug "apm_dependency_provided_p: Dependency satisfied in list of provisions." + ns_log Debug "apm_dependency_provided_p: Dependency satisfied in list of provisions." return 1 } else { set old_version_p 1 } - } - } + } + } } - + if { $old_version_p} { - return -1 + return -1 } else { - return 0 + return 0 } } @@ -161,8 +161,8 @@ @return The full path of the packages dir stored in the package info map. - Assumes that the info file is stored in the root - dir of the package. + Assumes that the info file is stored in the root + dir of the package. } { return [file dirname [pkg_info_spec $pkg_info]] @@ -237,41 +237,41 @@ @param initial_install Only process spec files with the initial install attribute. @param pkg_info_all If you supply this argument, when a - requirement goes unsatisfied, instead of failing, this proc will - try to add whatever other packages are needed to the install set. The list of package keys to - add will be the third element in the list returned. + requirement goes unsatisfied, instead of failing, this proc will + try to add whatever other packages are needed to the install set. The list of package keys to + add will be the third element in the list returned. @return A list whose first element indicates whether dependencies were satisfied (1 if so, 0 otherwise).\ - The second element is the package info list with the packages ordered according to dependencies.\ - Packages that can be installed come first. Any packages that failed the dependency check come last. - The third element is a list of package keys on additional packages to install, in order to satisfy dependencies. + The second element is the package info list with the packages ordered according to dependencies.\ + Packages that can be installed come first. Any packages that failed the dependency check come last. + The third element is a list of package keys on additional packages to install, in order to satisfy dependencies. } { #### Iterate over the list of info files. ## Every time we satisfy another package, remove it from install_pend, and loop again. ## If we don't satisfy at least one more package, halt. ## install_in - Package info structures for packages that can be installed in a satisfactory order. ## install_pend - Stores package info structures fro packages that might have their dependencies satisfied - ## by packages in the install set. + ## by packages in the install set. ## extra_package_keys - package keys of extra packages to install to satisfy all requirements. set extra_package_keys [list] set updated_p 1 set install_in [list] foreach spec_file $spec_files { - if { [catch { - array set package [apm_read_package_info_file $spec_file] - if { ($package(initial-install-p) eq "t" || !$initial_install_p) - && [apm_package_supports_rdbms_p -package_key $package(package.key)] - } { + if { [catch { + array set package [apm_read_package_info_file $spec_file] + if { ($package(initial-install-p) eq "t" || !$initial_install_p) + && [apm_package_supports_rdbms_p -package_key $package(package.key)] + } { lappend install_pend [pkg_info_new \ - $package(package.key) \ - $spec_file \ - $package(embeds) \ - $package(extends) \ - $package(provides) \ - $package(requires) \ - ""] + $package(package.key) \ + $spec_file \ + $package(embeds) \ + $package(extends) \ + $package(provides) \ + $package(requires) \ + ""] } # Remove this package from the pkg_info_all list ... @@ -284,11 +284,11 @@ } incr counter } - } errmsg]} { - # Failed to parse the specificaton file. - apm_callback_and_log $callback "$spec_file could not be parsed correctly. It is not being installed. - The error: $errmsg" - } + } errmsg]} { + # Failed to parse the specificaton file. + apm_callback_and_log $callback "$spec_file could not be parsed correctly. It is not being installed. + The error: $errmsg" + } } # Outer loop tries to find a package from the pkg_info_all list to add if @@ -306,19 +306,19 @@ foreach prov [pkg_info_provides $pkg_info] { lappend install_in_provides $prov } - } + } # Now determine if we can add another package to the install set. foreach pkg_info $install_pend { set satisfied_p 1 foreach req [concat [pkg_info_embeds $pkg_info] [pkg_info_extends $pkg_info] [pkg_info_requires $pkg_info]] { if {[apm_dependency_provided_p -dependency_list $install_in_provides \ - [lindex $req 0] [lindex $req 1]] != 1} { + [lindex $req 0] [lindex $req 1]] != 1} { # Unsatisfied dependency. set satisfied_p 0 # Check to see if we've recorded it already set errmsg "Requires [lindex $req 0] of version >= [lindex $req 1]." if { ![info exists install_error([pkg_info_key $pkg_info])] || - $errmsg ni $install_error([pkg_info_key $pkg_info])} { + $errmsg ni $install_error([pkg_info_key $pkg_info])} { lappend install_error([pkg_info_key $pkg_info]) $errmsg } lappend new_install_pend $pkg_info @@ -328,14 +328,14 @@ if { $satisfied_p } { # At least one more package was added to the list that can be installed, so repeat. lappend install_in [pkg_info_new \ - [pkg_info_key $pkg_info] \ - [pkg_info_spec $pkg_info] \ - [pkg_info_embeds $pkg_info] \ - [pkg_info_extends $pkg_info] \ - [pkg_info_provides $pkg_info] \ - [pkg_info_requires $pkg_info] \ - "t" \ - "Package satisfies dependencies."] + [pkg_info_key $pkg_info] \ + [pkg_info_spec $pkg_info] \ + [pkg_info_embeds $pkg_info] \ + [pkg_info_extends $pkg_info] \ + [pkg_info_provides $pkg_info] \ + [pkg_info_requires $pkg_info] \ + "t" \ + "Package satisfies dependencies."] set updated_p 1 } } @@ -358,9 +358,9 @@ foreach pkg_info_add $pkg_info_all { # Will this package do anything to change whether this requirement has been satisfied? if { [pkg_info_key $pkg_info_add] eq [lindex $req 0] - && [apm_dependency_provided_p -dependency_list [pkg_info_provides $pkg_info_add] \ - [lindex $req 0] [lindex $req 1]] == 1 - } { + && [apm_dependency_provided_p -dependency_list [pkg_info_provides $pkg_info_add] \ + [lindex $req 0] [lindex $req 1]] == 1 + } { # It sure does. Add it to list of packages to install lappend install_pend $pkg_info_add @@ -389,17 +389,17 @@ } } } - + set install_order(order) $install_in # Update all of the packages that cannot be installed. if { [info exists install_pend] && $install_pend ne "" } { - foreach pkg_info $install_pend { - lappend install_in [pkg_info_new [pkg_info_key $pkg_info] [pkg_info_spec $pkg_info] \ - [pkg_info_embeds $pkg_info] [pkg_info_extends $pkg_info] \ + foreach pkg_info $install_pend { + lappend install_in [pkg_info_new [pkg_info_key $pkg_info] [pkg_info_spec $pkg_info] \ + [pkg_info_embeds $pkg_info] [pkg_info_extends $pkg_info] \ [pkg_info_provides $pkg_info] [pkg_info_requires $pkg_info] \ - "f" $install_error([pkg_info_key $pkg_info])] - } - return [list 0 $install_in] + "f" $install_error([pkg_info_key $pkg_info])] + } + return [list 0 $install_in] } return [list 1 $install_in $extra_package_keys] @@ -417,25 +417,25 @@ @param package_keys The list of package_keys of the packages requested to be installed. @param repository_array Name of an array in the caller's namespace containing the repository of - available packages as returned by apm_get_package_repository. + available packages as returned by apm_get_package_repository. @return An array list with the following elements:
Installed $version(package-name), version $version(name).
" + apm_callback_and_log $callback "Installed $version(package-name), version $version(name).
" } { global errorInfo ns_log Error "apm_package_install: Error installing $version(package-name) version $version(name): $errmsg\n$errorInfo" - apm_callback_and_log -severity Error $callback [subst {Failed to install $version(package-name), version $version(name). The following error was generated: -
+ apm_callback_and_log -severity Error $callback [subst {-[ad_quotehtml $errmsg] -
Failed to install $version(package-name), version $version(name). The following error was generated: +
-+ [ad_quotehtml $errmsg] +
-NOTE: If the error comes from a sql script you may try to source it manually. When you are done with that you should revisit the APM and try again but remember to leave the manually souced sql scipts unchecked on the previous page. -
-}] - return 0 ++ NOTE: If the error comes from a sql script you may try to source it manually. When you are done with that you should revisit the APM and try again but remember to leave the manually souced sql scipts unchecked on the previous page. +
+ }] + return 0 } # Enable the package if { $enable_p } { nsv_set apm_enabled_package $package_key 1 - apm_version_enable -callback $callback $version_id + apm_version_enable -callback $callback $version_id } # Instantiating, mounting, and after-install callback only invoked on initial install @@ -943,24 +943,24 @@ # There is already a node with that path, check if there is a package mounted there array set node [site_node::get -url "/${priority_mount_path}"] if { $node(object_id) eq "" } { - # There is no package mounted there so go ahead and mount the new package - set node_id $node(node_id) + # There is no package mounted there so go ahead and mount the new package + set node_id $node(node_id) } else { - # Don't unmount already mounted packages - set node_id "" + # Don't unmount already mounted packages + set node_id "" } - } + } - if { $node_id ne "" } { + if { $node_id ne "" } { site_node::instantiate_and_mount \ - -node_id $node_id \ - -node_name $priority_mount_path \ - -package_name $version(package-name) \ - -package_key $package_key + -node_id $node_id \ + -node_name $priority_mount_path \ + -package_name $version(package-name) \ + -package_key $package_key apm_callback_and_log $callback "Mounted an instance of the package at /${priority_mount_path}
" - } { + } { # Another package is mounted at the path so we cannot mount global errorInfo set error_text "Package $version(package-name) could not be mounted at /$version(auto-mount) , there may already be a package mounted there, the error is: $error" @@ -973,7 +973,7 @@ # Using empty context_id apm_package_instance_new -instance_name $version(package-name) \ - -package_key $package_key + -package_key $package_key } } else { # After upgrade Tcl proc callback @@ -989,7 +989,7 @@ ad_proc apm_unregister_disinherited_params { package_key dependency_id } { Remove parameters for package_key that have been disinherited (i.e., the - dependency that caused them to be inherited have been removed). Called only + dependency that caused them to be inherited have been removed). Called only by the APM and keep it that way, please. } { @@ -1043,10 +1043,10 @@ upvar $array local_array if { $version_id eq "" } { - set version_id [db_null] + set version_id [db_null] } if { $release_date eq "" } { - set release_date [db_null] + set release_date [db_null] } set version_id [db_exec_plsql version_insert {}] @@ -1073,8 +1073,8 @@ } { if {![apm_package_registered_p $package_key]} { - apm_callback_and_log $callback "This package is not installed. Done." - return 0 + apm_callback_and_log $callback "This package is not installed. Done." + return 0 } # Obtain the portion of the email address before the at sign. We'll use this in the name of @@ -1087,15 +1087,15 @@" - db_source_sql_file -callback $callback "[acs_package_root_dir $package_key]/$path" - apm_callback_and_log $callback "" + apm_callback_and_log $callback "
" + db_source_sql_file -callback $callback "[acs_package_root_dir $package_key]/$path" + apm_callback_and_log $callback "" } } # Optionally remove the files from the filesystem if {$remove_files_p==1} { - if { [catch { - file delete -force [acs_package_root_dir $package_key] - } error] } { - apm_callback_and_log $callback "
\n" - } elseif { $file_type eq "sqlj_code" } { - if { !$ul_p } { - apm_callback_and_log $callback "" - db_source_sql_file -callback $callback $path/$file_path - apm_callback_and_log $callback "
\n" - } elseif {$file_type eq "ctl_file"} { + db_source_sqlj_file -callback $callback "$path/$file_path" + apm_callback_and_log $callback "\n" + } elseif {$file_type eq "ctl_file"} { ns_log Debug "apm_package_install_data_model: Now processing $file_path of type ctl_file" if { !$ul_p } { apm_callback_and_log $callback "" - db_source_sqlj_file -callback $callback "$path/$file_path" - apm_callback_and_log $callback "
\n" + apm_callback_and_log $callback "\n" } } if {$ul_p} { - apm_callback_and_log $callback "" db_load_sql_data -callback $callback $path/$file_path - apm_callback_and_log $callback "
" + apm_callback_and_log $callback "
" } if { [llength $data_model_files] } { @@ -1306,29 +1306,29 @@ } { # Update each parameter that exists. foreach parameter $parameters { - set parameter_name [lindex $parameter 0] - # Keep a running tally of all parameters that are in the current version. - set description [lindex $parameter 1] - set section_name [lindex $parameter 2] + set parameter_name [lindex $parameter 0] + # Keep a running tally of all parameters that are in the current version. + set description [lindex $parameter 1] + set section_name [lindex $parameter 2] set scope [lindex $parameter 3] - set datatype [lindex $parameter 4] - set min_n_values [lindex $parameter 5] - set max_n_values [lindex $parameter 6] - set default_value [lindex $parameter 7] - if {[db_0or1row parameter_id_get { - select parameter_id from apm_parameters - where parameter_name = :parameter_name - and package_key = :package_key - }]} { - ns_log Debug "apm_package_upgrade_parameters: Updating parameter, $parameter_name:$parameter_id" + set datatype [lindex $parameter 4] + set min_n_values [lindex $parameter 5] + set max_n_values [lindex $parameter 6] + set default_value [lindex $parameter 7] + if {[db_0or1row parameter_id_get { + select parameter_id from apm_parameters + where parameter_name = :parameter_name + and package_key = :package_key + }]} { + ns_log Debug "apm_package_upgrade_parameters: Updating parameter, $parameter_name:$parameter_id" # DRB: We don't allow one to upgrade scope and should probably throw an error. - apm_parameter_update $parameter_id $package_key $parameter_name $description \ - $default_value $datatype $section_name $min_n_values $max_n_values - } else { - ns_log Debug "apm_package_upgrade_parameters: Registering parameter, $parameter_name." - apm_parameter_register -scope $scope $parameter_name $description $package_key $default_value \ - $datatype $section_name $min_n_values $max_n_values - } + apm_parameter_update $parameter_id $package_key $parameter_name $description \ + $default_value $datatype $section_name $min_n_values $max_n_values + } else { + ns_log Debug "apm_package_upgrade_parameters: Registering parameter, $parameter_name." + apm_parameter_register -scope $scope $parameter_name $description $package_key $default_value \ + $datatype $section_name $min_n_values $max_n_values + } } ns_log Debug "apm_package_upgrade_parameters: Parameter Upgrade Complete." } @@ -1339,16 +1339,16 @@ } { foreach parameter $parameters { - set parameter_name [lindex $parameter 0] - set description [lindex $parameter 1] - set section_name [lindex $parameter 2] + set parameter_name [lindex $parameter 0] + set description [lindex $parameter 1] + set section_name [lindex $parameter 2] set scope [lindex $parameter 3] - set datatype [lindex $parameter 4] - set min_n_values [lindex $parameter 5] - set max_n_values [lindex $parameter 6] - set default_value [lindex $parameter 7] - apm_parameter_register -scope $scope $parameter_name $description $package_key $default_value $datatype \ - $section_name $min_n_values $max_n_values + set datatype [lindex $parameter 4] + set min_n_values [lindex $parameter 5] + set max_n_values [lindex $parameter 6] + set default_value [lindex $parameter 7] + apm_parameter_register -scope $scope $parameter_name $description $package_key $default_value $datatype \ + $section_name $min_n_values $max_n_values } } @@ -1366,34 +1366,34 @@ ns_log Debug "apm_package_install_dependencies: Installing dependencies.\nembeds: $embeds\nextends: $extends\nprovides: $provides\nrequires:$requires" # Delete any dependencies register for this version. db_foreach all_dependencies_for_version { - select dependency_id from apm_package_dependencies - where version_id = :version_id + select dependency_id from apm_package_dependencies + where version_id = :version_id } { - apm_dependency_remove $dependency_id + apm_dependency_remove $dependency_id } foreach item [lsort -unique $provides] { - lassign $item interface_uri interface_version - ns_log Debug "apm_package_install_dependencies: Registering dependency $interface_uri, $interface_version for $version_id" - apm_interface_add $version_id $interface_uri $interface_version + lassign $item interface_uri interface_version + ns_log Debug "apm_package_install_dependencies: Registering dependency $interface_uri, $interface_version for $version_id" + apm_interface_add $version_id $interface_uri $interface_version } foreach item [lsort -unique $embeds] { - lassign $item dependency_uri dependency_version - ns_log Debug "apm_package_install_dependencies: Registering dependency embeds $dependency_uri, $dependency_version for $version_id" - apm_dependency_add embeds $version_id $dependency_uri $dependency_version + lassign $item dependency_uri dependency_version + ns_log Debug "apm_package_install_dependencies: Registering dependency embeds $dependency_uri, $dependency_version for $version_id" + apm_dependency_add embeds $version_id $dependency_uri $dependency_version } foreach item [lsort -unique $extends] { - lassign $item dependency_uri dependency_version - ns_log Debug "apm_package_install_dependencies: Registering dependency extends $dependency_uri, $dependency_version for $version_id" - apm_dependency_add extends $version_id $dependency_uri $dependency_version + lassign $item dependency_uri dependency_version + ns_log Debug "apm_package_install_dependencies: Registering dependency extends $dependency_uri, $dependency_version for $version_id" + apm_dependency_add extends $version_id $dependency_uri $dependency_version } foreach item [lsort -unique $requires] { - lassign $item dependency_uri dependency_version - ns_log Debug "apm_package_install_dependencies: Registering dependency requires $dependency_uri, $dependency_version for $version_id" - apm_dependency_add requires $version_id $dependency_uri $dependency_version + lassign $item dependency_uri dependency_version + ns_log Debug "apm_package_install_dependencies: Registering dependency requires $dependency_uri, $dependency_version for $version_id" + apm_dependency_add requires $version_id $dependency_uri $dependency_version } } @@ -1404,9 +1404,9 @@ } { set owners [list] for {set i 0} {$i < [llength $owner_names] } {incr i} { - if { [lindex $owner_names $i] ne "" } { - lappend owners [list [lindex $owner_names $i] [lindex $owner_uris $i]] - } + if { [lindex $owner_names $i] ne "" } { + lappend owners [list [lindex $owner_names $i] [lindex $owner_uris $i]] + } } return $owners } @@ -1417,16 +1417,16 @@ } { db_dml apm_delete_owners { - delete from apm_package_owners where version_id = :version_id + delete from apm_package_owners where version_id = :version_id } set counter 0 foreach item $owners { - lassign $item owner_name owner_uri - db_dml owner_insert { - insert into apm_package_owners(version_id, owner_uri, owner_name, sort_key) - values(:version_id, :owner_uri, :owner_name, :counter) - } - incr counter + lassign $item owner_name owner_uri + db_dml owner_insert { + insert into apm_package_owners(version_id, owner_uri, owner_name, sort_key) + values(:version_id, :owner_uri, :owner_name, :counter) + } + incr counter } } @@ -1462,41 +1462,41 @@ set spec [apm_generate_package_spec $version_id] apm_version_info $version_id db_1row package_version_info_select { - select package_key, version_id - from apm_package_version_info - where version_id = :version_id + select package_key, version_id + from apm_package_version_info + where version_id = :version_id } ns_log Debug "apm_package_install_spec: Checking existence of package directory." set root [acs_package_root_dir $package_key] if { ![file exists $root] } { - file mkdir $root -# doesn't work under windows. its not very useful anyway. -# file attributes $root -permissions [parameter::get -parameter InfoFilePermissionsMode -default 0755] + file mkdir $root + # doesn't work under windows. its not very useful anyway. + # file attributes $root -permissions [parameter::get -parameter InfoFilePermissionsMode -default 0755] } db_transaction { - ns_log Debug "apm_package_install_spec: Determining path of .info file." - set path "[acs_package_root_dir $package_key]/$package_key.info" + ns_log Debug "apm_package_install_spec: Determining path of .info file." + set path "[acs_package_root_dir $package_key]/$package_key.info" - ns_log Debug "apm_package_install_spec: Writing APM .info file to the database." - db_dml apm_spec_file_register {} - ns_log Debug "apm_package_install_spec: Writing .info file." + ns_log Debug "apm_package_install_spec: Writing APM .info file to the database." + db_dml apm_spec_file_register {} + ns_log Debug "apm_package_install_spec: Writing .info file." - set file [open $path "w"] - puts -nonewline $file $spec - close $file + set file [open $path "w"] + puts -nonewline $file $spec + close $file # create minimal directories foreach dir {www www/doc tcl tcl/test sql sql/postgresql sql/oracle} { - set path "[acs_package_root_dir $package_key]/$dir" + set path "[acs_package_root_dir $package_key]/$dir" if { ![file exists $path] } { file mkdir $path } } - # Mark $version_id as the only installed version of the package. - db_dml version_mark_installed { + # Mark $version_id as the only installed version of the package. + db_dml version_mark_installed { update apm_package_versions set installed_p = decode(version_id, :version_id, 't', 'f') where package_key = :package_key @@ -1513,11 +1513,11 @@ @param version_id The id of the version to be enabled. } { db_exec_plsql apm_package_version_enable { - begin - apm_package_version.enable( - version_id => :version_id - ); - end; + begin + apm_package_version.enable( + version_id => :version_id + ); + end; } apm_callback_and_log $callback "
Package enabled." } @@ -1529,11 +1529,11 @@ @param version_id The id of the version to be disabled. } { db_exec_plsql apm_package_version_disable { - begin - apm_package_version.disable( - version_id => :version_id - ); - end; + begin + apm_package_version.disable( + version_id => :version_id + ); + end; } apm_callback_and_log $callback "
Package disabled." } @@ -1555,19 +1555,19 @@ } { if { $spec_file_path eq "" } { - set spec_file_path [db_null] + set spec_file_path [db_null] } if { $spec_file_mtime eq "" } { - set spec_file_mtime [db_null] + set spec_file_mtime [db_null] } if { $package_type eq "apm_application" } { - db_exec_plsql application_register {} + db_exec_plsql application_register {} } elseif { $package_type eq "apm_service" } { - db_exec_plsql service_register {} + db_exec_plsql service_register {} } else { - error "Unrecognized package type: $package_type" + error "Unrecognized package type: $package_type" } } @@ -1582,7 +1582,7 @@ upvar $array local_array if { $release_date eq "" } { - set release_date [db_null] + set release_date [db_null] } set version_id [db_exec_plsql apm_version_update {}] @@ -1604,34 +1604,34 @@ } { foreach pkg_info $pkg_info_list { - if { [catch { - set spec_file [pkg_info_spec $pkg_info] - set package_key [pkg_info_key $pkg_info] + if { [catch { + set spec_file [pkg_info_spec $pkg_info] + set package_key [pkg_info_key $pkg_info] apm_package_install \ -load_data_model \ -enable \ -callback $callback \ $spec_file - } errmsg] } { + } errmsg] } { global errorInfo - apm_callback_and_log -severity Error $callback "
[string totitle $package_key] not installed. + apm_callback_and_log -severity Error $callback "
[string totitle $package_key] not installed.
Error:
" - } + } } } ad_proc -private apm_package_upgrade_p {package_key version_name} { @return 1 if a version of the indicated package_key of version lower than version_name \ - is already installed in the system, 0 otherwise. + is already installed in the system, 0 otherwise. } { return [db_string apm_package_upgrade_p { - select apm_package_version.version_name_greater(:version_name, version_name) upgrade_p - from apm_package_versions - where package_key = :package_key - and version_id = apm_package.highest_version (:package_key) + select apm_package_version.version_name_greater(:version_name, version_name) upgrade_p + from apm_package_versions + where package_key = :package_key + and version_id = apm_package.highest_version (:package_key) } -default 0] } @@ -1657,9 +1657,9 @@ } { db_exec_plsql apm_version_upgrade { - begin - apm_package_version.upgrade(version_id => :version_id); - end; + begin + apm_package_version.upgrade(version_id => :version_id); + end; } } @@ -1672,13 +1672,13 @@ } { ns_log Debug "apm_upgrade_for_version_p: upgrade_p $path, $initial_version_name $final_version_name" return [db_exec_plsql apm_upgrade_for_version_p { - begin - :1 := apm_package_version.upgrade_p( - path => :path, - initial_version_name => :initial_version_name, - final_version_name => :final_version_name - ); - end; + begin + :1 := apm_package_version.upgrade_p( + path => :path, + initial_version_name => :initial_version_name, + final_version_name => :final_version_name + ); + end; }] } @@ -1704,15 +1704,15 @@ # Get the version number from, e.g. the 2.0 from upgrade-2.0-3.0.sql if {[regexp {\-(.*)-.*.sql} $f1 match f1_version_from] - && [regexp {\-(.*)-.*.sql} $f2 match f2_version_from] + && [regexp {\-(.*)-.*.sql} $f2 match f2_version_from] } { - # At this point we should have something like 2.0 and 3.1d which Tcl string - # comparison can handle. - set f1_version_from [db_exec_plsql test_f1 {}] - set f2_version_from [db_exec_plsql test_f2 {}] - return [string compare $f1_version_from $f2_version_from] + # At this point we should have something like 2.0 and 3.1d which Tcl string + # comparison can handle. + set f1_version_from [db_exec_plsql test_f1 {}] + set f2_version_from [db_exec_plsql test_f2 {}] + return [string compare $f1_version_from $f2_version_from] } else { - error "Invalid upgrade script syntax. Should be \"upgrade-major.minor-major.minor.sql\"." + error "Invalid upgrade script syntax. Should be \"upgrade-major.minor-major.minor.sql\"." } } @@ -1728,46 +1728,49 @@ } { set types_to_retrieve [list "sqlj_code"] if {$upgrade_from_version_name eq ""} { - lappend types_to_retrieve "data_model_create" + lappend types_to_retrieve "data_model_create" # Assuming here that ctl_file files are not upgrade scripts # TODO: Make it possible to determine which ctl files are upgrade scripts and which aren't lappend types_to_retrieve "ctl_file" } else { - lappend types_to_retrieve "data_model_upgrade" + lappend types_to_retrieve "data_model_upgrade" } set data_model_list [list] set upgrade_file_list [list] set ctl_file_list [list] - set file_list [apm_get_package_files -include_data_model_files -file_types $types_to_retrieve -package_path $package_path -package_key $package_key] + set file_list [apm_get_package_files -include_data_model_files \ + -file_types $types_to_retrieve \ + -package_path $package_path \ + -package_key $package_key] foreach path $file_list { set file_type [apm_guess_file_type $package_key $path] set file_db_type [apm_guess_db_type $package_key $path] - apm_log APMDebug "apm_data_model_scripts_find: Checking \"$path\" of type \"$file_type\" and db_type \"$file_db_type\"." + apm_log APMDebug "apm_data_model_scripts_find: Checking \"$path\" of type \"$file_type\" and db_type \"$file_db_type\"." - if {$file_type in $types_to_retrieve} { + if {$file_type in $types_to_retrieve} { set list_item [list $path $file_type $package_key] - if {$file_type eq "data_model_upgrade"} { + if {$file_type eq "data_model_upgrade"} { # Upgrade script - if {[apm_upgrade_for_version_p $path $upgrade_from_version_name \ - $upgrade_to_version_name]} { - # Its a valid upgrade script. - ns_log Debug "apm_data_model_scripts_find: Adding $path to the list of upgrade files." - lappend upgrade_file_list $list_item - } - } elseif {$file_type eq "ctl_file"} { + if {[apm_upgrade_for_version_p $path $upgrade_from_version_name \ + $upgrade_to_version_name]} { + # Its a valid upgrade script. + ns_log Debug "apm_data_model_scripts_find: Adding $path to the list of upgrade files." + lappend upgrade_file_list $list_item + } + } elseif {$file_type eq "ctl_file"} { lappend ctl_file_list $list_item } else { # Install script - apm_log APMDebug "apm_data_model_scripts_find: Adding $path to the list of data model files." - lappend data_model_list $list_item - } - } + apm_log APMDebug "apm_data_model_scripts_find: Adding $path to the list of data model files." + lappend data_model_list $list_item + } + } } # ctl files need to be loaded after the sql create scripts set file_list [concat [apm_order_upgrade_scripts $upgrade_file_list] \ - $data_model_list \ - $ctl_file_list] + $data_model_list \ + $ctl_file_list] apm_log APMDebug "apm_data_model_scripts_find: Data model scripts for $package_key: $file_list" return $file_list @@ -1783,19 +1786,19 @@ set query_file_list [list] foreach file $file_list { - lassign $file path file_type file_db_type - ns_log Debug "apm_query_files_find: Checking \"$path\" of type \"$file_type\" and db_type \"$file_db_type\"." + lassign $file path file_type file_db_type + ns_log Debug "apm_query_files_find: Checking \"$path\" of type \"$file_type\" and db_type \"$file_db_type\"." # DRB: we return query files which match the given database type or for which no db_type # is defined, which we interpret to mean a file containing queries that work with all of our # supported databases. - if {"query_file" eq $file_type - && ($file_db_type eq "" || [db_type] eq $file_db_type ) - } { + if {"query_file" eq $file_type + && ($file_db_type eq "" || [db_type] eq $file_db_type ) + } { ns_log Debug "apm_query_files_find: Adding $path to the list of query files." lappend query_file_list $path - } + } } ns_log Notice "apm_query_files_find: Query files for $package_key: $query_file_list" return $query_file_list @@ -1810,11 +1813,11 @@[ad_quotehtml $errmsg][ad_quotehtml $errorInfo]
- The reason mounting is done here and not via the auto-mount - feature of the APM is that there is a circular dependency between - acs-subsite and acs-content-repository. The package acs-subsite - requires acs-content-repository and so we cannot install acs-subsite - before acs-content-repository in order to be able to mount acs-content-repository. + The reason mounting is done here and not via the auto-mount + feature of the APM is that there is a circular dependency between + acs-subsite and acs-content-repository. The package acs-subsite + requires acs-content-repository and so we cannot install acs-subsite + before acs-content-repository in order to be able to mount acs-content-repository.
@see site_node::instantiate_and_mount @@ -1827,8 +1830,8 @@ ns_log Notice "apm_mount_core_packages: Mounting acs-lang" set acs_lang_id [site_node::instantiate_and_mount -package_key acs-lang] permission::grant -party_id [acs_magic_object the_public] \ - -object_id $acs_lang_id \ - -privilege read + -object_id $acs_lang_id \ + -privilege read # Mount acs-admin ns_log Notice "apm_mount_core_packages: Mounting acs-admin" @@ -1845,24 +1848,24 @@ # Mount acs-core-docs ns_log Notice "apm_mount_core_packages: Mounting acs-core-docs" site_node::instantiate_and_mount -node_name doc \ - -package_key acs-core-docs + -package_key acs-core-docs # Mount the acs-api-browser ns_log Notice "apm_mount_core_packages: Mounting acs-api-browser" set api_browser_id \ [site_node::instantiate_and_mount -node_name api-doc \ - -package_key acs-api-browser] + -package_key acs-api-browser] # Only registered users should have permission to access the # api-browser permission::grant -party_id [acs_magic_object registered_users] \ - -object_id $api_browser_id \ - -privilege read + -object_id $api_browser_id \ + -privilege read permission::set_not_inherit -object_id $api_browser_id # Mount acs-automated-testing ns_log Notice "apm_mount_core_packages: Mounting acs-automated-testing" site_node::instantiate_and_mount -node_name test \ - -package_key acs-automated-testing + -package_key acs-automated-testing ns_log Notice "apm_mount_core_packages: Finished mounting of core packages" } @@ -1887,11 +1890,11 @@