Index: openacs-4/packages/acs-bootstrap-installer/installer.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/installer.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-bootstrap-installer/installer.tcl 25 Aug 2003 11:55:40 -0000 1.9 +++ openacs-4/packages/acs-bootstrap-installer/installer.tcl 10 Oct 2003 14:52:16 -0000 1.10 @@ -204,7 +204,258 @@ } } +ad_proc -private install_do_data_model_install {} { + Installs the kernel datamodel. +} { + ns_write " + Installing the OpenACS kernel data model... +
+ + Done installing the OpenACS kernel data model.+ " + cd [file join [acs_root_dir] packages acs-kernel sql [db_type]] + db_source_sql_file -callback apm_ns_write_callback acs-kernel-create.sql + # DRB: Now initialize the APM's table of known database types. This is + # butt-ugly. We could have apm-create.sql do this but that would mean + # adding a new database type would require editing two places (the very + # obvious list in bootstrap.tcl and the less-obvious list in apm-create.sql). + # On the other hand, this is ugly because now this code knows about the + # apm datamodel as well as the existence of the special acs-kernel module. + + set apm_db_types_exists [db_string db_types_exists " + select case when count(*) = 0 then 0 else 1 end from apm_package_db_types"] + + if { !$apm_db_types_exists } { + ns_log Notice "Populating apm_package_db_types" + foreach known_db_type [db_known_database_types] { + set db_type [lindex $known_db_type 0] + set db_pretty_name [lindex $known_db_type 2] + db_dml insert_apm_db_type { + insert into apm_package_db_types + (db_type_key, pretty_db_name) + values + (:db_type, :db_pretty_name) + } + } + } + + ns_write "
+ + " + + # Some APM procedures use util_memoize, so initialize the cache + # before starting APM install + apm_source "[acs_package_root_dir acs-tcl]/tcl/20-memoize-init.tcl" + + apm_version_enable -callback apm_ns_write_callback [apm_package_install -callback apm_ns_write_callback "[file join [acs_root_dir] packages acs-kernel acs-kernel.info]"] + + ns_write "
Loading package .info files.
" + + # Preload all the .info files so the next page is snappy. + apm_dependency_check -initial_install [apm_scan_packages -new [file join [acs_root_dir] packages]] + + ns_write "Done loading package .info files
" +} + +ad_proc -private install_do_packages_install {} { + Installs all packages during OpenACS install. +} { + proc ad_acs_kernel_id {} { + if {[db_table_exists apm_packages]} { + return [db_string acs_kernel_id_get { + select package_id from apm_packages + where package_key = 'acs-kernel' + } -default 0] + } else { + return 0 + } + } + + ns_write "Installing OpenACS Core Services" + + # Load the acs-tcl init files that might be needed when installing, instantiating and mounting packages + # We shouldn't source request-processor-init.tcl as it might interfere with the installer request handler + foreach { init_file } { utilities-init.tcl site-nodes-init.tcl } { + ns_log Notice "Loading acs-tcl init file $init_file" + apm_source "[acs_package_root_dir acs-tcl]/tcl/$init_file" + } + apm_bootstrap_load_libraries -procs acs-subsite + apm_bootstrap_load_queries acs-subsite + install_redefine_ad_conn + + # Attempt to install all packages. + set dependency_results [apm_dependency_check -initial_install [apm_scan_packages -new [file join [acs_root_dir] packages]]] + set dependencies_satisfied_p [lindex $dependency_results 0] + set pkg_list [lindex $dependency_results 1] + apm_packages_full_install -callback apm_ns_write_callback $pkg_list + + # Complete the initial install. + + if { ![ad_acs_admin_node] } { + ns_write "
+
" + + # Now process the application bundle if an install.xml file was found. + + if { [file exists [apm_install_xml_file_path]] } { + set root_node [apm_load_install_xml_file] + + ns_write "" + + # Mount the main site + cd [file join [acs_root_dir] packages acs-kernel sql [db_type]] + db_source_sql_file -callback apm_ns_write_callback acs-install.sql + + # Make sure the site-node cache is updated with the main site + site_node::init_cache + + # We need to redefine ad_conn again since apm_package_install resourced the real ad_conn + install_redefine_ad_conn + + # Mount and set permissions for core packages + apm_mount_core_packages + + ns_write "
Loading packages for the [nsv_get acs_application pretty_name] application.
" + + set actions [xml_node_get_children_by_name $root_node actions] + if { [llength $actions] > 1 } { + ns_log Error "Error in \"install.xml\": only one action node is allowed" + ns_write "Error in \"install.xml\": only one action node is allowed
"
+ return
+ }
+ set actions [xml_node_get_children [lindex $actions 0]]
+
+ foreach action $actions {
+
+ switch -exact [xml_node_get_name $action] {
+
+ text {}
+
+ install {
+
+ set install_spec_files [list]
+ foreach install_spec_file \
+ [glob -nocomplain "[acs_root_dir]/packages/[apm_required_attribute_value $action package]/*.info"] {
+ if { [catch { array set package [apm_read_package_info_file $install_spec_file] } errmsg] } {
+ # Unable to parse specification file.
+ ns_log Error "$install_spec_file could not be parsed correctly. The error: $errmsg"
+ ns_write "
install: $install_spec_file could not be parsed correctly. The error: $errmsg"
+ return
+ }
+ if { [apm_package_supports_rdbms_p -package_key $package(package.key)] &&
+ ![apm_package_installed_p $package(package.key)] } {
+ lappend install_spec_files $install_spec_file
+ }
+ }
+
+ set pkg_info_list [list]
+ foreach spec_file [glob -nocomplain "[acs_root_dir]/packages/*/*.info"] {
+ # Get package info, and find out if this is a package we should install
+ if { [catch { array set package [apm_read_package_info_file $spec_file] } errmsg] } {
+ # Unable to parse specification file.
+ ns_log Error "$spec_file could not be parsed correctly. The error: $errmsg"
+ ns_write "
install: $spec_file could not be parsed correctly. The error: $errmsg"
+ return
+ }
+
+ if { [apm_package_supports_rdbms_p -package_key $package(package.key)] &&
+ ![apm_package_installed_p $package(package.key)] } {
+ # Save the package info, we may need it for dependency satisfaction later
+ lappend pkg_info_list [pkg_info_new $package(package.key) $spec_file \
+ $package(provides) $package(requires) ""]
+ }
+ }
+
+ if { [llength $install_spec_files] > 0 } {
+ set dependency_results [apm_dependency_check -pkg_info_all $pkg_info_list $install_spec_files]
+ if { [lindex $dependency_results 0] == 1 } {
+ apm_packages_full_install -callback apm_ns_write_callback [lindex $dependency_results 1]
+ } else {
+ foreach package_spec [lindex $dependency_results 1] {
+ if { [string is false [pkg_info_dependency_p $package_spec]] } {
+ ns_log Error "install: package \"[pkg_info_key $package_spec]\"[join [pkg_info_comment $package_spec] ","]"
+ append html "
Package \"[pkg_info_key $package_spec]\"\n
Mounting new instance of package $package_key at /$mount_point
"
+ site_node::instantiate_and_mount \
+ -node_id $node_id \
+ -node_name $mount_point \
+ -package_name $instance_name \
+ -package_key $package_key
+
+ }
+
+ }
+
+ set-parameter {
+ set name [apm_required_attribute_value $action name]
+ set value [apm_required_attribute_value $action value]
+ set package_key [apm_attribute_value -default "" $action package]
+ set url [apm_attribute_value -default "" $action url]
+
+ if { ![string equal $package_key ""] && ![string equal $url ""] } {
+ ns_log Error "set-parameter: Can't specify both package and url"
+ ns_write "
set-parameter: Can't specify both package and url"
+ return
+ } elseif { ![string equal $package_key ""] } {
+ parameter::set_from_package_key -package_key $package_key -parameter $name -value $value
+ } else {
+ parameter::set_value \
+ -package_id [site_node::get_object_id -node_id [site_node::get_node_id -url $url]] \
+ -parameter $name \
+ -value $value
+ }
+ }
+
+ default {
+ ns_log Error "Error in \"install.xml\": got bad node \"[xml_node_get_name $action]\""
+ }
+
+ }
+
+ }
+ }
+ }
+
+
+ ns_write "All Packages Installed."
+}
+
# Register the install handler.
ns_register_filter preauth GET * install_handler
ns_register_filter preauth POST * install_handler