65 lines
No EOL
2 KiB
Text
65 lines
No EOL
2 KiB
Text
local tArgs = {...}
|
|
local packages = config.load("/etc/tpm/package.dat")
|
|
local temp = config.load("/etc/tpm/packageInstalled.dat")
|
|
local found, value
|
|
|
|
if not security.getSU() then
|
|
exception.throw("RestrictedOpsException")
|
|
return
|
|
end
|
|
|
|
if #tArgs < 1 then
|
|
kerneldraw.printAppInfo("tpm", "Package name not specified")
|
|
return
|
|
elseif not packages then
|
|
kerneldraw.printAppInfo("tpm", "package.dat is missing or corrupt")
|
|
log.writeMessage("package.dat unable to be traversed")
|
|
return
|
|
elseif not temp then
|
|
shell.executeScript("/etc/scripts/tpm-recache.tsf")
|
|
end
|
|
|
|
found, value = search.traverseKey(temp, tArgs[1])
|
|
if found and value then
|
|
kerneldraw.printAppInfo("tpm", "Package already installed")
|
|
return
|
|
end
|
|
|
|
kerneldraw.printAppInfo("tpm", "Traversing package.dat")
|
|
local ok, pack = search.traverseValue(packages, tArgs[1])
|
|
if ok and pack then
|
|
kerneldraw.printAppInfo("tpm", "Found corresponding package")
|
|
kerneldraw.printAppInfo("tpm", "Downloading API files [1/2]")
|
|
local numapi = 1
|
|
local numbin = 1
|
|
local APIInstallFlag = false
|
|
for k,v in pairs(pack.apis) do
|
|
if tpm.downloadAPI(k, v) then
|
|
APIInstallFlag = true
|
|
kerneldraw.printAppInfo("tpm", "Downloaded API "..k.." ["..tostring(numapi).."]")
|
|
else
|
|
kerneldraw.printAppWarning("tpm", "Failed to download API "..k)
|
|
end
|
|
numapi = numapi + 1
|
|
end
|
|
kerneldraw.printAppInfo("tpm", "Downloading binaries [2/2]")
|
|
for k,v in pairs(pack.bins) do
|
|
if tpm.downloadBinary(k, v) then
|
|
kerneldraw.printAppInfo("tpm", "Downloaded binary "..k.." ["..tostring(numbin).."]")
|
|
else
|
|
kerneldraw.printAppWarning("tpm", "Failed to download binary "..k)
|
|
end
|
|
numbin = numbin + 1
|
|
end
|
|
table.insert(temp, pack.name)
|
|
log.writeMessage("New package downloaded and installed")
|
|
config.save(temp, "/etc/tpm/packageInstalled.dat")
|
|
kerneldraw.printAppSuccess("tpm", "package installed")
|
|
if APIInstallFlag then
|
|
if kerneldraw.request("Assemblies were installed, restart") then
|
|
kernel.reboot(false)
|
|
end
|
|
end
|
|
else
|
|
kerneldraw.printAppInfo("tpm", "Unable to find id for "..tArgs[1])
|
|
end |