r314 - in trunk: . scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun May 27 14:13:15 EDT 2007
Author: icculus
Date: 2007-05-27 14:13:15 -0400 (Sun, 27 May 2007)
New Revision: 314
Modified:
trunk/docs.txt
trunk/scripts/mojosetup_mainline.lua
Log:
More manifest work.
Modified: trunk/docs.txt
===================================================================
--- trunk/docs.txt 2007-05-27 16:41:12 UTC (rev 313)
+++ trunk/docs.txt 2007-05-27 18:13:15 UTC (rev 314)
@@ -957,7 +957,7 @@
MojoSetup.manifest
- This is an array of tables (not a function!) that is built during the
+ This is a table of tables (not a function!) that is built during the
course of the installation. As changes are made to the destination
filesystem, they are noted in MojoSetup.manifest, so this will be
complete and most useful during a postinstall hook in your config file.
@@ -966,11 +966,21 @@
so you should treat it as read-only. Modifying this table from your config
script will result in undefined (but probably bad) behaviour.
- The format of the tables in the array vary depending on type. They all
- have a "type" field, which is a string. Based on the type, different
- fields are available:
+ There is one element in the array for each Setup.Option that generated
+ a change to the filesystem. Each of these elements is an array of tables.
- if (item.type = "file") then
+ for option,items in pairs(MojoSetup.manifest) do
+ print("Option: " .. option.description)
+ for i,item in ipairs(items) do
+ -- ... do stuff with "item" here ...
+ end
+ end
+
+ The format of the item tables vary depending on type. They all have a
+ "type" field, which is a string. Based on the type, different fields are
+ available:
+
+ if item.type == "file" then
print("file created at " .. item.path)
print("with permissions" ... item.mode) -- This is a string!
@@ -982,12 +992,12 @@
end
end
- if (item.type = "dir") then
+ if item.type == "dir" then
print("directory created at " .. item.path)
print("with permissions" ... item.mode) -- This is a string!
end
- if (item.type = "symlink") then
+ if item.type == "symlink" then
print("symbolic link created at " .. item.path)
print("pointing to " .. item.linkdest)
end
Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua 2007-05-27 16:41:12 UTC (rev 313)
+++ trunk/scripts/mojosetup_mainline.lua 2007-05-27 18:13:15 UTC (rev 314)
@@ -233,7 +233,7 @@
end
-local function install_file(dest, archive, file, option, perms)
+local function install_file(dest, archive, file, perms, option)
-- Upvalued so we don't look these up each time...
local fname = string.gsub(dest, "^.*/", "", 1) -- chop the dirs off...
local ptype = _("Installing") -- !!! FIXME: localization.
@@ -264,19 +264,25 @@
end
end
- MojoSetup.manifest[#MojoSetup.manifest+1] =
- {
- type = "file",
- path = dest,
- checksums = sums,
- mode = perms,
- }
+ if option ~= nil then
+ if MojoSetup.manifest[option] == nil then
+ MojoSetup.manifest[option] = {}
+ end
+ local manifest = MojoSetup.manifest[option]
+ manifest[#manifest+1] =
+ {
+ type = "file",
+ path = dest,
+ checksums = sums,
+ mode = perms,
+ }
+ end
MojoSetup.loginfo("Created file '" .. dest .. "'")
end
-local function install_symlink(dest, lndest)
+local function install_symlink(dest, lndest, option)
MojoSetup.installed_files[#MojoSetup.installed_files+1] = dest
if not MojoSetup.platform.symlink(dest, lndest) then
-- !!! FIXME: formatting!
@@ -284,18 +290,24 @@
MojoSetup.fatal(_("symlink creation failed!"))
end
- MojoSetup.manifest[#MojoSetup.manifest+1] =
- {
- type = "symlink",
- path = dest,
- linkdest = lndest,
- }
+ if option ~= nil then
+ if MojoSetup.manifest[option] == nil then
+ MojoSetup.manifest[option] = {}
+ end
+ local manifest = MojoSetup.manifest[option]
+ manifest[#manifest+1] =
+ {
+ type = "symlink",
+ path = dest,
+ linkdest = lndest,
+ }
+ end
MojoSetup.loginfo("Created symlink '" .. dest .. "' -> '" .. lndest .. "'")
end
-local function install_directory(dest, perms)
+local function install_directory(dest, perms, option)
MojoSetup.installed_files[#MojoSetup.installed_files+1] = dest
if not MojoSetup.platform.mkdir(dest, perms) then
-- !!! FIXME: formatting
@@ -303,18 +315,24 @@
MojoSetup.fatal(_("mkdir failed"))
end
- MojoSetup.manifest[#MojoSetup.manifest+1] =
- {
- type = "dir",
- path = dest,
- mode = perms,
- }
+ if option ~= nil then
+ if MojoSetup.manifest[option] == nil then
+ MojoSetup.manifest[option] = {}
+ end
+ local manifest = MojoSetup.manifest[option]
+ manifest[#manifest+1] =
+ {
+ type = "dir",
+ path = dest,
+ mode = perms,
+ }
+ end
MojoSetup.loginfo("Created directory '" .. dest .. "'")
end
-local function install_parent_dirs(path)
+local function install_parent_dirs(path, option)
-- Chop any '/' chars from the end of the string...
path = string.gsub(path, "/+$", "")
@@ -324,7 +342,7 @@
if item ~= "" then
fullpath = fullpath .. "/" .. item
if not MojoSetup.platform.exists(fullpath) then
- install_directory(fullpath, nil)
+ install_directory(fullpath, nil, option)
end
end
end
@@ -367,7 +385,7 @@
local id = #MojoSetup.rollbacks + 1
local f = MojoSetup.rollbackdir .. "/" .. id
-- !!! FIXME: don't add (f) to the installed_files table...
- install_parent_dirs(f)
+ install_parent_dirs(f, nil)
MojoSetup.rollbacks[id] = dest
if not MojoSetup.movefile(dest, f) then
-- !!! FIXME: formatting
@@ -407,13 +425,13 @@
if dest ~= nil then -- Only install if file wasn't filtered out
dest = MojoSetup.destination .. "/" .. dest
if permit_write(dest, ent, file) then
- install_parent_dirs(dest)
+ install_parent_dirs(dest, option)
if ent.type == "file" then
- install_file(dest, archive, file, option, perms)
+ install_file(dest, archive, file, perms, option)
elseif ent.type == "dir" then
- install_directory(dest, perms)
+ install_directory(dest, perms, option)
elseif ent.type == "symlink" then
- install_symlink(dest, ent.linkdest)
+ install_symlink(dest, ent.linkdest, option)
else -- !!! FIXME: device nodes, etc...
-- !!! FIXME: formatting!
-- !!! FIXME: should this be fatal?
@@ -571,6 +589,7 @@
MojoSetup.totalwrite = 0
MojoSetup.downloaded = 0
MojoSetup.totaldownload = 0
+ MojoSetup.install = install
-- !!! FIXME: try to sanity check everything we can here
-- !!! FIXME: (unsupported URLs, bogus media IDs, etc.)
@@ -787,7 +806,7 @@
for file,option in pairs(MojoSetup.files.downloads) do
local f = MojoSetup.downloaddir .. "/" .. id
-- !!! FIXME: don't add (f) to the installed_files table...
- install_parent_dirs(f)
+ install_parent_dirs(f, nil)
id = id + 1
-- Upvalued so we don't look these up each time...
@@ -971,6 +990,7 @@
MojoSetup.scratchdir = nil
MojoSetup.rollbackdir = nil
MojoSetup.downloaddir = nil
+ MojoSetup.install = nil
MojoSetup.forceoverwrite = nil
MojoSetup.stages = nil
MojoSetup.files = nil
More information about the mojosetup-commits
mailing list