Index: openacs-4/packages/acs-admin/www/install/install-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/install/install-3.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-admin/www/install/install-3.tcl 10 Jan 2007 21:22:00 -0000 1.9 +++ openacs-4/packages/acs-admin/www/install/install-3.tcl 27 Oct 2014 16:38:56 -0000 1.10 @@ -13,13 +13,11 @@ # ##### - ad_progress_bar_begin \ -title "Installing Packages" \ -message_1 "Installing selected packages, please wait ..." \ -message_2 "We will continue automatically when installation is complete." - ##### # # Get packages to install @@ -29,7 +27,6 @@ apm_get_package_repository -repository_url $repository_url -array repository set install [ad_get_client_property acs-admin install] - if { [llength $install] == 0 } { ns_log Notice "install-3.tcl: Nothing to install. Is this a double-click?" } @@ -38,8 +35,46 @@ ad_set_client_property acs-admin install {} +# +# Perform a topological sort for the right install order +# +set install_order "" +set to_install $install +ns_log notice "to_install: $to_install" +while {[llength $to_install] > 0} { + foreach package_key $to_install { + array unset version + array set version $repository($package_key) + + set satisfied_p 1 + foreach req [concat $version(embeds) $version(extends) $version(requires)] { + lassign $req pkg req_version + + # + # A package can be installed, when its requirements are + # installed before the package. All other dependencies + # were checked earlier. + # + + if { $pkg in $to_install } { + set satisfied_p 0 + #ns_log notice "we have to delay $pkg" + break + } + } + if {$satisfied_p} { + lappend install_order $package_key + set pos [lsearch $to_install $package_key] + set to_install [lreplace $to_install $pos $pos] + } + } + #ns_log notice "iteration: \nto_install: $to_install\ninstall_order: $install_order" +} + +ns_log notice "Install packages in this order: $install_order" + ##### # # Install packages @@ -48,13 +83,13 @@ set success_p 1 -foreach package_key $install { +foreach package_key $install_order { ns_log Notice "Installing $package_key" array unset version array set version $repository($package_key) - if { [exists_and_not_null version(download_url)] } { + if { ([info exists version(download_url)] && $version(download_url) ne "") } { set spec_file [apm_load_apm_file -url $version(download_url)] if { $spec_file eq "" } { ns_log Error "Error downloading package $package_key from $version(download_url). Installing package failed." @@ -64,7 +99,7 @@ set package_path "[apm_workspace_install_dir]/$package_key" } else { set spec_file $version(path) - set package_path "[acs_root_dir]/packages/$package_key" + set package_path "$::acs::rootdir/packages/$package_key" } set final_version_name $version(name) @@ -102,7 +137,12 @@ ns_log Debug "Data model scripts: \nupgrade_from_version_name = $initial_version_name\nupgrade_to_version_name=$final_version_name\npackage_path=$package_path\npackage_key=$package_key\n => $data_model_files" - # Install the packages -- this actually copies the files into the right place in the file system and backs up any old files + ns_write [subst { +

Installing $package_key ...
+ + }] + # Install the packages -- this actually copies the files into the + # right place in the file system and backs up any old files set version_id [apm_package_install \ -enable \ -package_path $package_path \ @@ -115,7 +155,17 @@ # 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 success_p 0 + } elseif {[file exists $::acs::rootdir/packages/$package_key/install.xml]} { + ns_write "... configure $package_key
\n" + #ns_log notice "===== RUN /packages/$package_key/install.xml" + apm::process_install_xml /packages/$package_key/install.xml "" + ns_write "... installation OK
\n" + } else { + ns_write "... installation OK
\n" } + ns_write { + + } } #####