Index: openacs-4/packages/acs-admin/www/apm/packages-install-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/packages-install-2.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-admin/www/apm/packages-install-2.tcl 17 Oct 2010 21:06:07 -0000 1.12 +++ openacs-4/packages/acs-admin/www/apm/packages-install-2.tcl 27 Oct 2014 16:38:52 -0000 1.13 @@ -6,125 +6,181 @@ @creation-date Mon Oct 9 00:13:43 2000 @cvs-id $Id$ } { - {install:multiple ""} - {enable:multiple ""} - {force_p "f"} + {package_key:multiple ""} + {force_p:boolean "f"} } -# Install and enable are sets of keys; need to turn them back into spec files. -set spec_files [ad_get_client_property apm spec_files] +set title "Package Installation" +set context [list [list "/acs-admin/apm/" "Package Manager"] $title] -# LARS HACK: I got rid of the separate install/enable checkboxes -set install $enable - # Clear out previous client properties. ad_set_client_property -clob t apm pkg_install_list "" -ad_set_client_property -clob t apm pkg_enable_list "" -foreach spec_file $spec_files { - # 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. - # If we get here, its because someone hacked the archive the loading process - # which checks the info file and displays an error. - # process - ns_log Error "$spec_file could not be parsed correctly. It is not being installed. - The error: $errmsg" +if {$package_key eq ""} { + set body { +

+ No packages selected.

} - - # 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(embeds) $package(extends) $package(provides) $package(requires) ""] - - if { [lsearch -exact $install $package(package.key)] != -1 } { - # This is a package which we should install - lappend install_spec_files $spec_file +} else { + + ##### + # + # Check dependencies + # + ##### + apm_get_package_repository -array repository + + set install_pkgs $package_key + while 1 { + set fixpoint_p 1 + + ns_log notice "run apm_dependency_check_new with <$install_pkgs>" + array set result [apm_dependency_check_new \ + -repository_array repository \ + -package_keys $install_pkgs] + #ns_log notice "RESULT of apm_dependency_check_new: [array get result]" + + array set failed $result(failed) + + switch $result(status) { + ok { + set title "Confirm" + } + failed { + set title "Missing Required Packages" + } + default { + error "Bad status returned from apm_depdendency_check_new: '$result(status)'" + } + } + + # + # Get the package info list with potential unresolved dependencies + # + set pkg_info_list {} + foreach pkg $result(packages) { + + # + # Load package info from spec file. + # + if {[catch {set spec_file [apm_package_info_file_path $pkg]}]} { + # + # In case the spec file is not found (unknown package) + # produce an empty entry. + # + array set package [list package.key $pkg embeds "" extends "" \ + provides "" requires "" properties {install ""}] + } else { + array set package [apm_read_package_info_file $spec_file] + } + + if {[info exists failed($pkg)]} { + set comments {} + foreach e $failed($pkg) { + lappend comments "Requires: [lindex $e 0] [lindex $e 1]" + } + set flag f + } else { + lassign {t ""} flag comments + array set properties $package(properties) + + set must_add {} + foreach p $properties(install) { + if {$p ni $install_pkgs} { + lappend must_add $p + } + } + if {[llength $must_add] > 0} { + lappend install_pkgs {*}$must_add + ns_log notice "+++ install_pkgs <$install_pkgs> after must_add <$must_add>" + set fixpoint_p 0 + break + } + } + lappend pkg_info_list [pkg_info_new $package(package.key) \ + $spec_file \ + $package(embeds) \ + $package(extends) \ + $package(provides) \ + $package(requires) \ + $flag $comments] + } + if {$fixpoint_p} break } -} -if {![info exists install_spec_files]} { - doc_body_append "[apm_header "Package Installation"]

-No packages selected.

[ad_footer]" - return -} + # + # When the package list was extended by the dependency test, show + # it again to the user + # -### Dependency Check -set dependency_results [apm_dependency_check -pkg_info_all $pkg_info_list $install_spec_files] + if {$result(status) eq "ok" && [llength $result(install)] > [llength $package_key]} { -if { [lindex $dependency_results 0] == 1 && [llength [lindex $dependency_results 2]] > 0 } { + set body [subst { +

Additional Packages Automatically Added

+ + Some of the packages you were trying to install required + other packages to be installed first. We've added these + additional packages needed, and ask you to review the list + of packages below. - set extra_package_keys [lindex $dependency_results 2] +

+ }] - # Check was good after adding a couple more packages + append body [apm_package_selection_widget $pkg_info_list $result(install)] + append body [subst { + +
+ }] + + } elseif {$result(status) eq "ok" || $force_p} { + + # We use client properties to pass along this information as + # it is fairly large. + ad_set_client_property -clob t apm pkg_install_list $pkg_info_list - doc_body_append "[apm_header "Package Installation"] -

Additional Packages Automatically Added

- - Some of the packages you were trying to install required other packages to be installed first. - We've added these additional packages needed, and ask you to review the list of packages below. + ad_returnredirect packages-install-3 + ad_script_abort -

- [export_form_vars spec_files]

- -

- - " + } else { - set install [concat $install $extra_package_keys] - set enable [concat $enable $extra_package_keys] - - doc_body_append [apm_package_selection_widget [lindex $dependency_results 1] $install $enable] + ### Check failed. Offer user an explanation and an ability to + ### select unselect packages. - doc_body_append " -
- -
- [ad_footer] - " + #[export_vars -form {package_key}]

-} elseif { ([lindex $dependency_results 0] == 1) || $force_p eq "t" } { - ### Check passed! Initiate install. + set body [subst { - # We use client properties to pass along this information as it is fairly large. - ad_set_client_property -clob t apm pkg_install_list [lindex $dependency_results 1] - ad_set_client_property -clob t apm pkg_enable_list $enable +

Unsatisfied Dependencies

+ + Some of the packages you are trying to install have + unsatisfied dependencies. The packages with unsatisfied + dependencies have been deselected. If you wish to install + packages that do not pass dependencies, please click the + "force" option below. - ad_returnredirect packages-install-3 - ad_script_abort -} else { - ### Check failed. Offer user an explanation and an ability to select unselect packages. - doc_body_append "[apm_header "Package Installation"] -

Select Packages to Install

- - Some of the packages you are trying to install have unsatisfied dependencies. The packages - with unsatisfied dependencies have been deselected. If you wish to install packages that do - not pass dependencies, please click the \"force\" option below. -

- - - - If you think you might want to use a package later (but not right away), - install it but don't enable it. - - [export_form_vars spec_files]

- -

- - " - - doc_body_append [apm_package_selection_widget [lindex $dependency_results 1] $install $enable] + +

+ If you think you might want to use a package later (but not right away), + install it but don't enable it. + }] + + append body \ + [apm_package_selection_widget $pkg_info_list $result(install)] \ + [subst { + Force the install

+ + + }] + } - - doc_body_append " -

- Force the install

- - - [ad_footer] - " + } + +ad_return_template apm + +# +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: