aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-05 18:22:37 +0000
committerhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-05 18:22:37 +0000
commit5e3256ced6d08a72438db6a0374f8cf7b68db55a (patch)
tree70ea064f38582fd48fc1776c3424347b72c250e2
parent989701b2ed22b2479a7df8a5252951e53622dd31 (diff)
downloadluarocks-5e3256ced6d08a72438db6a0374f8cf7b68db55a.tar.gz
luarocks-5e3256ced6d08a72438db6a0374f8cf7b68db55a.tar.bz2
luarocks-5e3256ced6d08a72438db6a0374f8cf7b68db55a.zip
pack deployed files using rock_manifest
git-svn-id: http://luarocks.org/svn/luarocks/trunk@68 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
-rw-r--r--src/luarocks/pack.lua51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua
index e4dc1794..2fa12d9b 100644
--- a/src/luarocks/pack.lua
+++ b/src/luarocks/pack.lua
@@ -56,6 +56,25 @@ local function pack_source_rock(rockspec_file)
56 return rock_file 56 return rock_file
57end 57end
58 58
59local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir)
60 fs.make_dir(pack_dir)
61 for file, sub in pairs(file_tree) do
62 local source = dir.path(deploy_dir, file)
63 local target = dir.path(pack_dir, file)
64 if type(sub) == "table" then
65 local ok, err = copy_back_files(name, version, sub, source, target)
66 else
67 local versioned = path.versioned_name(source, name, version)
68 if fs.exists(versioned) then
69 fs.copy(versioned, target)
70 else
71 fs.copy(source, target)
72 end
73 end
74 end
75 return true
76end
77
59-- @param name string: Name of package to pack. 78-- @param name string: Name of package to pack.
60-- @param version string or nil: A version number may also be passed. 79-- @param version string or nil: A version number may also be passed.
61-- @return string or (nil, string): The filename of the resulting 80-- @return string or (nil, string): The filename of the resulting
@@ -83,33 +102,23 @@ local function pack_binary_rock(name, version)
83 return nil, "'"..name.." "..version.."' does not seem to be an installed rock." 102 return nil, "'"..name.." "..version.."' does not seem to be an installed rock."
84 end 103 end
85 104
105 local rock_manifest = manif.load_rock_manifest(name, version)
106 if not rock_manifest then
107 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?"
108 end
109
86 local name_version = name .. "-" .. version 110 local name_version = name .. "-" .. version
87 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") 111 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock")
88 112
89 local temp_dir = fs.make_temp_dir("pack") 113 local temp_dir = fs.make_temp_dir("pack")
90 fs.copy_contents(prefix, temp_dir) 114 fs.copy_contents(prefix, temp_dir)
91 115
92 local is_binary = false 116 if rock_manifest.lib then
93 local manifest = manif.load_manifest(cfg.rocks_dir) 117 copy_back_files(name, version, rock_manifest.lib, cfg.deploy_lib_dir, dir.path(temp_dir, "lib"))
94 for module_name, module_data in pairs(manifest.modules) do 118 is_binary = true
95 for package, file in pairs(module_data) do 119 end
96 if package == name.."/"..version then 120 if rock_manifest.lua then
97 local dest 121 copy_back_files(name, version, rock_manifest.lua, cfg.deploy_lua_dir, dir.path(temp_dir, "lua"))
98 print("TODO LR2 do this based on rock_manifest")
99 if file:match("^"..cfg.deploy_lua_dir) then
100 local pathname = file:sub(#cfg.deploy_lua_dir + 1)
101 dest = dir.path(temp_dir, "lua", dir.dir_name(pathname))
102 elseif file:match("^"..cfg.deploy_lib_dir) then
103 local pathname = file:sub(#cfg.deploy_lib_dir + 1)
104 dest = dir.path(temp_dir, "lib", dir.dir_name(pathname))
105 is_binary = true
106 end
107 if dest then
108 fs.make_dir(dest)
109 fs.copy(file, dest)
110 end
111 end
112 end
113 end 122 end
114 123
115 fs.change_dir(temp_dir) 124 fs.change_dir(temp_dir)