apm_package_delete (public)
apm_package_delete [ -sql_drop_scripts sql_drop_scripts ] \ [ -callback callback ] [ -remove_files ] [ -delete_site_nodes ] \ package_key
Defined in packages/acs-tcl/tcl/apm-install-procs.tcl
De-install a package from the system. Will unmount and uninstantiate package instances, invoke any before-uninstall callback, source any provided sql drop scripts, remove message keys, and delete the package from the APM tables.
- Switches:
- -sql_drop_scripts (optional)
- -callback (optional, defaults to
"apm_dummy_callback"
)- -remove_files (optional, boolean)
- -delete_site_nodes (optional, boolean)
- Parameters:
- package_key (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- upgrade
Source code: # get the supposedly unique enabled version of this package 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_transaction { set site_nodes [list] 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 <br>" site_node::unmount -node_id $node_id lappend site_nodes $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 <br>" 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 # Unregister I18N messages lang::catalog::package_delete -package_key $package_key # Remove package from APM tables apm_callback_and_log $callback "<li>Deleting $package_key..." db_exec_plsql apm_package_delete {} } # Source SQL drop scripts if {$sql_drop_scripts ne ""} { apm_callback_and_log $callback "Now executing drop scripts. <ul> " foreach path $sql_drop_scripts { apm_callback_and_log $callback "<li><pre>" db_source_sql_file -callback $callback "[acs_package_root_dir $package_key]/$path" apm_callback_and_log $callback "</pre>" } } # 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 "<li>Unable to delete [acs_package_root_dir $package_key]:<font color=red>$error</font>" } } if {$delete_site_nodes_p} { # We also cleanup the leftover site nodes. We must check that # the nodes still exist because the uninstall callbacks might # have taken care of them already. We also need to make sure # that the nodes do not have subnodes, as the deletion would # fail otherwise. foreach node_id $site_nodes { if {[db_0or1row still_exists_and_is_leaf { select 1 from site_nodes n where node_id = :node_id and not exists (select 1 from site_nodes where parent_id = n.node_id) }]} { site_node::delete -node_id $node_id } } } # Flush the installed_p cache acs::try_cache acs::misc_cache flush apm_package_installed-$package_key apm_callback_and_log $callback "<p>Done."Generic XQL file: packages/acs-tcl/tcl/apm-install-procs.xql
PostgreSQL XQL file: <fullquery name="apm_package_delete.apm_package_delete"> <querytext> select apm_package_type__drop_type( :package_key, 't' ); </querytext> </fullquery>packages/acs-tcl/tcl/apm-install-procs-postgresql.xql
Oracle XQL file: <fullquery name="apm_package_delete.apm_package_delete"> <querytext> begin apm_package_type.drop_type( package_key => :package_key, cascade_p => 't' ); end; </querytext> </fullquery>packages/acs-tcl/tcl/apm-install-procs-oracle.xql