r333 - trunk/scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Jul 2 05:14:54 EDT 2007
Author: icculus
Date: 2007-07-02 05:14:48 -0400 (Mon, 02 Jul 2007)
New Revision: 333
Modified:
trunk/scripts/config.lua
trunk/scripts/mojosetup_mainline.lua
Log:
Show global EULAs before READMEs, but allow per-option EULAs, too, which show
at the last possible moment before installation, and can apply to specific
pieces of the install.
Modified: trunk/scripts/config.lua
===================================================================
--- trunk/scripts/config.lua 2007-07-02 07:58:52 UTC (rev 332)
+++ trunk/scripts/config.lua 2007-07-02 09:14:48 UTC (rev 333)
@@ -47,20 +47,20 @@
-- Generally these return the table you pass to them, but they
-- may sanitize the values, add defaults, and verify the data.
- -- End User License Agreement(s). You can specify multiple files.
+ -- End User License Agreement(s). You can specify multiple
+ -- Setup.Eula sections here.
-- Also, Note the "translate" call.
+ -- This shows up as the first thing the user sees, and must
+ -- agree to before anything goes forward. You could put this
+ -- in the base Setup.Option and they won't be shown it until
+ -- installation is about to start, if you would rather
+ -- defer this until necessary and/or show the README first.
Setup.Eula
{
description = "My Game License",
source = MojoSetup.translate("MyGame_EULA.html")
},
- Setup.Eula
- {
- description = "Punkbuster License",
- source = MojoSetup.translate("PunkBuster_EULA.html"),
- },
-
-- README file(s) to show and install.
Setup.Readme
{
@@ -128,6 +128,27 @@
end
},
+ -- Here's an option that has it's own EULA.
+ Setup.Option
+ {
+ value = true,
+ required = false,
+ disabled = false,
+ bytes = megabytes(1),
+ description = "PunkBuster support",
+
+ Setup.Eula
+ {
+ description = "Punkbuster License",
+ source = MojoSetup.translate("PunkBuster_EULA.html"),
+ },
+
+ Setup.File
+ {
+ source = "media://cd1/pb.zip",
+ },
+ },
+
-- Radio buttons.
Setup.OptionGroup
{
Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua 2007-07-02 07:58:52 UTC (rev 332)
+++ trunk/scripts/mojosetup_mainline.lua 2007-07-02 09:14:48 UTC (rev 333)
@@ -631,22 +631,9 @@
end
end
- -- Next stage: show any READMEs.
- if install.readmes ~= nil then
- for k,readme in pairs(install.readmes) do
- local desc = readme.description
- -- !!! FIXME: pull from archive?
- local fname = "data/" .. readme.source
- -- (desc) and (fname) become upvalues in this function.
- stages[#stages+1] = function(thisstage, maxstage)
- return MojoSetup.gui.readme(desc, fname, thisstage, maxstage)
- end
- end
- end
-
- -- Next stage: accept all EULAs. Never lets user step back, so they
- -- either accept or reject and go to the next EULA or stage. Rejection
- -- of any EULA is considered fatal.
+ -- Next stage: accept all global EULAs. Rejection of any EULA is considered
+ -- fatal. These are global EULAs for the install, per-option EULAs come
+ -- later.
if install.eulas ~= nil then
for k,eula in pairs(install.eulas) do
local desc = eula.description
@@ -665,6 +652,19 @@
end
end
+ -- Next stage: show any READMEs.
+ if install.readmes ~= nil then
+ for k,readme in pairs(install.readmes) do
+ local desc = readme.description
+ -- !!! FIXME: pull from archive?
+ local fname = "data/" .. readme.source
+ -- (desc) and (fname) become upvalues in this function.
+ stages[#stages+1] = function(thisstage, maxstage)
+ return MojoSetup.gui.readme(desc, fname, thisstage, maxstage)
+ end
+ end
+ end
+
-- Next stage: let user choose install destination.
-- The config file can force a destination if it has a really good reason
-- (system drivers that have to go in a specific place, for example),
@@ -705,15 +705,72 @@
end
-- Next stage: let user choose install options.
- if install.options ~= nil or install.optiongroups ~= nil then
- -- (install) becomes an upvalue in this function.
- stages[#stages+1] = function(thisstage, maxstage)
- -- This does some complex stuff with a hierarchy of tables in C.
- return MojoSetup.gui.options(install, thisstage, maxstage)
+ -- This may not produce a GUI stage if it decides that all options
+ -- are either required or disabled.
+ -- (install) becomes an upvalue in this function.
+ stages[#stages+1] = function(thisstage, maxstage)
+ -- This does some complex stuff with a hierarchy of tables in C.
+ return MojoSetup.gui.options(install, thisstage, maxstage)
+ end
+
+
+ -- Next stage: accept all option-specific EULAs.
+ -- Rejection of any EULA will put you back one stage (usually to the
+ -- install options), but if there is no previous stage, this becomes
+ -- fatal.
+ -- This may not produce a GUI stage if there are no selected options with
+ -- EULAs to accept.
+ stages[#stages+1] = function(thisstage, maxstage)
+ local option_eulas = {}
+
+ local function find_option_eulas(opts)
+ local options = opts['options']
+ if options ~= nil then
+ for k,v in pairs(options) do
+ if v.value and v.eulas then
+ for ek,ev in pairs(v.eulas) do
+ option_eulas[#option_eulas+1] = ev
+ end
+ find_option_eulas(v)
+ end
+ end
+ end
+
+ local optiongroups = opts['optiongroups']
+ if optiongroups ~= nil then
+ for k,v in pairs(optiongroups) do
+ if not v.disabled then
+ find_option_eulas(v)
+ end
+ end
+ end
end
+
+ find_option_eulas(install)
+
+ for k,eula in pairs(option_eulas) do
+ local desc = eula.description
+ local fname = "data/" .. eula.source
+ local retval = MojoSetup.gui.readme(desc,fname,thisstage,maxstage)
+ if retval == 1 then
+ if not MojoSetup.promptyn(desc, _("Accept this license?"), false) then
+ -- can't go back? We have to die here instead.
+ if thisstage == 1 then
+ MojoSetup.fatal(_("You must accept the license before you may install"))
+ else
+ retval = -1 -- just step back a stage.
+ end
+ end
+ end
+
+ if retval ~= 1 then
+ return retval
+ end
+ end
+
+ return 1 -- all licenses were agreed to. Go to the next stage.
end
-
-- Next stage: Make sure source list is sane.
-- This is not a GUI stage, it just needs to run between them.
-- This gets a little hairy.
More information about the mojosetup-commits
mailing list