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.69.2.1 -r1.69.2.2
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 24 Nov 2003 17:43:15 -0000 1.69.2.1
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 25 Nov 2003 12:45:17 -0000 1.69.2.2
@@ -735,6 +735,7 @@
# We are upgrading a package
# Load catalog files with upgrade switch before package version is changed in db
+ ns_log Notice "pm debug upgrading loading catalog files"
apm_load_catalog_files -upgrade $package_key
set version_id [apm_package_install_version -callback $callback $package_key $version_name \
@@ -745,6 +746,7 @@
} else {
# We are installing a new package
+ ns_log Notice "pm debug installing loading catalog files"
apm_load_catalog_files $package_key
set version_id [apm_package_install_version \
@@ -918,16 +920,66 @@
}
ad_proc -private apm_package_delete {
+ {-sql_drop_scripts ""}
{
-callback apm_dummy_callback
}
{-remove_files:boolean}
package_key
} {
- Deinstalls and deletes a package from the ACS and the filesystem.
+ Deinstall a package from the system. Will unmount and uninstantiate
+ package instances, invoke any before-unstall callback, source any
+ provided sql drop scripts, remove message keys, and delete
+ the package from the APM tables.
} {
+ set version_id [apm_version_id_from_package_key $package_key]
+
+ # Unmount all instances of this package with the Tcl API that
+ # invokes before-unmount callbacks
+ db_foreach all_package_instances {
+ select site_nodes.node_id
+ from apm_packages, site_nodes
+ where apm_packages.package_id = site_nodes.object_id
+ and apm_packages.package_key = :package_key
+ } {
+ set url [site_node::get_url -node_id $node_id]
+ apm_callback_and_log $callback "Unmounting package instance at url $url
"
+ site_node::unmount -node_id $node_id
+ }
+
+ # Delete the package instances with Tcl API that invokes
+ # before-uninstantiate callbacks
+ db_foreach all_package_instances {
+ select package_id
+ from apm_packages
+ where package_key = :package_key
+ } {
+ apm_callback_and_log $callback "Deleting package instance $package_id
"
+ apm_package_instance_delete $package_id
+ }
+
+ # Invoke the before-uninstall Tcl callback before the sql drop scripts
+ apm_invoke_callback_proc -version_id $version_id -type before-uninstall
+
+ # Source SQL drop scripts
+ if {![empty_string_p $sql_drop_scripts]} {
+
+ apm_callback_and_log $callback "Now executing drop scripts.
+
" + db_source_sql_file -callback apm_doc_body_callback "[acs_package_root_dir $package_key]/$path" + apm_callback_and_log $callback "" + } + } + + # Unregister I18N messages + lang::catalog::package_delete -package_key $package_key + + # Remove package from APM tables apm_callback_and_log $callback "