Skip to content

Commit

Permalink
Add a dataprefix option which allows you to perform installations from
Browse files Browse the repository at this point in the history
the top level directory, making mojo more compatible with Loki Setup 1.x.
  • Loading branch information
jwhite66 committed Jun 7, 2010
1 parent f532468 commit 934fdb9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
7 changes: 7 additions & 0 deletions docs.txt
Expand Up @@ -243,6 +243,13 @@ Here are the elements, and the attributes they can possess.
the installer will prompt the user, possibly recommmending locations
to him.

dataprefix (default: "data/", mustBeString)

This attribute can be used to force the installer to pull data files
from a location other than data/. The use of the default data/
is strongly recommended; use this option only with great care.



recommended_destinations (no default, mustBeStringOrTableOfStrings)

Expand Down
1 change: 1 addition & 0 deletions scripts/mojosetup_init.lua
Expand Up @@ -299,6 +299,7 @@ function Setup.Package(tab)
{ "description", nil, mustExist, mustBeString, cantBeEmpty },
{ "version", nil, mustExist, mustBeString, cantBeEmpty },
{ "destination", nil, mustBeString, cantBeEmpty },
{ "dataprefix", "data/", mustBeString},
{ "recommended_destinations", nil, mustBeStringOrTableOfStrings },
{ "precheck", nil, mustBeFunction },
{ "preflight", nil, mustBeFunction },
Expand Down
30 changes: 15 additions & 15 deletions scripts/mojosetup_mainline.lua
Expand Up @@ -602,7 +602,7 @@ local function install_archive_entry(archive, ent, file, option)
end


local function install_archive(archive, file, option)
local function install_archive(archive, file, option, dataprefix)
if not MojoSetup.archive.enumerate(archive) then
MojoSetup.fatal(_("Couldn't enumerate archive"))
end
Expand Down Expand Up @@ -635,9 +635,9 @@ local function install_archive(archive, file, option)
while ent ~= nil do
-- If inside GBaseArchive (no URL lead in string), then we
-- want to clip to data/ directory...
if isbase then
if isbase and (string.len(dataprefix) > 0) then
local count
ent.filename, count = string.gsub(ent.filename, "^data/", "", 1)
ent.filename, count = string.gsub(ent.filename, "^" .. dataprefix, "", 1)
if count == 0 then
ent.filename = nil
end
Expand Down Expand Up @@ -671,7 +671,7 @@ local function install_archive(archive, file, option)
end


local function install_basepath(basepath, file, option)
local function install_basepath(basepath, file, option, dataprefix)
-- Obviously, we don't want to enumerate the entire physical filesystem,
-- so we'll dig through each path element with MojoPlatform_exists()
-- until we find one that doesn't, then we'll back up and try to open
Expand All @@ -693,7 +693,7 @@ local function install_basepath(basepath, file, option)
-- case, but it won't work for archives-in-archives.
if MojoSetup.platform.exists(basepath) then
local archive = create_basepath_archive(basepath)
install_archive(archive, file, option)
install_archive(archive, file, option, dataprefix)
MojoSetup.archive.close(archive)
else
-- Check for archives-in-archives...
Expand All @@ -710,14 +710,14 @@ local function install_basepath(basepath, file, option)
local arclist = { archive }
path = rebuild_path(paths, i)
local arc = drill_for_archive(archive, path, arclist)
install_archive(arc, file, option)
install_archive(arc, file, option, dataprefix)
close_archive_list(arclist)
return -- we're done here
end
end

-- wait, the whole thing exists now? Did this just move in?
install_basepath(basepath, file, option) -- try again, I guess...
install_basepath(basepath, file, option, dataprefix) -- try again, I guess...
end
end

Expand Down Expand Up @@ -1324,7 +1324,7 @@ local function do_install(install)
if (install.eulas ~= nil) and (not skipeulas) then
for k,eula in pairs(install.eulas) do
local desc = eula.description
local fname = "data/" .. eula.source
local fname = install.dataprefix .. eula.source
local accept_needed = not eula.accept_not_needed

-- (desc) and (fname) become upvalues in this function.
Expand Down Expand Up @@ -1362,7 +1362,7 @@ local function do_install(install)
for k,readme in pairs(install.readmes) do
local desc = readme.description
-- !!! FIXME: pull from archive?
local fname = "data/" .. readme.source
local fname = install.dataprefix .. readme.source
-- (desc) and (fname) become upvalues in this function.
stages[#stages+1] = function(thisstage, maxstage)
return MojoSetup.gui.readme(desc, fname, thisstage, maxstage)
Expand Down Expand Up @@ -1463,7 +1463,7 @@ local function do_install(install)

for k,eula in pairs(option_eulas) do
local desc = eula.description
local fname = "data/" .. eula.source
local fname = install.dataprefix .. eula.source
local accept_needed = not eula.accept_not_needed
local retval = MojoSetup.gui.readme(desc,fname,thisstage,maxstage)
if retval == 1 then
Expand Down Expand Up @@ -1726,7 +1726,7 @@ local function do_install(install)
local files = MojoSetup.files.media[mediaid]
for file,option in pairs(files) do
local prot,host,path = MojoSetup.spliturl(file.source)
install_basepath(basepath .. "/" .. path, file, option)
install_basepath(basepath .. "/" .. path, file, option, install.dataprefix)
end
end
medialist = nil -- done with this.
Expand All @@ -1737,20 +1737,20 @@ local function do_install(install)
for file,option in pairs(MojoSetup.files.downloads) do
local f = MojoSetup.downloaddir .. "/" .. id
id = id + 1
install_basepath(f, file, option)
install_basepath(f, file, option, install.dataprefix)
end
end

if MojoSetup.files.included ~= nil then
for file,option in pairs(MojoSetup.files.included) do
local arc = MojoSetup.archive.base
if file.source == nil then
install_archive(arc, file, option)
install_archive(arc, file, option, install.dataprefix)
else
local prot,host,path = MojoSetup.spliturl(file.source)
local arclist = {}
arc = drill_for_archive(arc, "data/" .. path, arclist)
install_archive(arc, file, option)
arc = drill_for_archive(arc, install.dataprefix .. path, arclist)
install_archive(arc, file, option, install.dataprefix)
close_archive_list(arclist)
end
end
Expand Down

0 comments on commit 934fdb9

Please sign in to comment.