summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-29 16:54:30 +0000
committerSteven Barth <steven@midlink.org>2008-07-29 16:54:30 +0000
commit8dad54251aeb9ede55bbc775c1cf7a9d84402762 (patch)
treed4734ae53cdfb297a3e52d507083a41daa5224b0
parent41eceab4c413d331c14d3b3ba0e8bb355427f1f3 (diff)
libs/lpk: Several fixes in CLI -> Machine bindings
-rw-r--r--libs/lpk/luasrc/lpk.lua2
-rw-r--r--libs/lpk/luasrc/lpk/core.lua11
-rw-r--r--libs/lpk/luasrc/lpk/core/download.lua1
-rw-r--r--libs/lpk/luasrc/lpk/core/install.lua16
-rw-r--r--libs/lpk/luasrc/lpk/core/retreive.lua7
5 files changed, 33 insertions, 4 deletions
diff --git a/libs/lpk/luasrc/lpk.lua b/libs/lpk/luasrc/lpk.lua
index 3b42a367e..7117c75f9 100644
--- a/libs/lpk/luasrc/lpk.lua
+++ b/libs/lpk/luasrc/lpk.lua
@@ -31,7 +31,7 @@ else
os.exit(task.register.error or 1)
end
else
- luci.util.perror(error .. "\n")
+ luci.util.perror((error or "Unknown Error") .. "\n")
luci.lpk.util.splash()
os.exit(1)
end
diff --git a/libs/lpk/luasrc/lpk/core.lua b/libs/lpk/luasrc/lpk/core.lua
index bef5651c6..97de4fa92 100644
--- a/libs/lpk/luasrc/lpk/core.lua
+++ b/libs/lpk/luasrc/lpk/core.lua
@@ -22,6 +22,10 @@ function Task.rollback(self)
end
local state = table.remove(self.done)
+ if not state.rollback then
+ return true
+ end
+
local ret, err = pcall(state.rollback, state, self.register)
if ret then
@@ -33,7 +37,7 @@ end
function Task.step(self)
local state = table.remove(self.work)
- local ret, next = pcall(state.process, state, self.register)
+ local ret, next = pcall(state.process, self.register)
if ret then
if next then
@@ -42,7 +46,8 @@ function Task.step(self)
table.insert(self.work, state)
table.insert(self.work, nstate)
else
- self.register.error = "Unknown state: " .. next
+ self.register.error = 2
+ self.register.errstr = "Unknown state: " .. next
return false
end
else
@@ -98,5 +103,5 @@ function Machine.task(self, name, ...)
local register = {}
- return start:entry(register) and Task(self, register, start)
+ return start.entry(register, ...) and Task(self, register, start)
end
diff --git a/libs/lpk/luasrc/lpk/core/download.lua b/libs/lpk/luasrc/lpk/core/download.lua
index e69de29bb..7b306479f 100644
--- a/libs/lpk/luasrc/lpk/core/download.lua
+++ b/libs/lpk/luasrc/lpk/core/download.lua
@@ -0,0 +1 @@
+module("luci.lpk.core.download", package.seeall)
diff --git a/libs/lpk/luasrc/lpk/core/install.lua b/libs/lpk/luasrc/lpk/core/install.lua
index e69de29bb..abf612b29 100644
--- a/libs/lpk/luasrc/lpk/core/install.lua
+++ b/libs/lpk/luasrc/lpk/core/install.lua
@@ -0,0 +1,16 @@
+module("luci.lpk.core.install", package.seeall)
+
+function entry(register, ...)
+ print("Requested install of " .. table.concat(arg, ", "))
+ return true
+end
+
+function process(register)
+ register.sometext = "Test"
+ if not register.retreived then
+ print("Step down to retreive")
+ return "retreive"
+ else
+ print("Coming up again")
+ end
+end \ No newline at end of file
diff --git a/libs/lpk/luasrc/lpk/core/retreive.lua b/libs/lpk/luasrc/lpk/core/retreive.lua
index e69de29bb..5ad63aa93 100644
--- a/libs/lpk/luasrc/lpk/core/retreive.lua
+++ b/libs/lpk/luasrc/lpk/core/retreive.lua
@@ -0,0 +1,7 @@
+module("luci.lpk.core.retreive", package.seeall)
+
+function process(register)
+ print "Now in retreive"
+ print (register.sometext)
+ register.retreived = true
+end \ No newline at end of file