aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/deps.lua19
-rw-r--r--src/luarocks/fetch.lua4
2 files changed, 14 insertions, 9 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 6d5f3fef..93b187cf 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -170,9 +170,14 @@ local function parse_constraint(input)
170 assert(type(input) == "string") 170 assert(type(input) == "string")
171 171
172 local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") 172 local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)")
173 op = operators[op] 173 local _op = operators[op]
174 version = parse_version(version) 174 version = parse_version(version)
175 if not op or not version then return nil end 175 if not _op then
176 return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'"
177 end
178 if not version then
179 return nil, "Could not parse version from constraint: '"..input.."'"
180 end
176 return { op = op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest 181 return { op = op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest
177end 182end
178 183
@@ -187,13 +192,13 @@ end
187function parse_constraints(input) 192function parse_constraints(input)
188 assert(type(input) == "string") 193 assert(type(input) == "string")
189 194
190 local constraints, constraint = {}, nil 195 local constraints, constraint, oinput = {}, nil, input
191 while #input > 0 do 196 while #input > 0 do
192 constraint, input = parse_constraint(input) 197 constraint, input = parse_constraint(input)
193 if constraint then 198 if constraint then
194 table.insert(constraints, constraint) 199 table.insert(constraints, constraint)
195 else 200 else
196 return nil 201 return nil, "Failed to parse constraint '"..tostring(o_input).."' with error: ".. input
197 end 202 end
198 end 203 end
199 return constraints 204 return constraints
@@ -213,9 +218,9 @@ function parse_dep(dep)
213 assert(type(dep) == "string") 218 assert(type(dep) == "string")
214 219
215 local name, rest = dep:match("^%s*([a-zA-Z][a-zA-Z0-9%.%-%_]*)%s*(.*)") 220 local name, rest = dep:match("^%s*([a-zA-Z][a-zA-Z0-9%.%-%_]*)%s*(.*)")
216 if not name then return nil end 221 if not name then return nil, "failed to extract dependency name from '"..tostring(dep).."'" end
217 local constraints = parse_constraints(rest) 222 local constraints, err = parse_constraints(rest)
218 if not constraints then return nil end 223 if not constraints then return nil, err end
219 return { name = name, constraints = constraints } 224 return { name = name, constraints = constraints }
220end 225end
221 226
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index 3bb0cdc0..bfdbacec 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -189,9 +189,9 @@ function load_local_rockspec(filename)
189 or base 189 or base
190 if rockspec.dependencies then 190 if rockspec.dependencies then
191 for i = 1, #rockspec.dependencies do 191 for i = 1, #rockspec.dependencies do
192 local parsed = deps.parse_dep(rockspec.dependencies[i]) 192 local parsed, err = deps.parse_dep(rockspec.dependencies[i])
193 if not parsed then 193 if not parsed then
194 return nil, "Parse error processing dependency '"..rockspec.dependencies[i].."'" 194 return nil, "Parse error processing dependency '"..rockspec.dependencies[i].."': "..tostring(err)
195 end 195 end
196 rockspec.dependencies[i] = parsed 196 rockspec.dependencies[i] = parsed
197 end 197 end