Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-admin/www/install/local-install-3.adp'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-admin/www/install/local-install-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/install/Attic/local-install-3.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-admin/www/install/local-install-3.tcl 19 Sep 2003 12:59:27 -0000 1.3 +++ openacs-4/packages/acs-admin/www/install/local-install-3.tcl 21 Sep 2003 18:24:19 -0000 1.4 @@ -2,205 +2,184 @@ Install from local file system } +# TODO: Maybe set a body onload handler to display a warning message that the page has stopped loading, +# which it shouldn't. + +# TODO: There's some weird issue with this page causing the entire server to stop serving +# pages if you hit reload. The whole point of moving this into a background thread was to +# let people safely double-click ... + ##### # -# Start progress bar +# Start installation process # ##### -# TODO: We should execute this in a background-thread, so that -# we don't risk running two installation processes at the same time (double-click, or two users) -# TODO: Maybe set a body onload handler to display a warning message that the page has stopped loading, -# which it shouldn't. If people hit reload, we should preferably just re-display the progress bar -# and continue waiting. +set pkg_install_list [ad_get_client_property apm pkg_install_list] +ns_log Notice "Installing: $pkg_install_list" +# We unset the client property so we won't install these packages twice +ad_set_client_property apm pkg_install_list {} + +if { ![empty_string_p $pkg_install_list] } { + util_background_exec -name package-install -pass_vars { pkg_install_list } { + + set sql_files [list] + + foreach pkg_info $pkg_install_list { + ns_log Notice "Installing $pkg_info" + + set package_key [pkg_info_key $pkg_info] + set spec_file [pkg_info_spec $pkg_info] + array set version [apm_read_package_info_file $spec_file] + set final_version_name $version(name) + + if { [apm_package_version_installed_p $version(package.key) $version(name)] } { + # Already installed. + + # Enable this version, in case it's not already enabled + if { ![apm_package_enabled_p $version(package.key)] } { + ns_log Notice "Package $version(package.key) $version(name) is already installed but not enabled, enabling" + apm_version_enable -callback apm_dummy_callback [apm_highest_version $version(package.key)] + } else { + ns_log Notice "Package $version(package.key) $version(name) is already installed and enabled, skipping" + } + + continue + } + + # Determine if we are upgrading or installing. + if { [apm_package_upgrade_p $package_key $final_version_name] == 1} { + ns_log Debug "Upgrading package [string totitle $version(package-name)] to $final_version_name." + set upgrade_p 1 + set initial_version_name [db_string apm_package_upgrade_from { + select version_name from apm_package_versions + where package_key = :package_key + and version_id = apm_package__highest_version(:package_key) + } -default ""] + } else { + set upgrade_p 0 + set initial_version_name "" + } + + # Find out which script is appropriate to be run. + set data_model_in_package 0 + set table_rows "" + set data_model_files [concat \ + [apm_data_model_scripts_find \ + -upgrade_from_version_name $initial_version_name \ + -upgrade_to_version_name $final_version_name \ + $package_key] \ + [apm_ctl_files_find $package_key]] + + # Install the packages. + set version_id [apm_package_install \ + -enable \ + -install_path "[acs_root_dir]/packages" \ + -load_data_model \ + -data_model_files $data_model_files \ + $spec_file] + + if { $version_id == 0 } { + # Installation of the package failed and we shouldn't continue with installation + # as there might be packages depending on the failed package. Ideally we should + # probably check for such dependencies and continue if there are none. + error "Error installing one of the packages" + } + } + } +} + +##### +# +# Display progress bar +# +##### + + ReturnHeaders -ns_write " +ns_write { - + -
-
+
+
-

Installing packages...

+

Installing packages...

-
-
+
- -" - - - -##### -# -# Install packages -# -##### - - -set pkg_install_list [ad_get_client_property apm pkg_install_list] - -set sql_file_list [list] - - -foreach pkg_info $pkg_install_list { - - set package_key [pkg_info_key $pkg_info] - array set version [apm_read_package_info_file [pkg_info_spec $pkg_info]] - set final_version_name $version(name) - - # Determine if we are upgrading or installing. - if { [apm_package_upgrade_p $package_key $final_version_name] == 1} { - ns_log Debug "Upgrading package [string totitle $version(package-name)] to $final_version_name." - set upgrade_p 1 - set initial_version_name [db_string apm_package_upgrade_from { - select version_name from apm_package_versions - where package_key = :package_key - and version_id = apm_package__highest_version(:package_key) - } -default ""] - } else { - set upgrade_p 0 - set initial_version_name "" - } - - # Find out which script is appropriate to be run. - set data_model_in_package 0 - set table_rows "" - set data_model_files [concat \ - [apm_data_model_scripts_find \ - -upgrade_from_version_name $initial_version_name \ - -upgrade_to_version_name $final_version_name \ - $package_key] \ - [apm_ctl_files_find $package_key]] - - set sql_file_list [concat $sql_file_list $data_model_files] } - - - -set sql_files $sql_file_list - -set error_p 0 - -set installed_count 0 -foreach pkg_info $pkg_install_list { - set spec_file [pkg_info_spec $pkg_info] - if { [catch { - array set version [apm_read_package_info_file $spec_file] - } errmsg] } { - ns_write "
  • Unable to install the [pkg_info_key $pkg_info] package because its specification - file is invalid:
    [ad_quotehtml $errmsg]
    " - continue - } - - if {[apm_package_version_installed_p $version(package.key) $version(name)] } { - # Already installed. - continue - } - - set package_key $version(package.key) - set version_files $version(files) - - set data_model_files [list] - # Find the correct data model files for this package. - foreach file $sql_files { - if {![string compare [lindex $file 2] $package_key]} { - # Pass on the file path and its type. - lappend data_model_files $file - } - } - - # Install the packages. - set version_id [apm_package_install \ - -enable \ - -install_path "[acs_root_dir]/packages" \ - -load_data_model \ - -data_model_files $data_model_files \ - $spec_file] - - if { $version_id == 0 } { - # Installation of the package failed and we shouldn't continue with installation - # as there might be packages depending on the failed package. Ideally we should - # probably check for such dependencies and continue if there are none. - set error_p 1 - break - } - - incr installed_count +while { [util_background_running_p -name package-install] } { + ns_write {} + ns_sleep 1 } - ##### # # Done # ##### -set continue_url [export_vars -base local-install-4 { error_p }] +set success_p [lindex [util_background_get_result -name package-install] 0] + +set continue_url [export_vars -base local-install-4 { success_p }] ns_write "" ns_conn close Index: openacs-4/packages/acs-admin/www/install/local-install-4.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/install/Attic/local-install-4.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-admin/www/install/local-install-4.adp 18 Sep 2003 21:02:30 -0000 1.1 +++ openacs-4/packages/acs-admin/www/install/local-install-4.adp 21 Sep 2003 18:24:19 -0000 1.2 @@ -4,7 +4,7 @@

    Done installing packages.

    - +

    Unfortunately, we had some errors. Please check your server error log or contact your system administrator.

    Index: openacs-4/packages/acs-admin/www/install/local-install-4.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/install/Attic/local-install-4.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-admin/www/install/local-install-4.tcl 18 Sep 2003 21:02:30 -0000 1.1 +++ openacs-4/packages/acs-admin/www/install/local-install-4.tcl 21 Sep 2003 18:24:19 -0000 1.2 @@ -1,7 +1,7 @@ ad_page_contract { Install from local file system } { - {error_p 0} + {success_p 0} } set page_title "Installation Complete" Index: openacs-4/packages/acs-admin/www/install/local-install.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/install/Attic/local-install.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-admin/www/install/local-install.tcl 18 Sep 2003 21:02:30 -0000 1.2 +++ openacs-4/packages/acs-admin/www/install/local-install.tcl 21 Sep 2003 18:24:19 -0000 1.3 @@ -32,20 +32,21 @@ set package_key $version(package.key) if { [apm_package_supports_rdbms_p -package_key $version(package.key)] } { + set installed_p 0 if { ![info exists installed_version($version(package.key))] } { set upgrade_text {} } elseif { [string equal $version(name) $installed_version($version(package.key))] } { - continue + set installed_p 1 } elseif { [apm_higher_version_installed_p $version(package.key) $version(name)] != 1 } { - continue + set installed_p 1 } else { set upgrade_text Upgrade set upgrades_p 1 } # If in upgrade mode, only add to list if it's an upgrade - if { !$upgrade_p || ![empty_string_p $upgrade_text] } { + if { !$installed_p && (!$upgrade_p || ![empty_string_p $upgrade_text]) } { multirow append packages \ $version(package.key) \ $version(package-name) \ @@ -57,7 +58,7 @@ } } { global errorInfo - ns_log Error "Error while checking package info file:\n$errorInfo" + ns_log Error "Error while checking package info file $spec_file: $errmsg\n$errorInfo" } }