1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 // insList : . List of the changes caused by the installation of one or
19 // !~ U toolbox_4 1.0 !
25 // !~ U toolbox_5 1.0 !
27 // tree_out : . Dependency tree of the package (returned by atomsDependencyTree)
32 // toolbox_5 - 1.0: [1x1 struct]
33 // toolbox_4 - 1.0: [1x1 struct]
34 // toolbox_2 - 1.3: [1x1 struct]
35 // toolbox_1 - 1.9: [1x1 struct]
37 function [insList,depTree] = atomsInstallList(packages)
42 // Save the initial path
43 // =========================================================================
46 // Get scilab version (needed for later)
47 // =========================================================================
48 sciversion = strcat(string(getversion("scilab")) + ".");
50 // Check input parameters
51 // =========================================================================
56 error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"atomsInstallList",1))
59 if type(packages) <> 10 then
60 error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"atomsInstallList",1));
63 packages = stripblanks(packages);
65 // Loop on packages and to build the dependency tree
66 // =========================================================================
68 for i=1:size(packages,"*")
70 package = packages(i);
72 if size(regexp(package,"/\s/") ,"*" ) > 1 then
74 error(msprintf(gettext("%s: Wrong value for input argument #%d: it must contain at most one space.\n"),"atomsInstallList",1));
77 if size(regexp(package,"/\s/") ,"*" ) == 0 then
78 // install the most recent version of the package
79 package_names(i) = package;
80 package_versions(i) = "";
82 // A version is specified
83 space = regexp(package,"/\s/");
84 package_names(i) = part(package,[1:space-1]);
85 package_versions(i) = part(package,[space+1:length(package)]);
88 // Ok, The syntax is correct, Now check if it's a valid package
89 if ~ atomsIsPackage(package_names(i),package_versions(i)) then
90 if isempty(package_versions(i)) then
91 package_full_name = package_names(i);
93 package_full_name = package_names(i)+" - "+package_versions(i);
96 error(msprintf(gettext("%s: The package %s is not available.\n"),"atomsInstallList",package_full_name));
99 // Build the depencency tree
100 [tree,version_out] = atomsDependencyTree(package_names(i),package_versions(i));
102 if (type(tree) == 4) & (~ tree) then
104 error(msprintf(gettext("%s: The dependency tree cannot be resolved.\n"),"atomsInstallList",1));
107 // Update the package_versions(i) with the version returned by
108 // atomsDependencyTree
109 package_versions(i) = version_out;
111 // Concatenate the tree with the existing one
112 depTree = atomsCatTree( depTree , tree );
115 // Add a field to detect later if it's the toolbox is automaticaly installed
116 // or if it's a user choice
117 // =========================================================================
119 for i=1:size(package_names,"*")
120 this_package_details = depTree(package_names(i)+" - "+package_versions(i));
121 this_package_details("user_choice") = %T;
122 depTree(package_names(i)+" - "+package_versions(i)) = this_package_details;
125 // Now we have the list of package that have to be installed
126 // We have to check if
127 // - each package is already installed
128 // - If yes, Is it the most recent version
129 // =========================================================================
131 mandatory_packages = getfield(1,depTree);
132 mandatory_packages(1:2) = [];
134 for i=1:size(mandatory_packages,"*")
135 this_package_details = depTree(mandatory_packages(i));
137 this_package_name = this_package_details("Toolbox");
138 this_package_version = this_package_details("Version");
140 if isfield(this_package_details,"user_choice") & this_package_details("user_choice") then
141 this_package_user_choice = "U"; // stand for User Choice
143 this_package_user_choice = ""; // stand for User Choice
148 if atomsIsInstalled(this_package_name) then
149 vers = atomsGetInstalledVers(this_package_name);
150 if find( vers == this_package_version ) == [] then
158 insList = [ insList ; "+" this_package_user_choice this_package_name this_package_version ];
160 insList = [ insList ; "~" this_package_user_choice this_package_name this_package_version ];
165 // Go to the initial location
166 // =========================================================================