- installed packages and dependencies are now saved into binary files
Pierre MARECHAL [Sun, 28 Jun 2009 13:44:29 +0000 (15:44 +0200)]
 - text files are keeped for debugging

16 files changed:
scilab/modules/atoms/macros/atomsGetInstalled.sci
scilab/modules/atoms/macros/atomsIsInstalled.sci
scilab/modules/atoms/macros/atomsIsLoaded.sci
scilab/modules/atoms/macros/atomsLoad.sci
scilab/modules/atoms/macros/atoms_internals/atomsGetDepChilds.sci
scilab/modules/atoms/macros/atoms_internals/atomsGetDepParents.sci
scilab/modules/atoms/macros/atoms_internals/atomsInstallList.sci
scilab/modules/atoms/macros/atoms_internals/atomsInstallRegister.sci
scilab/modules/atoms/macros/atoms_internals/atomsInstallUnregister.sci
scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalled.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledMat.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledStruct.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalleddeps.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalled.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalleddeps.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsUpdateDep.sci [new file with mode: 0644]

index 7926e53..0f3f5ef 100644 (file)
@@ -29,7 +29,7 @@ function packages = atomsGetInstalled(allusers)
                error(msprintf(gettext("%s: Wrong number of input argument: at most %d expected.\n"),"atomsGetInstalled",1));
        end
        
-       // Apply changes for all users or just for me ?
+       // Load all packages, or just user packages ?
        // =========================================================================
        
        if rhs == 0 then
@@ -41,47 +41,15 @@ function packages = atomsGetInstalled(allusers)
                end
        end
        
-       // Define the differents path of the file where are installed
+       // Call atomsLoadInstalledMat
        // =========================================================================
        
-       installed_files = [];
-       user_file       = pathconvert(SCIHOME+"/atoms/installed",%F);
-       alluser_file    = pathconvert(SCI+"/.atoms/installed",%F);
-       
-       if fileinfo(user_file)<>[] then
-               installed_files = [ installed_files ; user_file "user" ];
-       end
-       
-       if allusers & (fileinfo(alluser_file)<>[]) then
-               installed_files = [ installed_files ; alluser_file "allusers"];
-       end
-       
-       // Loop on each "installed" file specified as first input argument
-       // =========================================================================
-       
-       for i=1:size(installed_files(:,1),"*")
-               
-               // Get the installed package list in this file
-               installed = mgetl(installed_files(i,1));
-               
-               // Loop on each URL specified as first input argument
-               for j=1:size(installed,"*")
-                       current_status       = part(installed(j),1:1);
-                       installed(j)         = part(installed(j),5:length(installed(j)));
-                       current_name_length  = regexp(installed(j),"/\s-\s/","o");
-                       current_name         = part(installed(j),1:current_name_length-1);
-                       current_version      = part(installed(j),current_name_length+3:length(installed(j)));
-                       
-                       if installed_files(i,2) == "user" then
-                               // user
-                               current_path  = pathconvert(SCIHOME+"/atoms/"+current_name+"/"+current_version,%F); 
-                       else
-                               // all users
-                               current_path = pathconvert(SCI+"/contrib/"+current_name+"/"+current_version,%F);
-                       end
-                       
-                       packages = [ packages ; current_name current_version installed_files(i,2) current_path current_status];
-               end
+       if allusers then
+               // all packages
+               packages = atomsLoadInstalledMat("all");
+       else
+               // user packages
+               packages = atomsLoadInstalledMat(%F);
        end
        
 endfunction
index dffe031..b6bcb1a 100644 (file)
@@ -68,7 +68,6 @@ function res = atomsIsInstalled(name,version,allusers)
        // =========================================================================
        packages = atomsGetInstalled(allusers);
        
-       
        // Loop on name
        // =========================================================================
        
index 0d5f3ab..c1619c5 100644 (file)
@@ -17,7 +17,7 @@
 
 //   version_out : . If the toolbox is loaded, version_out is the version of the
 //                   loaded toolbox
-//                   otherwise, version_out = "-1"
+//                   otherwise, version_out = ""
 //                 . Matrix of string (n x 1)
 //                 . mandatory
 
index f2cfcc7..cb9b139 100644 (file)
@@ -295,6 +295,6 @@ function result = atomsLoad(name,version)
        
        // Exec the resume cmd
        // =========================================================================
-       // execstr(resume_cmd,"errcatch");
+       execstr(resume_cmd);
        
 endfunction
index 5b7e6e5..9b79e89 100644 (file)
@@ -7,7 +7,7 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-// Returns true if a package is installed, false otherwise
+// Give the list of packages needed by this package (identified by its name and version)
 
 function packages = atomsGetDepChilds(name,version,allusers)
        
@@ -55,63 +55,27 @@ function packages = atomsGetDepChilds(name,version,allusers)
                end
        end
        
-       // Define the differents path of the file where are installed
+       // Load the installed_deps struct
        // =========================================================================
        
-       installed_deps_files = [];
-       user_file            = pathconvert(SCIHOME+"/atoms/installed_deps",%F);
-       alluser_file         = pathconvert(SCI+"/.atoms/installed_deps",%F);
-       
-       if fileinfo(user_file)<>[] then
-               installed_deps_files = [ installed_deps_files ; user_file "user" ];
+       if allusers then
+               // all packages
+               installed_deps = atomsLoadInstalleddeps("all");
+       else
+               // user packages
+               installed_deps = atomsLoadInstalleddeps(%F);
        end
        
-       if allusers & (fileinfo(alluser_file)<>[]) then
-               installed_deps_files = [ installed_deps_files ; alluser_file "allusers"];
+       // If name - version is not a field of the struct, the job is done
+       // =========================================================================
+       
+       if ~ isfield(installed_deps,name+" - "+version) then
+               return;
        end
        
-       // Loop on each "installed_deps" file specified as first input argument
+       // Return the matrix associated with the wanted package (name - version)
        // =========================================================================
        
-       found = 0;
-       
-       for i=1:size(installed_deps_files(:,1),"*")
-               
-               if found == 1 then
-                       break;
-               end
-               
-               // Get the installed package list in this file
-               installed_deps_lines = mgetl(installed_deps_files(i,1));
-               
-               // Loop on each lines
-               for j=1:size(installed_deps_lines,"*")
-                       
-                       // If this line is a "parent toolbox" or a blank line and the wanted toolbox is already found
-                       // Break the loop
-                       
-                       if (found == 1) & ..
-                               ( (regexp(installed_deps_lines(j),"/^\[(.)*\]$/","o") <> []) | isempty(installed_deps_lines(j)) ) then
-                               break;
-                       end
-                       
-                       // Yeah, the wanted toolbox has been found
-                       
-                       if installed_deps_lines(j) == "["+name+" - "+version+"]" then
-                               found = 1;
-                               continue;
-                       end
-                       
-                       // This line is a inevitably a toolbox
-                       if found == 1 then
-                               this_line           = stripblanks(installed_deps_lines(j));
-                               current_name_length = regexp(this_line,"/\s-\s/","o");
-                               current_name        = part(this_line,1:current_name_length-1);
-                               current_version     = part(this_line,current_name_length+3:length(this_line));
-                               packages            = [ packages ; current_name current_version];
-                       end
-                       
-               end
-       end
+       packages = installed_deps(name+" - "+version);
        
 endfunction
index b710bfc..3d74c53 100644 (file)
@@ -7,7 +7,7 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-// Renvoie la liste des packages dont celui passé en argument est une dépendance
+// Give the list of packages that use this package (identified by its name and version)
 
 function packages = atomsGetDepParents(name,version,allusers)
        
@@ -55,55 +55,27 @@ function packages = atomsGetDepParents(name,version,allusers)
                end
        end
        
-       // Define the differents path of the file where are installed
+       // Load the installed_deps struct
        // =========================================================================
        
-       installed_deps_files = [];
-       user_file            = pathconvert(SCIHOME+"/atoms/installed_deps",%F);
-       alluser_file         = pathconvert(SCI+"/.atoms/installed_deps",%F);
-       
-       if fileinfo(user_file)<>[] then
-               installed_deps_files = [ installed_deps_files ; user_file "user" ];
+       if allusers then
+               // all packages
+               [ child_deps,parent_deps ] = atomsLoadInstalleddeps("all");
+       else
+               // user packages
+               [ child_deps,parent_deps ] = atomsLoadInstalleddeps(%F);
        end
        
-       if allusers & (fileinfo(alluser_file)<>[]) then
-               installed_deps_files = [ installed_deps_files ; alluser_file "allusers"];
+       // If name - version is not a field of the struct, the job is done
+       // =========================================================================
+       
+       if ~ isfield(parent_deps,name+" - "+version) then
+               return;
        end
        
-       // Loop on each "installed_deps" file specified as first input argument
+       // Return the matrix associated with the wanted package (name - version)
        // =========================================================================
        
-       for i=1:size(installed_deps_files(:,1),"*")
-               
-               // Get the installed package list in this file
-               installed_deps_lines = mgetl(installed_deps_files(i,1));
-               
-               // Loop on each lines
-               for j=1:size(installed_deps_lines,"*")
-                       
-                       if regexp(installed_deps_lines(j),"/^\[(.)*\]$/","o") <> [] then
-                               
-                               // Remove leading and trailing whitespaces.
-                               this_line = stripblanks(installed_deps_lines(j));
-                               
-                               // Remove leading and trailing [ ]
-                               this_line = part(this_line,2:length(this_line)-1);
-                               
-                               current_name_length = regexp(this_line,"/\s-\s/","o");
-                               current_name        = part(this_line,1:current_name_length-1);
-                               current_version     = part(this_line,current_name_length+3:length(this_line));
-                               current_parent      = [current_name current_version];
-                               
-                               continue;
-                       end
-                       
-                       if stripblanks(installed_deps_lines(j)) == name+" - "+version then
-                               if ~ isempty(current_parent) then
-                                       packages = [ packages ; current_parent ];
-                               end
-                       end
-               end
-               
-       end
+       packages = parent_deps(name+" - "+version);
        
 endfunction
index c371d8e..6c75c2b 100644 (file)
@@ -143,10 +143,10 @@ function [insList,depTree] = atomsInstallList(packages)
                        this_package_user_choice = ""; // stand for User Choice
                end
                
-               to_install = %F; 
+               to_install = %F;
                
                if atomsIsInstalled(this_package_name) then
-                       vers = atomsGetInstalledVers(mandatory_packages(i));
+                       vers = atomsGetInstalledVers(this_package_name);
                        if find( vers == this_package_version ) == [] then
                                to_install = %T;
                        end
index cf9cd7c..c322e2a 100644 (file)
@@ -9,15 +9,13 @@
 
 // Add toolboxes to the list of installed packages
 // This function has an impact on the following files :
-//  -> ATOMSDIR/installed
-//  -> ATOMSDIR/installed_deps
+//  -> ATOMSDIR/installed.txt, ATOMSDIR/installed.bin
+//  -> ATOMSDIR/installed_deps.txt, ATOMSDIR/installed_deps.bin
 
 function nbAdd = atomsInstallRegister(name,version,status,allusers)
        
        rhs            = argn(2);
        nbAdd          = 0;
-       installed      = []; // Column vector that contain installed packages
-       installed_deps = []; // Column vector that contain installed dependencies
        
        // Check number of input arguments
        // =========================================================================
@@ -62,7 +60,7 @@ function nbAdd = atomsInstallRegister(name,version,status,allusers)
        // Apply changes for all users or just for me ?
        // =========================================================================
        
-       if rhs == 3 then
+       if rhs < 4 then
                // By default, The toolbox is installed for all users (if we have write access of course !)
                if atomsAUWriteAccess() then
                        allusers = %T; 
@@ -73,7 +71,7 @@ function nbAdd = atomsInstallRegister(name,version,status,allusers)
        else
                // Just check if it's a boolean
                if type(allusers) <> 4 then
-                       error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"atomsInstallRegister",2));
+                       error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"atomsInstallRegister",4));
                end
                
                // Check if we have the write access
@@ -82,92 +80,65 @@ function nbAdd = atomsInstallRegister(name,version,status,allusers)
                end
        end
        
-       // Define the path of the file that will record the change according to
-       // the "allusers" value
-       // =========================================================================
-       
-       if allusers then
-               atoms_directory = pathconvert(SCI+"/.atoms");
-       else
-               atoms_directory = pathconvert(SCIHOME+"/atoms");
-       end
-       
-       // Does the atoms_directory exist, if not create it
-       // =========================================================================
        
-       if ~ isdir(atoms_directory) then
-               mkdir(atoms_directory);
-       end
-       
-       // Does the SCIHOME/atoms/installed exist, if yes load it
+       // load installed packages (a struct)
        // =========================================================================
+       installed = atomsLoadInstalledStruct(allusers);
        
-       if fileinfo(atoms_directory+"installed") <> [] then
-               installed = mgetl(atoms_directory+"installed");
-       end
-       
-       // Does the SCIHOME/atoms/installed_deps exist, if yes load it
+       // Load the installed_deps (a struct)
        // =========================================================================
-       
-       if fileinfo(atoms_directory+"installed_deps") <> [] then
-               installed_deps = mgetl(atoms_directory+"installed_deps");
-       end
+       installed_deps = atomsLoadInstalleddeps(allusers);
        
        // Loop on each URL specified as input argument
        // =========================================================================
-       
        for i=1:size(name,"*")
                
-               // Add the URL only if it doesn't already exist
-               if grep( installed ,"/^[AI]\s-\s"+name(i)+"\s-\s"+version(i)+"$/","r") == [] then
-                       
+               if isfield(installed,name(i)+" - "+version(i)) then
+                       // This package is already registered
+                       continue;
+               else
+                       // We have at least one change
                        nbAdd = nbAdd + 1;
-                       
-                       // installed file
-                       // =================================================================
-                       installed = [ installed ; status(i)+" - "+name(i)+" - "+version(i) ];
-                       
-                       // installed_deps file
-                       // =================================================================
-                       
-                       // Parent package
-                       // --------------
-                       this_package_str = ["["+name(i)+" - "+version(i)+"]"];
-                       
-                       // Get the depencency tree & and child package
-                       // -------------------------------------------
-                       tree              = atomsDependencyTree(name(i),version(i));
-                       dep_packages      = getfield(1,tree);
-                       dep_packages(1:2) = [];
-                       dep_packages(find(dep_packages == name(i))) = [];
-                       
-                       // loop on childs
-                       // -------------------------------------------
-                       for j=1:size(dep_packages,"*")
-                               this_dep_package_details = tree(dep_packages(j));
-                               this_package_str = [this_package_str;"    "+this_dep_package_details("Toolbox")+" - "+this_dep_package_details("Version")];
-                       end
-                       
-                       // Finalize the current packages string
-                       // ------------------------------------
-                       this_package_str  = [this_package_str;""];
-                       
-                       // Cat the current packages deps with all others
-                       // ---------------------------------------------
-                       installed_deps    = [installed_deps;this_package_str];
-                       
                end
                
+               // installed struct
+               // ---------------------------------------------------------------------
+               
+               // Build the matrix
+               
+               if allusers then
+                       this_package_path    = pathconvert(SCI+"/contrib/"+name(i)+"/"+version(i),%F);
+                       this_package_uservar = "allusers";
+               else
+                       this_package_path    = pathconvert(SCIHOME+"/atoms/"+name(i)+"/"+version(i),%F);
+                       this_package_uservar = "user";
+               end
+               
+               // Add this package to the struct
+               installed(name(i)+" - "+version(i)) = [ .. 
+                       name(i)              ; .. // name
+                       version(i)           ; .. // version
+                       this_package_path    ; .. // path
+                       this_package_uservar ; .. // allusers / user
+                       status(i)            ];   // I / A
+               
+               // installed_deps file
+               // Get the depencency tree & and child package
+               // ---------------------------------------------------------------------
+               
+               childs_tree = atomsDependencyTree(name(i),version(i));
+               childs_mat  = getfield(1,childs_tree);
+               childs_mat(1:2) = [];
+               childs_mat( find(childs_mat == name(i)+" - "+version(i)) ) = [];
+               installed_deps(name(i)+" - "+version(i)) = childs_mat';
        end
        
        // Apply changes
        // =========================================================================
        
        if nbAdd > 0 then
-               
-               mputl(installed     , atoms_directory+"installed");
-               mputl(installed_deps, atoms_directory+"installed_deps");
-               
+               atomsSaveInstalled(installed,allusers);
+               atomsSaveInstalleddeps(installed_deps,allusers);
        end
        
 endfunction
index 25b1c08..cfb543e 100644 (file)
 //  -> ATOMSDIR/installed
 //  -> ATOMSDIR/installed_deps
 
-function nbDel = atomsInstallUnregister(name,version,allusers)
+function atomsInstallUnregister(name,version,allusers)
        
-       rhs                  = argn(2);
-       nbDel                = 0;
+       rhs = argn(2);
        
        // Check number of input arguments
        // =========================================================================
@@ -66,102 +65,53 @@ function nbDel = atomsInstallUnregister(name,version,allusers)
                end
        end
        
-       // Define the path of the files that will record the change according to
-       // the "allusers" value and the existence of the latter
+       // Process installed
        // =========================================================================
+       installed_before = atomsLoadInstalledStruct(allusers);
+       installed_after  = atomsRmfields(installed_before,name+" - "+version);
+       atomsSaveInstalled(installed_after);
        
-       // installed files
+       // Process installed dependencies
+       // =========================================================================
+       installed_deps_before = atomsLoadInstalleddeps(allusers);
+       installed_deps_after  = atomsRmfields(installed_deps_before,name+" - "+version);
+       atomsSaveInstalleddeps(installed_deps_after);
        
-       atoms_files = [];
+endfunction
+
+
+function struct_out = atomsRmfields(struct_in,fields_to_remove)
        
-       if fileinfo( pathconvert(SCIHOME+"/atoms/installed",%F) )<> [] then
-               atoms_files = [ atoms_files ; pathconvert(SCIHOME+"/atoms/installed",%F) ];
-       end
+       rhs        = argn(2);
+       struct_out = struct();
        
-       if allusers & (fileinfo( pathconvert(SCI+"/.atoms/installed",%F) )<>[]) then
-               atoms_files = [ atoms_files ; pathconvert(SCI+"/.atoms/installed",%F) ];
-       end
+       // Check number of input arguments
+       // =========================================================================
        
-       // installed_deps files
+       if rhs <> 2 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsRmfields",2));
+       end
        
-       atoms_files_deps = [];
+       // Check input parameters type
+       // =========================================================================
        
-       if fileinfo( pathconvert(SCIHOME+"/atoms/installed_deps",%F) )<> [] then
-               atoms_files_deps = [ atoms_files_deps ; pathconvert(SCIHOME+"/atoms/installed_deps",%F) ];
+       if type(struct_in) <> 17 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: Struct expected.\n"),"atomsRmfields",1));
        end
        
-       if allusers & (fileinfo( pathconvert(SCI+"/.atoms/installed_deps",%F) )<>[]) then
-               atoms_files_deps = [ atoms_files_deps ; pathconvert(SCI+"/.atoms/installed_deps",%F) ];
+       if type(fields_to_remove) <> 10 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"atomsRmfields",1));
        end
        
-       // Loop on each installed file specified as first input argument
-       // =========================================================================
+       // Get the fields of the 1st input argument
+       // =========================================================================    
        
-       for i=1:size(atoms_files,"*")
-               
-               // Get the installed package list in this file
-               installed = mgetl(atoms_files(i));
-               
-               // Loop on each URL specified as first input argument
-               for j=1:size(name,"*")
-                       indice = grep(installed,"/^[AI]\s-\s"+name(j)+"\s-\s"+version(j)+"$/","r");
-                       
-                       if indice <> [] then
-                               nbDel = nbDel + 1;
-                               installed(indice) = [];
-                       end
-               end
-               
-               if installed == [] then
-                       mdelete(atoms_files(i));
-               else
-                       // Apply changes on this file
-                       mputl(installed,atoms_files(i));
-               end
-       end
-       
-       // Loop on each installed file specified as first input argument
-       // =========================================================================
+       fields_in      = getfield(1,struct_in);
+       fields_in(1:2) = [];
        
-       for i=1:size(atoms_files_deps,"*")
-               
-               found = 0;
-               
-               // Get the installed package list in this file
-               installed_deps_in  = mgetl(atoms_files_deps(i));
-               installed_deps_out = [];
-               
-               // Loop on each URL specified as first input argument
-               for j=1:size(name,"*")
-                       
-                       // Loop on each lines of the installed_deps file
-                       for k=1:size(installed_deps_in,"*")
-                               
-                               if installed_deps_in(k) == "["+name(j)+" - "+version(j)+"]" then
-                                       found = 1;
-                                       continue;
-                               end
-                               
-                               if regexp(installed_deps_in(k),"/^\[(.)*\]$/","o") <> [] then
-                                       found = 0;
-                               end
-                               
-                               if found == 1 then
-                                       continue;
-                               end
-                               
-                               if found == 0 then
-                                       installed_deps_out = [ installed_deps_out , installed_deps_in(k) ];
-                               end
-                       end
-                       
-               end
-               
-               if installed_deps_out == [] then
-                       mdelete(atoms_files_deps(i));
-               else
-                       // Apply changes on this file
-                       mputl(installed_deps_out,atoms_files_deps(i));
+       for i=1:size( fields_in,"*")
+               if find(fields_in(i) == fields_to_remove) == [] then
+                       struct_out( fields_in(i) ) = struct_in(fields_in(i));
                end
        end
        
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalled.sci b/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalled.sci
new file mode 100644 (file)
index 0000000..b780dc4
--- /dev/null
@@ -0,0 +1,65 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+function matrix_out = atomsLoadInstalledMat(allusers)
+       
+       rhs = argn(2);
+       
+       // Init the output argument
+       // =========================================================================
+       matrix_out = [];
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 1 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsLoadInstalled",1));
+       end
+       
+       // Check number of input argument type
+       // =========================================================================
+       
+       if (type(allusers)<>4) & (type(allusers)<>10) then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or a string expected.\n"),"atomsLoadInstalled",1));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if (type(allusers)==10) & (allusers=="all") then
+               installed_file = [ pathconvert(SCI+"/.atoms/installed.bin",%F); pathconvert(SCIHOME+"/atoms/installed.bin",%F) ];
+       elseif allusers then
+               installed_file = pathconvert(SCI+"/.atoms/installed.bin",%F);
+       else
+               installed_file = pathconvert(SCIHOME+"/atoms/installed.bin",%F);
+       end
+       
+       // Loop on installed files
+       // =========================================================================
+       
+       for i=1:size(installed_file,"*")
+               
+               // Does the file exist,
+               // If yes, load the tree
+               // If not, the job is done for this file
+               // ---------------------------------------------------------------------
+               
+               if fileinfo(installed_file(i)) <> [] then
+                       load(installed_file(i),"installed_mat");
+               else
+                       continue
+               end
+               
+               matrix_out = [ matrix_out ; installed_mat ];
+       end
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledMat.sci b/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledMat.sci
new file mode 100644 (file)
index 0000000..25e1ca9
--- /dev/null
@@ -0,0 +1,65 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+function matrix_out = atomsLoadInstalledMat(allusers)
+       
+       rhs = argn(2);
+       
+       // Init the output argument
+       // =========================================================================
+       matrix_out = [];
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 1 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsLoadInstalledMat",1));
+       end
+       
+       // Check number of input argument type
+       // =========================================================================
+       
+       if (type(allusers)<>4) & (type(allusers)<>10) then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or a string expected.\n"),"atomsLoadInstalledMat",1));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if (type(allusers)==10) & (allusers=="all") then
+               installed_file = [ pathconvert(SCI+"/.atoms/installed.bin",%F); pathconvert(SCIHOME+"/atoms/installed.bin",%F) ];
+       elseif allusers then
+               installed_file = pathconvert(SCI+"/.atoms/installed.bin",%F);
+       else
+               installed_file = pathconvert(SCIHOME+"/atoms/installed.bin",%F);
+       end
+       
+       // Loop on installed files
+       // =========================================================================
+       
+       for i=1:size(installed_file,"*")
+               
+               // Does the file exist,
+               // If yes, load the tree
+               // If not, the job is done for this file
+               // ---------------------------------------------------------------------
+               
+               if fileinfo(installed_file(i)) <> [] then
+                       load(installed_file(i),"installed_mat");
+               else
+                       continue
+               end
+               
+               matrix_out = [ matrix_out ; installed_mat ];
+       end
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledStruct.sci b/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalledStruct.sci
new file mode 100644 (file)
index 0000000..0fb888a
--- /dev/null
@@ -0,0 +1,66 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+function struct_out = atomsLoadInstalledStruct(allusers)
+       
+       rhs = argn(2);
+       
+       // Init the output argument
+       // =========================================================================
+       struct_out = struct();
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 1 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsLoadInstalledStruct",1));
+       end
+       
+       // Check number of input argument type
+       // =========================================================================
+       
+       if (type(allusers)<>4) & (type(allusers)<>10) then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or a string expected.\n"),"atomsLoadInstalledStruct",1));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if (type(allusers)==10) & (allusers=="all") then
+               installed_file = [ pathconvert(SCI+"/.atoms/installed.bin",%F); pathconvert(SCIHOME+"/atoms/installed.bin",%F) ];
+       elseif allusers then
+               installed_file = pathconvert(SCI+"/.atoms/installed.bin",%F);
+       else
+               installed_file = pathconvert(SCIHOME+"/atoms/installed.bin",%F);
+       end
+       
+       // Loop on installed files
+       // =========================================================================
+       
+       for i=1:size(installed_file,"*")
+               
+               // Does the file exist,
+               // If yes, load the tree
+               // If not, the job is done for this file
+               // ---------------------------------------------------------------------
+               
+               if fileinfo(installed_file(i)) <> [] then
+                       load(installed_file(i),"installed_struct");
+               else
+                       continue
+               end
+               
+               struct_out = atomsCatTree(struct_out,installed_struct);
+               
+       end
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalleddeps.sci b/scilab/modules/atoms/macros/atoms_internals/atomsLoadInstalleddeps.sci
new file mode 100644 (file)
index 0000000..f05c872
--- /dev/null
@@ -0,0 +1,73 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+function [child_deps_tree,parent_deps_tree] = atomsLoadInstalleddeps(allusers)
+       
+       lhs = argn(1);
+       rhs = argn(2);
+       
+       // Init the output argument
+       // =========================================================================
+       child_deps_tree  = struct();
+       parent_deps_tree = struct();
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 1 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsLoadInstalleddeps",1));
+       end
+       
+       // Check number of input argument type
+       // =========================================================================
+       
+       if (type(allusers)<>4) & (type(allusers)<>10) then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or a string expected.\n"),"atomsLoadInstalleddeps",1));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if (type(allusers)==10) & (allusers=="all") then
+               installed_deps_file = [ pathconvert(SCI+"/.atoms/installed_deps.bin",%F); pathconvert(SCIHOME+"/atoms/installed_deps.bin",%F) ];
+       elseif allusers then
+               installed_deps_file = pathconvert(SCI+"/.atoms/installed_deps.bin",%F);
+       else
+               installed_deps_file = pathconvert(SCIHOME+"/atoms/installed_deps.bin",%F);
+       end
+       
+       // Loop on installed_deps files
+       // =========================================================================
+       
+       for i=1:size(installed_deps_file,"*")
+               
+               // Does the file exist,
+               // If yes, load the tree
+               // If not, the job is done for this file
+               // ---------------------------------------------------------------------
+               
+               if fileinfo(installed_deps_file(i)) <> [] then
+                       load(installed_deps_file(i),"child_deps","parent_deps");
+               else
+                       continue
+               end
+               
+               // contenate installed_deps into tree_out
+               child_deps_tree = atomsCatTree(child_deps_tree,child_deps);
+               
+               if lhs > 1 then
+                       parent_deps_tree = atomsCatTree(parent_deps_tree,parent_deps);
+               end
+               
+       end
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalled.sci b/scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalled.sci
new file mode 100644 (file)
index 0000000..0dd6060
--- /dev/null
@@ -0,0 +1,95 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+function  atomsSaveInstalled(installed_struct,allusers)
+       
+       rhs = argn(2);
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 2 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"atomsSaveInstalled",2));
+       end
+       
+       // Check type of input argument type
+       // =========================================================================
+       
+       if type(installed_struct) <> 17 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A struct expected.\n"),"atomsSaveInstalled",1));
+       end
+       
+       if type(allusers) <> 4 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"atomsSaveInstalled",2));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if allusers then
+               atoms_directory = pathconvert(SCI+"/.atoms");
+       else
+               atoms_directory = pathconvert(SCIHOME+"/atoms");
+       end
+       
+       // Does the atoms_directory exist, if not create it
+       // =========================================================================
+       
+       if ~ isdir(atoms_directory) then
+               mkdir(atoms_directory);
+       end
+       
+       // Define the path of the file that will record the change according 
+       // =========================================================================
+       installed_txt = atoms_directory+"installed.txt";
+       installed_bin = atoms_directory+"installed.bin";
+       
+       // Build the installed_mat and the installed_str
+       // =========================================================================
+       
+       installed_mat = [];
+       installed_str = [];
+       
+       packages      = getfield(1,installed_struct);
+       packages(1:2) = [];
+       
+       for i=1:size(packages,"*")
+               
+               this_package_details  = installed_struct(packages(i));
+               
+               this_package_name     = this_package_details(1);
+               this_package_version  = this_package_details(2);
+               this_package_path     = this_package_details(3);
+               this_package_allusers = this_package_details(4);
+               this_package_status   = this_package_details(5);
+               
+               installed_mat = [ installed_mat ; this_package_name this_package_version this_package_allusers this_package_path this_package_status];
+               installed_str = [ installed_str ; "[ "+this_package_name+" - "+this_package_version+" - "+this_package_allusers+" - "+this_package_path+" - "+this_package_status+" ]" ];
+               
+       end
+       
+       // If packages is empty, no need to keep the files
+       // =========================================================================
+       
+       if isempty(packages) then
+               mdelete(installed_txt);
+               mdelete(installed_bin);
+               return;
+       end
+       
+       // write files
+       // =========================================================================
+       
+       mputl( installed_str , installed_txt);
+       save( installed_bin , installed_struct , installed_mat );
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalleddeps.sci b/scilab/modules/atoms/macros/atoms_internals/atomsSaveInstalleddeps.sci
new file mode 100644 (file)
index 0000000..5a8500d
--- /dev/null
@@ -0,0 +1,174 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Internal function
+
+
+// Save two trees :
+//   - package -> childs : give the list of packages needed by "package"
+//   - package -> parents : give the list of packages used by "package"
+
+// The two trees are saved in two formats :
+//   - text file   : installed_deps.txt
+//   - binary file : installed_deps.bin
+
+
+// Input arguments :
+
+//   child_deps : .list of packages needed by "package"
+//                . struct 
+//                . mandatory
+
+//   allusers : . Tell where will be record the change
+//              . boolean 
+//              . optionnal
+
+function  atomsSaveInstalleddeps(child_deps,allusers)
+       
+       rhs = argn(2);
+       
+       // Check number of input arguments
+       // =========================================================================
+       
+       if rhs <> 2 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"atomsSaveInstalleddeps",2));
+       end
+       
+       // Check type of input argument type
+       // =========================================================================
+       
+       if type(child_deps) <> 17 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A struct expected.\n"),"atomsSaveInstalleddeps",1));
+       end
+       
+       if type(allusers) <> 4 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"atomsSaveInstalleddeps",2));
+       end
+       
+       // Define the path of the file that will record the change according to
+       // the "allusers" value
+       // =========================================================================
+       
+       if allusers then
+               atoms_directory = pathconvert(SCI+"/.atoms");
+       else
+               atoms_directory = pathconvert(SCIHOME+"/atoms");
+       end
+       
+       // Does the atoms_directory exist, if not create it
+       // =========================================================================
+       
+       if ~ isdir(atoms_directory) then
+               mkdir(atoms_directory);
+       end
+       
+       // Define the path of the file that will record the change according to
+       // =========================================================================
+       installed_deps_txt = atoms_directory+"installed_deps.txt";
+       installed_deps_bin = atoms_directory+"installed_deps.bin";
+       
+       
+       // List of installed packages
+       // =========================================================================
+       parents_packages = getfield(1,child_deps);
+       parents_packages(1:2) = [];
+       
+       
+       // Build the package->parents struct
+       // =========================================================================
+       
+       parent_deps = struct();
+       
+       for i=1:size(parents_packages,"*")
+               
+               this_package_parents = [];
+               
+               for j=1:size(parents_packages,"*")
+                       
+                       child_packages = child_deps( parents_packages(j) );
+                       if find(parents_packages(i) == child_packages) <> [] then
+                               this_package_parents = [ this_package_parents ;  parents_packages(j) ];
+                       end
+                       
+               end
+               
+               parent_deps( parents_packages(i) ) = this_package_parents;
+               
+       end
+       
+       // Build the string matrix (=> text file)
+       // =========================================================================
+       
+       string_matrix = [];
+       
+       // childs
+       // -------------------------------------------------------------------------
+       
+       string_matrix = [ string_matrix ; "# ==============================================================================" ];
+       string_matrix = [ string_matrix ; "# Packages childs" ];
+       string_matrix = [ string_matrix ; "# ==============================================================================" ];
+       string_matrix = [ string_matrix ; "" ];
+       
+       for i=1:size(parents_packages,"*")
+               
+               // parent
+               string_matrix = [ string_matrix ; "["+parents_packages(i)+"]" ];
+               
+               // childs
+               child_package = child_deps( parents_packages(i) );
+               for j=1:size(child_package,"*")
+                       string_matrix = [ string_matrix ; "    "+child_package(j) ];
+               end
+               
+               // spaces
+               string_matrix = [ string_matrix ; "" ];
+               
+       end
+       
+       // parents
+       // -------------------------------------------------------------------------
+       
+       string_matrix = [ string_matrix ; "" ];
+       string_matrix = [ string_matrix ; "# ==============================================================================" ];
+       string_matrix = [ string_matrix ; "# Packages parents" ];
+       string_matrix = [ string_matrix ; "# ==============================================================================" ];
+       string_matrix = [ string_matrix ; "" ];
+       
+       for i=1:size(parents_packages,"*")
+               
+               // parent
+               string_matrix = [ string_matrix ; "["+parents_packages(i)+"]" ];
+               
+               // childs
+               parent_package = parent_deps( parents_packages(i) );
+               for j=1:size(parent_package,"*")
+                       string_matrix = [ string_matrix ; "    "+parent_package(j) ];
+               end
+               
+               // spaces
+               string_matrix = [ string_matrix ; "" ];
+               
+       end
+       
+       // If parents_packages is empty, no need to keep the files
+       // =========================================================================
+       
+       if isempty(parents_packages) then
+               mdelete(installed_deps_txt);
+               mdelete(installed_deps_bin);
+               return;
+       end
+       
+       // write files
+       // =========================================================================
+       
+       mputl(string_matrix,installed_deps_txt);
+       save(installed_deps_bin,child_deps,parent_deps);
+       
+endfunction
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsUpdateDep.sci b/scilab/modules/atoms/macros/atoms_internals/atomsUpdateDep.sci
new file mode 100644 (file)
index 0000000..bde98f3
--- /dev/null
@@ -0,0 +1,79 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// Load one or several toolboxes
+
+function result = atomsUpdateDep(name_parent,version_parent,name_child,version_child)
+       
+       // Init the output argument
+       // =========================================================================
+       result = %F;
+       
+       // Check number of input arguments
+       // =========================================================================
+       rhs = argn(2);
+       if rhs <> 4 then
+               error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsUpdateDep",2));
+       end
+       
+       // Check input parameters type
+       // =========================================================================
+       
+       if type(name_parent) <> 10 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsUpdateDep",1));
+       end
+       
+       if type(version_parent) <> 10 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsUpdateDep",2));
+       end
+       
+       if type(name_child) <> 10 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsUpdateDep",3));
+       end
+       
+       if type(version_child) <> 10 then
+               error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsUpdateDep",4));
+       end
+       
+       // Check input parameters size
+       // =========================================================================
+       
+       if size(name_parent,"*") <> 1 then
+               error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsUpdateDep",1));
+       end
+       
+       if size(version_parent,"*") <> 1 then
+               error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsUpdateDep",2));
+       end
+       
+       if size(name_child,"*") <> 1 then
+               error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsUpdateDep",3));
+       end
+       
+       if size(version_child,"*") <> 1 then
+               error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsUpdateDep",4));
+       end
+       
+       // Define the path of the loaded file
+       // =========================================================================
+       loaded_file = pathconvert(TMPDIR+"/atoms/loaded",%F);
+       
+       // Does the loaded file exist, otherwise return FALSE
+       // =========================================================================
+       if fileinfo(loaded_file) <> [] then
+               loaded = mgetl(loaded_file);
+       else
+               return;
+       end
+       
+       
+       
+       
+       
+endfunction