r500 - in trunk: . scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Feb 25 23:50:20 EST 2008


Author: icculus
Date: 2008-02-25 23:50:20 -0500 (Mon, 25 Feb 2008)
New Revision: 500

Modified:
   trunk/docs.txt
   trunk/scripts/mojosetup_init.lua
   trunk/scripts/mojosetup_mainline.lua
Log:
Added preuninstall and postuninstall hooks to the config file.


Modified: trunk/docs.txt
===================================================================
--- trunk/docs.txt	2008-02-20 21:48:18 UTC (rev 499)
+++ trunk/docs.txt	2008-02-26 04:50:20 UTC (rev 500)
@@ -285,6 +285,30 @@
     Setup.Package table as a parameter.
 
 
+   preuninstall (no default, mustBeFunction)
+
+    If this attribute is defined, it is called by the uninstaller after the
+    user confirms that uninstallation is acceptable and deletion of
+    files is about to begin. It passes something like the finalized
+    Setup.Package table as a parameter. This function is serialized for later
+    use, in a different program running in a different context: it may NOT use
+    any Lua upvalues (they will be local variables set to nil when the function
+    runs) and any globals you reference may or may not exist when the
+    function runs. Try to do the bare minimum here if you must use this hook.
+
+
+   postinstall (no default, mustBeFunction)
+
+    If this attribute is defined, it is called by the uninstaller after the
+    uninstallation has successfully finished. It passes something like the
+    finalized Setup.Package table as a parameter. This function is serialized
+    for later use, in a different program running in a different context: it
+    may NOT use any Lua upvalues (they will be local variables set to nil when
+    the function runs) and any globals you reference may or may not exist when
+    the function runs. Try to do the bare minimum here if you must use this
+    hook.
+
+
    updateurl (no default, mustBeUrl)
 
     This is written to the manifest files for the aid of external tools, but

Modified: trunk/scripts/mojosetup_init.lua
===================================================================
--- trunk/scripts/mojosetup_init.lua	2008-02-20 21:48:18 UTC (rev 499)
+++ trunk/scripts/mojosetup_init.lua	2008-02-26 04:50:20 UTC (rev 500)
@@ -266,6 +266,8 @@
         { "superuser", false, mustBeBool },
         { "write_manifest", true, mustBeBool },
         { "support_uninstall", true, mustBeBool },
+        { "preuninstall", nil, mustBeFunction },
+        { "postuninstall", nil, mustBeFunction }
     })
 
     if MojoSetup.installs == nil then
@@ -278,33 +280,6 @@
     return tab
 
 --[[
- preuninstall
-            This is a shell script which is executed at the very beginning
-            of the uninstall process. It will be run before any RPM uninstall
-            scripts. This file is not installed, but is added to the
-            beginning of uninstall script.
-
- postuninstall 
-            This is a shell script which is executed at the very end of the 
-            uninstall process. It will be run after any RPM uninstall
-            scripts. This file is not installed, but is added to the
-            end of the uninstall script.
-
-            IMPORTANT: An actual file name for a shell scripts needs to be specified,
-            not a command, for both pre/postuninstall entries.
-            "sh script.sh" is incorrect, but "script.sh" is correct.
-
-            Both the preuninstall and postuninstall scripts will have access
-            to the default environment variables. See the 'SCRIPT' section
-            for details. 
-
-            Also, these scripts will be run at the very beginning and very 
-            end of the install cleanup if the install is aborted.
-
- nouninstall This is an optional flag which, if specified, tells setup
-             not to generate an uninstall script after it runs. It also
-             doesn't generate any data for product queries and auto-updating.
-
  promptbinaries When set to "yes", setup will create a checkbox
                 to allow the user whether or not to create 
                 a symbolic link to the binaries.

Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua	2008-02-20 21:48:18 UTC (rev 499)
+++ trunk/scripts/mojosetup_mainline.lua	2008-02-26 04:50:20 UTC (rev 500)
@@ -726,9 +726,9 @@
 end
 
 
-local function run_config_defined_hook(func, install)
+local function run_config_defined_hook(func, pkg)
     if func ~= nil then
-        local errstr = func(install)
+        local errstr = func(pkg)
         if errstr ~= nil then
             MojoSetup.fatal(errstr)
         end
@@ -829,6 +829,8 @@
             retval = tostring(obj)
         elseif objtype == "string" then
             retval = string.format("%q", obj)
+        elseif objtype == "function" then
+            retval = "loadstring(" .. string.format("%q", string.dump(obj)) .. ")"
         elseif objtype == "table" then
             retval = "{\n"
             local tab = string.rep("\t", indent)
@@ -981,7 +983,9 @@
         version = MojoSetup.install.version,
         manifest = MojoSetup.manifest,
         splash = MojoSetup.install.splash,
-        desktopmenuitems = MojoSetup.install.desktopmenuitems
+        desktopmenuitems = MojoSetup.install.desktopmenuitems,
+        preuninstall = MojoSetup.install.preuninstall,
+        postuninstall = MojoSetup.install.postuninstall
     }
 
     -- now build these things...
@@ -1800,6 +1804,7 @@
 
     if uninstall_permitted then
         start_gui(package.description, package.splash)
+        run_config_defined_hook(package.preuninstall, package)
 
         uninstall_desktop_menu_items(package)
 
@@ -1823,6 +1828,7 @@
 
         local filelist = flatten_manifest(package.manifest, prepend_dest_dir)
         delete_files(filelist, callback, true)
+        run_config_defined_hook(package.postuninstall, package)
         MojoSetup.gui.final(_("Uninstall complete"))
         stop_gui()
     end




More information about the mojosetup-commits mailing list