bug fix 8648 - delete the tarball when uninstalling 37/4837/11
Simon GARESTE [Fri, 2 Sep 2011 14:33:25 +0000 (16:33 +0200)]
Change-Id: Idaf3e0a344d5a0fcaa33b965bf5821fcf1577433

SEP/SEP_071_atomsDeleteTarball.odt [new file with mode: 0644]
scilab/CHANGES_5.4.X
scilab/modules/atoms/help/en_US/atomsRemove.xml
scilab/modules/atoms/macros/atomsRemove.sci
scilab/modules/atoms/macros/atoms_internals/atomsDeleteTarball.sci [new file with mode: 0644]
scilab/modules/atoms/macros/atoms_internals/atomsDisp.sci
scilab/modules/atoms/macros/atoms_internals/atomsRemoveList.sci
scilab/modules/atoms/tests/unit_tests/atomsRemove.dia.ref [new file with mode: 0644]
scilab/modules/atoms/tests/unit_tests/atomsRemove.tst [new file with mode: 0644]

diff --git a/SEP/SEP_071_atomsDeleteTarball.odt b/SEP/SEP_071_atomsDeleteTarball.odt
new file mode 100644 (file)
index 0000000..609e87c
Binary files /dev/null and b/SEP/SEP_071_atomsDeleteTarball.odt differ
index 8437351..bf72724 100644 (file)
@@ -587,6 +587,8 @@ ATOMS:
 
 * bug 5380 fixed - atomsShow() output was broken (separators were not aligned).
 
+* bug 8648 fixed - We did not delete the tarball when removing a module (SEP 71).
+
 * bug 8664 fixed - Message error updated for non supported OS.
 
 * bug 8763 fixed - ATOMS installation path was shared on Windows 64 with 32 bits.
@@ -597,6 +599,8 @@ ATOMS:
 
 * bug 8942, 9805 fixed - atomsSystemUpdate() failed on some Windows.
 
+* bug 9805 fixed - atomsSystemUpdate() failed on some Windows.
+
 * bug 9967 fixed - windows UAC causing trouble with atomsRepositorySetOfl (internal function)
 
 * bug 10025 fixed - wrong url in some examples from help files
@@ -604,6 +608,7 @@ ATOMS:
 * bug 10031 fixed - atomsDisp did not work with Verbose option set to True and "\n" in messages.
 
 
+
 Javasci:
 ========
 
@@ -627,6 +632,7 @@ returns the value of the ScilabTypeEnum enum.
                    EDT was crashing the execution of a java program.
 
 
+
 CACSD and Signal processing
 ==========================
 * bug 1635 fixed - iir filter frequency response may be wrong. "pole zero gain"
@@ -659,6 +665,7 @@ CACSD and Signal processing
 
 * bug 10169 fixed - bad clipping option in evans.
 
+
 Misc:
 =====
 
index 8a36ca8..8099c44 100644 (file)
@@ -24,7 +24,7 @@
   <refsynopsisdiv>
     <title>Calling Sequence</title>
     <synopsis>
-         result = atomsRemove(modules[,section])
+         result = atomsRemove(modules[,section][,delete])
        </synopsis>
   </refsynopsisdiv>
   <!-- ===================================================================== -->
                                        </para>
         </listitem>
                        </varlistentry>
+                       <varlistentry>
+        <term>delete</term>
+        <listitem>
+          <para>
+                                               <literal>delete</literal> is a boolean. If set to %T (True), the .zip or .tar.gz file containing 
+the sources will also be deleted. This includes the dependencies' archives files that were installed with the module, if any.
+                                       </para>
+        </listitem>
+                       </varlistentry>
                        
       <varlistentry>
         <term>result</term>
@@ -254,6 +263,16 @@ disp(atomsGetInstalled());
 atomsRemove("toolbox_4","allusers");
 disp(atomsGetInstalled());
 
+// Remove a module, including its archive file
+
+atomsInstall("toolbox_4");
+atomsRemove("toolbox_4",%T);
+
+// Remove a module from a specific section, including its archive file
+
+atomsInstall("toolbox_4");
+atomsRemove("toolbox_4","user",%T);
+
 // Unload the test repository
 atomsRepositoryDel("http://scene2.test.atoms.scilab.org");
 
@@ -266,7 +285,7 @@ atomsRepositoryDel("http://scene2.test.atoms.scilab.org");
 <title>See Also</title>
     <simplelist type="inline">
       <member>
-        <link linkend="atomsInstall">atomsRemove</link>
+        <link linkend="atomsInstall">atomsInstall</link>
       </member>
       <member>
         <link linkend="atomsIsInstalled">atomsIsInstalled</link>
@@ -282,7 +301,7 @@ atomsRepositoryDel("http://scene2.test.atoms.scilab.org");
   <refsection>
     <title>Authors</title>
     <simplelist type="vert">
-      <member>Pierre MARECHAL - DIGITEO</member>
+      <member>Simon GARESTE - DIGITEO</member>
     </simplelist>
   </refsection>
 </refentry>
index f7be5ac..7029e89 100644 (file)
@@ -11,7 +11,7 @@
 
 // Remove a toolbox
 
-function result = atomsRemove(packages,section)
+function result = atomsRemove(packages,section,del)
 
     result = [];
 
@@ -38,8 +38,8 @@ function result = atomsRemove(packages,section)
 
     rhs = argn(2);
 
-    if rhs < 1 | rhs > 2 then
-        error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"atomsRemove",1,2))
+    if rhs < 1 | rhs > 3 then
+        error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"atomsRemove",1,3))
     end
 
     if type(packages) <> 10 then
@@ -92,22 +92,69 @@ function result = atomsRemove(packages,section)
             section = "user";
         end
 
-    else
+        del = %F;
+
+    elseif rhs==2 then
 
         // Process the 2nd input argument : section
         // Allusers can be a boolean or equal to "user" or "allusers"
 
-        if type(section) <> 10 then
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsRemove",2));
+        if typeof(section) <> "string" & typeof(section) <> "boolean" then
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or single string expected.\n"),"atomsRemove",2));
+        end
+
+        if size(section, "*") <> 1 then
+            error(msprintf(gettext("%s: Wrong size for input argument #%d: A boolean or single string expected.\n"),"atomsRemove",2));
+        end
+
+        if typeof(section) == "string" then
+            if and(section<>["user","allusers","all"]) then
+                error(msprintf(gettext("%s: Wrong value for input argument #%d: ''user'' or ''allusers'' or ''all'' expected.\n"),"atomsRemove",1));
+            end
+
+            // Check if we have the write access
+            if or(section==["all","allusers"]) & ~ ATOMSALLUSERSWRITEACCESS then
+                error(msprintf(gettext("%s: You haven''t write access on this directory : %s.\n"),"atomsRemove",2,atomsPath("system","user")));
+            end
+
+            del = %F;
+        else
+            del = section;
+            if ATOMSALLUSERSWRITEACCESS then
+                section = "all";
+            else
+                section = "user";
+            end
+        end
+
+    else
+
+        if typeof(section) <> "string" then
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean or single string expected.\n"),"atomsRemove",2));
+        end
+
+        if size(section, "*") <> 1 then
+            error(msprintf(gettext("%s: Wrong size for input argument #%d: A boolean or single string expected.\n"),"atomsRemove",2));
         end
 
-        if and(section<>["user","allusers","all"]) then
-            error(msprintf(gettext("%s: Wrong value for input argument #%d: ''user'' or ''allusers'' or ''all'' expected.\n"),"atomsRemove",1));
+        // Process the 3rd input argument : delete
+        if typeof(del) <> "boolean" then
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"atomsRemove",3));
         end
 
-        // Check if we have the write access
-        if or(section==["all","allusers"]) & ~ ATOMSALLUSERSWRITEACCESS then
-            error(msprintf(gettext("%s: You haven''t write access on this directory : %s.\n"),"atomsRemove",2,atomsPath("system","user")));
+        if size(del, "*") <> 1 then
+            error(msprintf(gettext("%s: Wrong size for input argument #%d: A boolean expected.\n"),"atomsRemove",3));
+        end
+
+        if typeof(section) == "string" then
+            if and(section<>["user","allusers","all"]) then
+                error(msprintf(gettext("%s: Wrong value for input argument #%d: ''user'' or ''allusers'' or ''all'' expected.\n"),"atomsRemove",1));
+            end
+
+            // Check if we have the write access
+            if or(section==["all","allusers"]) & ~ ATOMSALLUSERSWRITEACCESS then
+                error(msprintf(gettext("%s: You haven''t write access on this directory : %s.\n"),"atomsRemove",2,atomsPath("system","user")));
+            end
         end
     end
 
@@ -156,14 +203,17 @@ function result = atomsRemove(packages,section)
     // Build the list of package to Uninstall
     // =========================================================================
     remove_package_list = atomsRemoveList(packages,section);
-
     // Loop on remList to print if a package has to be remove
     // or not
     // =========================================================================
     if ATOMSVERBOSE
         for i=1:size(remove_package_list(:,1),"*")
             if remove_package_list(i,1) == "-" then
-                atomsDisp(msprintf("\t%s (%s) will be removed from the ''%s'' section",remove_package_list(i,3),remove_package_list(i,4),remove_package_list(i,5)));
+                if del==%T then
+                    atomsDisp(msprintf("\t%s (%s) will be removed from the ''%s'' section and its package fully deleted",remove_package_list(i,3),remove_package_list(i,4),remove_package_list(i,5)));
+                else
+                    atomsDisp(msprintf("\t%s (%s) will be removed from the ''%s'' section",remove_package_list(i,3),remove_package_list(i,4),remove_package_list(i,5)));
+                end
             elseif (remove_package_list(i,1) == "~") & (remove_package_list(i,1) == "B") then
                 atomsDisp(msprintf("\t%s (%s) cannot be removed from the ''%s'' section and will be broken",remove_package_list(i,3),remove_package_list(i,4),remove_package_list(i,5)));
             end
@@ -197,7 +247,7 @@ function result = atomsRemove(packages,section)
             continue;
         end
 
-        atomsDisp(msprintf( "\tRemoving %s (%s)(%s) ... " , this_package_name , this_package_version , this_package_section));
+        atomsDisp(msprintf(gettext("Removing %s (%s)(%s).\n\n"), this_package_name , this_package_version , this_package_section));
 
         // Check if this_package_directory start with SCI or SCIHOME
 
@@ -206,11 +256,11 @@ function result = atomsRemove(packages,section)
             (grep(this_package_directory,"/^(SCI|SCIHOME)\"+filesep()+"/","r") == []) then
 
             atomsError("error", ..
-                msprintf( ..
-                    gettext("%s: The directory of this package (%s-%s) is located neither in SCI nor in SCIHOME. For security reason, ATOMS refuses to delete this directory.\n"), ..
-                        "atomsRemove", ..
-                        this_package_name, ..
-                        this_package_version));
+            msprintf( ..
+            gettext("%s: The directory of this package (%s-%s) is located neither in SCI nor in SCIHOME. For security reason, ATOMS refuses to delete this directory.\n"), ..
+            "atomsRemove", ..
+            this_package_name, ..
+            this_package_version));
         end
 
         if isdir(this_package_directory) then
@@ -219,12 +269,12 @@ function result = atomsRemove(packages,section)
 
             if uninstall_status<>1 then
                 atomsError("error", ..
-                    msprintf( ..
-                        gettext("%s: The directory of this package (%s-%s) cannot been deleted, please check if you have write access on this directory : %s.\n"), ..
-                        "atomsRemove", ..
-                        this_package_name, ..
-                        this_package_version, ..
-                        strsubst(this_package_directory,"\","\\") ));
+                msprintf( ..
+                gettext("%s: The directory of this package (%s-%s) cannot been deleted, please check if you have write access on this directory : %s.\n"), ..
+                "atomsRemove", ..
+                this_package_name, ..
+                this_package_version, ..
+                strsubst(this_package_directory,"\","\\") ));
             end
 
         end
@@ -238,15 +288,21 @@ function result = atomsRemove(packages,section)
             stat = rmdir(this_package_root_dir);
             if stat<>1 then
                 atomsError("error", ..
-                    msprintf( ..
-                        gettext("%s: The root directory of this package (%s-%s) cannot been deleted, please check if you have write access on this directory : %s.\n"), ..
-                        "atomsRemove", ..
-                        this_package_name, ..
-                        this_package_version, ..
-                        strsubst(this_package_root_dir,"\","\\") ));
+                msprintf( ..
+                gettext("%s: The root directory of this package (%s-%s) cannot been deleted, please check if you have write access on this directory : %s.\n"), ..
+                "atomsRemove", ..
+                this_package_name, ..
+                this_package_version, ..
+                strsubst(this_package_root_dir,"\","\\") ));
             end
         end
 
+        // Remove the tarball file if asked
+        if del==%T then
+            atomsDisp(msprintf(gettext("Deleting archives files for %s.\n\n"),this_package_name));
+            atomsDeleteTarball(this_package_name,section,this_package_version);
+        end
+
         // Remove this toolbox from the list of installed packages
         // =====================================================================
         atomsInstallUnregister(this_package_name,this_package_version,this_package_section);
diff --git a/scilab/modules/atoms/macros/atoms_internals/atomsDeleteTarball.sci b/scilab/modules/atoms/macros/atoms_internals/atomsDeleteTarball.sci
new file mode 100644 (file)
index 0000000..ac13317
--- /dev/null
@@ -0,0 +1,117 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Simon GARESTE <simon.gareste@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
+
+// Deletes the tarball used to install a package
+
+function remList = atomsDeleteTarball(package,section,version)
+
+    remList = [];
+
+    // Check input parameters
+    // =========================================================================
+    rhs = argn(2);
+
+    // Input argument number
+    // =========================================================================
+
+    if rhs < 2 | rhs > 3 then
+        error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"atomsDeleteTarball",2,3))
+    end
+
+    // 1st input argument
+    // =========================================================================
+    if type(package) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",1));
+    end
+
+    if size(package(1,:),"*") > 1 then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",1));
+    end
+
+    // 2nd input argument
+    // =========================================================================
+
+    if type(section) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",2));
+    end
+
+    if size(section(1,:),"*") > 1 then
+        error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",2));
+    end
+
+    // 3rd input argument
+    // =========================================================================
+    if rhs==3 then
+        if and(section<>["user","allusers","all"]) then
+            error(msprintf(gettext("%s: Wrong value for input argument #%d: ''user'' or ''allusers'' or ''all'' expected.\n"),"atomsRemove",2));
+        end
+
+        if type(version) <> 10 then
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",3));
+        end
+
+        if size(version(1,:),"*") > 1 then
+            error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsDeleteTarball",3));
+        end
+    // If no 3rd argument is provided, 2nd argument is the version, section by default set to "all"
+    else
+        version = section;
+        section = "all";
+    end
+    // Remove leading and trailing whitespace
+    // =========================================================================
+    package = stripblanks(package);
+
+    //Getting the list of archives kept
+    if section=="user" then
+        path = [atomsPath("install","user")+'archives/'];
+        tarballs = ls(path);
+    elseif section=="allusers"
+        path = [atomsPath("install","allusers")+'archives/'];
+        tarballs = ls(path);
+    else
+        path = [atomsPath("install","user")+'archives/',atomsPath("install","allusers")+'archives/'];
+        tarballs=[ls(path(1));ls(path(2))];
+    end
+
+    selected_package = grep(tarballs,package);
+
+    [nr,nc]=size(selected_package);
+
+    //Deleting archives matching name and version of the module
+    for i=1:nc
+        ok = grep(tarballs(selected_package(i)),'_'+version+'.');
+        if ok==1 then
+            if section=="user" | section=="allusers" then
+                if isfile(path+tarballs(selected_package(i))) then
+                    deletefile(path+tarballs(selected_package(i)));
+                    atomsDisp(msprintf(gettext("%s%s deleted.\n\n"),path,tarballs(selected_package(i))));
+                else
+                    atomsDisp(msprintf(gettext("%s%s does not exist.\n\n"),path,tarballs(selected_package(i))));
+                end
+            else
+                if isfile(path(1)+tarballs(selected_package(i))) then
+                    deletefile(path(1)+tarballs(selected_package(i)));
+                    atomsDisp(msprintf(gettext("%s%s deleted.\n\n"),path(1),tarballs(selected_package(i))));
+                else
+                    atomsDisp(msprintf(gettext("%s%s does not exist.\n\n"),path(1),tarballs(selected_package(i))));
+                end
+                if isfile(path(2)+tarballs(selected_package(i))) then
+                    deletefile(path(2)+tarballs(selected_package(i)))
+                    atomsDisp(msprintf(gettext("%s%s deleted.\n\n"),path(2),tarballs(selected_package(i))));
+                else
+                    atomsDisp(msprintf(gettext("%s%s does not exist.\n\n"),path(2),tarballs(selected_package(i))));
+                end
+
+            end
+        end
+    end
+endfunction
index 2bfa05e..2190706 100644 (file)
@@ -28,13 +28,12 @@ function atomsDisp(str)
 
     // Verbose Mode ?
     // =========================================================================
-
     if isdef("ATOMSVERBOSE") then
         if ATOMSVERBOSE then
-            mprintf("%s\n",str);
+            mprintf("%s",strcat(str,ascii(10)));
         end
     elseif strcmpi(atomsGetConfig("Verbose"),"True") == 0
-        mprintf("%s\n",str);
+        mprintf("%s",strcat(str,ascii(10)));
     end
 
 endfunction
index 68c7f69..9a3d441 100644 (file)
@@ -100,7 +100,7 @@ function remList = atomsRemoveList(packages,section)
 
         if isempty(package_versions(i)) then
 
-            // No version is mention :
+            // No version is mentioned :
             // → uninstall all version of this toolbox (if we have the right, of
             // course)
             this_package_versions = atomsGetInstalledVers(package_names(i),section);
@@ -130,7 +130,6 @@ function remList = atomsRemoveList(packages,section)
                     end
 
                 end
-
             else
 
                 // The packaging version is mentioned :
@@ -149,15 +148,12 @@ function remList = atomsRemoveList(packages,section)
             end
 
         end
-
     end
 
     // Second Step : List the packages that depends of the uninstalled packages
     // =========================================================================
-
     packages = remList;
     for i=1:size(packages(:,1),"*")
-
         this_package_name    = packages(i,3);
         this_package_version = packages(i,4);
         this_package_section = packages(i,5);
@@ -208,8 +204,7 @@ function remList = atomsRemoveList(packages,section)
                     continue
                 end
             end
-
-            if find(remList(:,3)+" - "+remList(:,4) == this_child_name+" - "+this_child_version) == [] then
+            if find(remList(:,3)+" - "+remList(:,4)+" - "+remList(:,5) == this_child_name+" - "+this_child_version+" - "+this_package_section) == [] then
                 remList = [ remList ; "-" "C" this_child_name this_child_version this_package_section ]; // C stands for "Child"
             end
 
@@ -219,9 +214,7 @@ function remList = atomsRemoveList(packages,section)
 
     // Third Step : Loop on childs check if we can remove it or not
     // =========================================================================
-
     packages = remList(find(remList(:,2)=="C"),:);
-
     for i=1:size(remList(:,1),"*")
 
         // This is not a Child package :
@@ -268,7 +261,6 @@ function remList = atomsRemoveList(packages,section)
                 continue;
             end
         end
-
     end
 
 endfunction
diff --git a/scilab/modules/atoms/tests/unit_tests/atomsRemove.dia.ref b/scilab/modules/atoms/tests/unit_tests/atomsRemove.dia.ref
new file mode 100644 (file)
index 0000000..e7602d9
--- /dev/null
@@ -0,0 +1,234 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Simon GARESTE <simon.gareste@scilab.org>
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- JVM NOT MANDATORY -->
+load("SCI/modules/atoms/macros/atoms_internals/lib");
+// Do not use the autoload system
+config_autoload = atomsGetConfig("autoloadAddAfterInstall");
+config_Verbose  = atomsGetConfig("Verbose");
+atomsSetConfig("autoloadAddAfterInstall","False");
+atomsSetConfig("Verbose" ,"False");
+// Load the 1st scenario : See scene1.test.atoms.scilab.org.txt
+// =============================================================================
+atomsRepositorySetOfl("http://scene1.test.atoms.scilab.org");
+if atomsIsInstalled("toolbox_1") then
+    atomsRemove("toolbox_1");
+end
+if atomsIsInstalled("toolbox_2") then
+    atomsRemove("toolbox_2");
+end
+if atomsIsInstalled("toolbox_3") then
+    atomsRemove("toolbox_3");
+end
+if atomsIsInstalled("toolbox_4") then
+    atomsRemove("toolbox_4");
+end
+if atomsIsInstalled("toolbox_5") then
+    atomsRemove("toolbox_5");
+end
+if atomsIsInstalled("toolbox_6") then
+    atomsRemove("toolbox_6");
+end
+// REMOVING PART
+// REMOVING an Automatic installed toolbox deletes the toolbox it has been 
+// installed by
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_2" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+// REMOVING an Automatic toolbox deletes all the toolboxes depending on it
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_3" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+        "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_1"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+//assert_checkequal(atomsRemove(["toolbox_1"]      ,"user"),ref);
+// REMOVING an Intentionnaly installed toolbox won't delete an Automatically
+// installed toolbox if it is needed by another toolbox
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_3" "1.0"],"user");
+ref = [ "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+        "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_3" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+// REMOVING a toolbox in a section won't delete it in other sections
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_5" "1.0"],"allusers");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+ref_all = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
+            "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
+            "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
+            "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref_all=strsubst(ref_all,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+removed=atomsRemove(["toolbox_5" "1.0"],"allusers");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref_all);
+// REMOVING a toolbox with section "all" will remove this toolbox in sections 
+// "alluser" AND "user"
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_5" "1.0"],"allusers");
+ref = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
+        "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"all");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+// REMOVING a toolbox from a section where it doesn't exist won't remove it from
+// its existing section
+// REMOVING an Intentionnaly installed toolbox deletes all the Automatically
+// installed toolbox that were installed for this.
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref_empty = [];
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+assert_checkequal(atomsRemove(["toolbox_5" "1.0"],"allusers"),ref_empty);
+removed=atomsRemove(["toolbox_5" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+// ============================================================================
+// DELETING PART
+rmdir(SCIHOME+"/atoms/archives/",'s');
+mkdir(SCIHOME+"/atoms/archives");
+rmdir(SCI+"/contrib/archives/",'s');
+mkdir(SCI+"/contrib/archives");
+// ============================================================================
+// REMOVING AND DELETING a toolbox will delete its archives and archives of the
+// toolboxes it depends on
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+ref_empty = [];
+removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+if getos()=="Windows" then
+    assert_checkequal(ls(atomsPath("install","user")+'archives\'),ref_empty);
+else
+    assert_checkequal(ls(atomsPath("install","user")+'archives/'),ref_empty);
+end
+rmdir(SCIHOME+"/atoms/archives/",'s');
+mkdir(SCIHOME+"/atoms/archives");
+rmdir(SCI+"/contrib/archives/",'s');
+mkdir(SCI+"/contrib/archives");
+// REMOVING AND DELETING a toolbox will not delete other archives than the ones
+// it depends on
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_6" "1.0"],"user");
+ref = [ "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+[version, opts] = getversion();
+arch = opts(2);
+if getos()=="Windows" then
+    ref=strsubst(ref,"/","\");
+       if arch == "x86" then
+ref_ls = [ "toolbox_1_1.0-1.bin.windows.zip";
+           "toolbox_2_2.0-1.bin.windows.zip";
+           "toolbox_6_1.0-1.bin.windows.zip"];
+       else
+ref_ls = [ "toolbox_1_1.0-1.bin.x64.windows.zip";
+           "toolbox_2_2.0-1.bin.x64.windows.zip";
+           "toolbox_6_1.0-1.bin.x64.windows.zip"];
+       end
+elseif getos()=="Linux" then
+       if arch == "x86" then
+ref_ls = [ "toolbox_1_1.0-1.bin.i686.linux.tar.gz";
+           "toolbox_2_2.0-1.bin.i686.linux.tar.gz";
+           "toolbox_6_1.0-1.bin.i686.linux.tar.gz"];   
+       else
+ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.linux.tar.gz";
+           "toolbox_2_2.0-1.bin.x86_64.linux.tar.gz";
+           "toolbox_6_1.0-1.bin.x86_64.linux.tar.gz"]; 
+       end
+elseif getos()=="Darwin" then
+ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.darwin.tar.gz";
+           "toolbox_2_2.0-1.bin.x86_64.darwin.tar.gz";
+           "toolbox_6_1.0-1.bin.x86_64.darwin.tar.gz"];        
+end
+ref_rem_6 = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+              "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+              "toolbox_6"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_6/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref_rem_6=strsubst(ref_rem_6,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+left=ls(atomsPath("install","user")+'archives/');
+[a,b]=gsort(left(:,1),'r','i');
+assert_checkequal(left(b,:),ref_ls);
+// cleaning
+allremoved=atomsRemove(["toolbox_6" "1.0"],"user",%T);
+[a,b]=gsort(allremoved(:,1),'r','i');
+assert_checkequal(allremoved(b,:),ref_rem_6);
+rmdir(atomsPath("install","user")+'archives/','s');
+mkdir(atomsPath("install","user")+'archives/');
+rmdir(atomsPath("install","allusers")+'archives/','s');
+mkdir(atomsPath("install","allusers")+'archives/');
+// no module should be installed
+assert_checktrue(isempty(atomsGetInstalled()));
+// Restore original values
+// =============================================================================
+atomsSetConfig("autoloadAddAfterInstall",config_autoload);
+atomsSetConfig("Verbose" ,config_Verbose);
+atomsRepositorySetOfl(mgetl(SCI+"/modules/atoms/tests/unit_tests/repositories.orig"));
diff --git a/scilab/modules/atoms/tests/unit_tests/atomsRemove.tst b/scilab/modules/atoms/tests/unit_tests/atomsRemove.tst
new file mode 100644 (file)
index 0000000..5ac3338
--- /dev/null
@@ -0,0 +1,257 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Simon GARESTE <simon.gareste@scilab.org>
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- JVM NOT MANDATORY -->
+
+load("SCI/modules/atoms/macros/atoms_internals/lib");
+
+// Do not use the autoload system
+config_autoload = atomsGetConfig("autoloadAddAfterInstall");
+config_Verbose  = atomsGetConfig("Verbose");
+atomsSetConfig("autoloadAddAfterInstall","False");
+atomsSetConfig("Verbose" ,"False");
+
+// Load the 1st scenario : See scene1.test.atoms.scilab.org.txt
+// =============================================================================
+atomsRepositorySetOfl("http://scene1.test.atoms.scilab.org");
+if atomsIsInstalled("toolbox_1") then
+    atomsRemove("toolbox_1");
+end
+if atomsIsInstalled("toolbox_2") then
+    atomsRemove("toolbox_2");
+end
+if atomsIsInstalled("toolbox_3") then
+    atomsRemove("toolbox_3");
+end
+if atomsIsInstalled("toolbox_4") then
+    atomsRemove("toolbox_4");
+end
+if atomsIsInstalled("toolbox_5") then
+    atomsRemove("toolbox_5");
+end
+if atomsIsInstalled("toolbox_6") then
+    atomsRemove("toolbox_6");
+end
+// REMOVING PART
+
+// REMOVING an Automatic installed toolbox deletes the toolbox it has been 
+// installed by
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+        
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_2" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+
+// REMOVING an Automatic toolbox deletes all the toolboxes depending on it
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_3" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+        "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_1"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+//assert_checkequal(atomsRemove(["toolbox_1"]      ,"user"),ref);
+
+// REMOVING an Intentionnaly installed toolbox won't delete an Automatically
+// installed toolbox if it is needed by another toolbox
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_3" "1.0"],"user");
+ref = [ "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+        "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ];
+        
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_3" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+
+// REMOVING a toolbox in a section won't delete it in other sections
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_5" "1.0"],"allusers");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+ref_all = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
+            "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
+            "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
+            "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref_all=strsubst(ref_all,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+removed=atomsRemove(["toolbox_5" "1.0"],"allusers");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref_all);
+
+// REMOVING a toolbox with section "all" will remove this toolbox in sections 
+// "alluser" AND "user"
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_5" "1.0"],"allusers");
+ref = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
+        "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"all");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+
+// REMOVING a toolbox from a section where it doesn't exist won't remove it from
+// its existing section
+// REMOVING an Intentionnaly installed toolbox deletes all the Automatically
+// installed toolbox that were installed for this.
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref_empty = [];
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+assert_checkequal(atomsRemove(["toolbox_5" "1.0"],"allusers"),ref_empty);
+removed=atomsRemove(["toolbox_5" "1.0"],"user");
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+
+// ============================================================================
+// DELETING PART
+rmdir(SCIHOME+"/atoms/archives/",'s');
+mkdir(SCIHOME+"/atoms/archives");
+rmdir(SCI+"/contrib/archives/",'s');
+mkdir(SCI+"/contrib/archives");
+// ============================================================================
+
+// REMOVING AND DELETING a toolbox will delete its archives and archives of the
+// toolboxes it depends on
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+        "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref=strsubst(ref,"/","\");
+end
+ref_empty = [];
+removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+if getos()=="Windows" then
+    assert_checkequal(ls(atomsPath("install","user")+'archives\'),ref_empty);
+else
+    assert_checkequal(ls(atomsPath("install","user")+'archives/'),ref_empty);
+end
+rmdir(SCIHOME+"/atoms/archives/",'s');
+mkdir(SCIHOME+"/atoms/archives");
+rmdir(SCI+"/contrib/archives/",'s');
+mkdir(SCI+"/contrib/archives");
+
+// REMOVING AND DELETING a toolbox will not delete other archives than the ones
+// it depends on
+// -----------------------------------------------------------------------------
+atomsInstall(["toolbox_5" "1.0"],"user");
+atomsInstall(["toolbox_6" "1.0"],"user");
+ref = [ "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
+        "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
+        "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
+[version, opts] = getversion();
+arch = opts(2);
+if getos()=="Windows" then
+    ref=strsubst(ref,"/","\");
+       if arch == "x86" then
+ref_ls = [ "toolbox_1_1.0-1.bin.windows.zip";
+           "toolbox_2_2.0-1.bin.windows.zip";
+           "toolbox_6_1.0-1.bin.windows.zip"];
+       else
+ref_ls = [ "toolbox_1_1.0-1.bin.x64.windows.zip";
+           "toolbox_2_2.0-1.bin.x64.windows.zip";
+           "toolbox_6_1.0-1.bin.x64.windows.zip"];
+       end
+elseif getos()=="Linux" then
+       if arch == "x86" then
+ref_ls = [ "toolbox_1_1.0-1.bin.i686.linux.tar.gz";
+           "toolbox_2_2.0-1.bin.i686.linux.tar.gz";
+           "toolbox_6_1.0-1.bin.i686.linux.tar.gz"];   
+       else
+ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.linux.tar.gz";
+           "toolbox_2_2.0-1.bin.x86_64.linux.tar.gz";
+           "toolbox_6_1.0-1.bin.x86_64.linux.tar.gz"]; 
+       end
+elseif getos()=="Darwin" then
+ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.darwin.tar.gz";
+           "toolbox_2_2.0-1.bin.x86_64.darwin.tar.gz";
+           "toolbox_6_1.0-1.bin.x86_64.darwin.tar.gz"];        
+end
+ref_rem_6 = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
+              "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
+              "toolbox_6"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_6/1.0-1"  "I" ];
+if getos()=="Windows" then
+   ref_rem_6=strsubst(ref_rem_6,"/","\");
+end
+removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
+[a,b]=gsort(removed(:,1),'r','i');
+assert_checkequal(removed(b,:),ref);
+
+left=ls(atomsPath("install","user")+'archives/');
+[a,b]=gsort(left(:,1),'r','i');
+assert_checkequal(left(b,:),ref_ls);
+
+// cleaning
+allremoved=atomsRemove(["toolbox_6" "1.0"],"user",%T);
+[a,b]=gsort(allremoved(:,1),'r','i');
+assert_checkequal(allremoved(b,:),ref_rem_6);
+
+//assert_checkequal(atomsRemove(["toolbox_6" "1.0"],"user",%T),ref_rem_6);
+rmdir(atomsPath("install","user")+'archives/','s');
+mkdir(atomsPath("install","user")+'archives/');
+rmdir(atomsPath("install","allusers")+'archives/','s');
+mkdir(atomsPath("install","allusers")+'archives/');
+
+// no module should be installed
+assert_checktrue(isempty(atomsGetInstalled()));
+
+
+// Restore original values
+// =============================================================================
+atomsSetConfig("autoloadAddAfterInstall",config_autoload);
+atomsSetConfig("Verbose" ,config_Verbose);
+atomsRepositorySetOfl(mgetl(SCI+"/modules/atoms/tests/unit_tests/repositories.orig"));
+