[mojosetup] [3/13] Don't forget previously created directories on upgrade.

Francois Gouget fgouget at codeweavers.com
Mon May 21 13:55:54 EDT 2012


Otherwise they won't be deleted on uninstall which will result in an unclean uninstallation.
---

This uses the content of the old manifest and thus depends on the 
previous patch.

 scripts/mojosetup_mainline.lua |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/scripts/mojosetup_mainline.lua b/scripts/mojosetup_mainline.lua
index 79489ec..758e9e0 100644
--- a/scripts/mojosetup_mainline.lua
+++ b/scripts/mojosetup_mainline.lua
@@ -235,7 +235,10 @@ local function flatten_manifest(man, postprocess)
     end
     if man ~= nil then
         for fname,items in pairs(man) do
-            files[#files+1] = postprocess(fname)
+            fname = postprocess(fname)
+            if fname ~= nil then
+                files[#files+1] = fname
+            end
         end
     end
 
@@ -482,7 +485,10 @@ local function install_directory(dest, perms, manifestkey)
     -- Chop any '/' chars from the end of the string...
     dest = string.gsub(dest, "/+$", "")
 
-    if not MojoSetup.platform.mkdir(dest, perms) then
+    -- The directory may already exist in case of an upgrade.
+    -- !!! FIXME: We should set the permissions (e.g. 0555) after filling up
+    -- !!! FIXME:  the directory, including if it already exists (upgrade).
+    if not MojoSetup.platform.mkdir(dest, perms) and not MojoSetup.platform.isdir(dest) then
         MojoSetup.logerror("Failed to create dir '" .. dest .. "'")
         MojoSetup.fatal(_("Directory creation failed"))
     end
@@ -524,9 +530,8 @@ end
 local function permit_write(dest, entinfo, file)
     local allowoverwrite = true
     if MojoSetup.platform.exists(dest) then
-        -- never "permit" existing dirs, so they don't rollback.
         if entinfo.type == "dir" then
-            allowoverwrite = false
+            allowoverwrite = true
         else
             if MojoSetup.forceoverwrite ~= nil then
                 allowoverwrite = MojoSetup.forceoverwrite
@@ -1951,7 +1956,17 @@ local function real_revertinstall()
     end
 
     delete_files(MojoSetup.downloads)
-    delete_files(flatten_manifest(MojoSetup.manifest, prepend_dest_dir))
+
+    local function filter_manifest(fname)
+        if MojoSetup.manifest[fname].type == 'directory' and MojoSetup.oldfiles[fname] ~= nil then
+            -- Don't delete directories that were created by the version we
+            --  were upgrading.
+            return nil
+        end
+        return prepend_dest_dir(fname)
+    end
+    delete_files(flatten_manifest(MojoSetup.manifest, filter_manifest))
+
     do_rollbacks()
     delete_scratchdirs()
 end
-- 
1.7.10


More information about the mojosetup mailing list