aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-04 16:06:35 +0000
committerhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-04 16:06:35 +0000
commitca15323a477a81e5f20c4b3195e318b36cbc71b4 (patch)
tree16fc2b052f68514bb5ecd1a94fa07b1e37a87ab5
parente1ac67028db826a17126df0d44c1060522a9ec9c (diff)
downloadluarocks-ca15323a477a81e5f20c4b3195e318b36cbc71b4.tar.gz
luarocks-ca15323a477a81e5f20c4b3195e318b36cbc71b4.tar.bz2
luarocks-ca15323a477a81e5f20c4b3195e318b36cbc71b4.zip
delegate the hard work to luarocks.rep
git-svn-id: http://luarocks.org/svn/luarocks/trunk@57 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
-rw-r--r--src/luarocks/remove.lua48
1 files changed, 5 insertions, 43 deletions
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua
index ba70f53e..acbe94a4 100644
--- a/src/luarocks/remove.lua
+++ b/src/luarocks/remove.lua
@@ -59,40 +59,6 @@ end
59-- @return boolean or (nil, string): true on success or nil and an error message. 59-- @return boolean or (nil, string): true on success or nil and an error message.
60local function delete_versions(name, versions) 60local function delete_versions(name, versions)
61 61
62 local manifest, err = manif.load_manifest(cfg.rocks_dir)
63 if not manifest then
64 return nil, err
65 end
66
67 local commands = {}
68 for version, data in pairs(versions) do
69 for _, command in pairs(manifest.repository[name][version][1].commands) do
70 if not commands[command] then commands[command] = {} end
71 table.insert(commands[command], name.."/"..version)
72 end
73 end
74
75 if next(commands) then
76 for command, users in pairs(commands) do
77 local providers_of_command = manifest.commands[command]
78 for _, user in ipairs(users) do
79 for i, value in ipairs(providers_of_command) do
80 if providers_of_command[i] == user then
81 table.remove(providers_of_command, i)
82 break
83 end
84 end
85 end
86 local remaining = next(providers_of_command)
87 if remaining then
88 local name, version = remaining:match("^([^/]*)/(.*)$")
89 rep.install_bins(name, version, command)
90 else
91 rep.delete_bin(command)
92 end
93 end
94 end
95
96 for version, _ in pairs(versions) do 62 for version, _ in pairs(versions) do
97 print("Removing "..name.." "..version.."...") 63 print("Removing "..name.." "..version.."...")
98 rep.delete_version(name, version) 64 rep.delete_version(name, version)
@@ -116,9 +82,7 @@ function run(...)
116 end 82 end
117 local results = {} 83 local results = {}
118 search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version)) 84 search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version))
119 85
120 print("remove functionality is currently broken")
121 --[[
122 local versions = results[name] 86 local versions = results[name]
123 if not versions then 87 if not versions then
124 return nil, "Could not find rock '"..name..(version and " "..version or "").."' in local tree." 88 return nil, "Could not find rock '"..name..(version and " "..version or "").."' in local tree."
@@ -141,11 +105,10 @@ function run(...)
141 print() 105 print()
142 end 106 end
143 local ok, err1 = delete_versions(name, versions) 107 local ok, err1 = delete_versions(name, versions)
144 -- FIXME 108 local ok, err2 = manif.make_manifest(cfg.rocks_dir)
145 -- local ok, err2 = manif.make_manifest(cfg.rocks_dir) 109 if err1 or err2 then
146 -- if err1 or err2 then 110 return nil, err1 or err2
147 -- return nil, err1 or err2 111 end
148 -- end
149 else 112 else
150 if not second then 113 if not second then
151 print("Will not remove "..name.." "..version..".") 114 print("Will not remove "..name.." "..version..".")
@@ -162,6 +125,5 @@ function run(...)
162 return nil, "Failed removing." 125 return nil, "Failed removing."
163 end 126 end
164 end 127 end
165 ]]
166 return true 128 return true
167end 129end