68 lines
2.1 KiB
Text
68 lines
2.1 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
|
||
|
|
||
|
|
||
|
kerneldraw.printAppInfo("tpm", "Traversing package.dat")
|
||
|
local ok, pack = search.traverseValue(packages, tArgs[1])
|
||
|
if ok and pack then
|
||
|
found, value = search.traverseKey(temp, pack.name)
|
||
|
if found and value then
|
||
|
temp[value] = nil
|
||
|
else
|
||
|
kerneldraw.printAppInfo("tpm", "Package missing")
|
||
|
return
|
||
|
end
|
||
|
kerneldraw.printAppInfo("tpm", "Found corresponding package")
|
||
|
kerneldraw.printAppInfo("tpm", "Removing API files [1/2]")
|
||
|
local numapi = 1
|
||
|
local numbin = 1
|
||
|
local APIRemovalFlag = false
|
||
|
for k,v in pairs(pack.apis) do
|
||
|
if fs.exists(tpm.toPackageAPI(k)) and not fs.isDir(tpm.toPackageAPI(k)) then
|
||
|
fs.delete(tpm.toPackageAPI(k))
|
||
|
APIRemovalFlag = true
|
||
|
kerneldraw.printAppInfo("tpm", "Removed API "..k.." ["..tostring(numapi).."]")
|
||
|
else
|
||
|
kerneldraw.printAppWarning("tpm", "Failed to remove API "..k)
|
||
|
end
|
||
|
numapi = numapi + 1
|
||
|
end
|
||
|
kerneldraw.printAppInfo("tpm", "Removing binaries [2/2]")
|
||
|
for k,v in pairs(pack.bins) do
|
||
|
if fs.exists(tpm.toPackageBinary(k)) and not fs.isDir(tpm.toPackageBinary(k)) then
|
||
|
fs.delete(tpm.toPackageBinary(k))
|
||
|
kerneldraw.printAppInfo("tpm", "Removed binary "..k.." ["..tostring(numbin).."]")
|
||
|
else
|
||
|
kerneldraw.printAppWarning("tpm", "Failed to remove binary "..k)
|
||
|
end
|
||
|
numbin = numbin + 1
|
||
|
end
|
||
|
if APIRemovalFlag then
|
||
|
if kerneldraw.request("Assemblies were removed, restart") then
|
||
|
kernel.reboot(false)
|
||
|
end
|
||
|
end
|
||
|
config.save(temp, "/etc/tpm/packageInstalled.dat")
|
||
|
log.writeMessage("Removed package "..tArgs[1])
|
||
|
kerneldraw.printAppSuccess("tpm", "Package removed")
|
||
|
else
|
||
|
kerneldraw.printAppInfo("tpm", "Unable to find id for "..tArgs[1])
|
||
|
end
|