diff --git a/lib/pkgman.lua b/lib/pkgman.lua index 0f7f237..eaf193c 100644 --- a/lib/pkgman.lua +++ b/lib/pkgman.lua @@ -4,6 +4,7 @@ local pkg = {} pkg.cfgPath = "/boot/cfg/pkg" pkg.sourcePath = pkg.cfgPath .. "/sources.cfg" pkg.installedPath = pkg.cfgPath .. "/installed.cfg" +require("pkgfs") local function getSources() local f = io.open(pkg.sourcePath,"rb") @@ -126,13 +127,12 @@ function pkg.upgrade(force) -- boolean -- boolean -- Upgrades all packages on th fs.makeDirectory("/boot/pkg") local installed = getInstalled() for repo,info in pairs(getSources()) do - for pkgname,pkg in pairs(getRepoMeta(repo)) do - if pkg.version ~= installed[pkgname].version or force then + for pkgname,pkginfo in pairs(getRepoMeta(repo)) do + if installed[pkgname] and pkginfo.version ~= installed[pkgname].version or force then pkg.remove(pkgname) - dl(info.path.."/"..pkg.filename,"/boot/pkg/"..pkg.filename) + dl(info.path.."/"..pkginfo.filename,"/boot/pkg/"..pkginfo.filename) installed[pkgname] = pkg - pcall(activatePackage,"/boot/pkg/"..pkg.filename,pkg.compressed) - return true + pcall(activatePackage,"/boot/pkg/"..pkginfo.filename,pkginfo.compressed) end end end @@ -142,7 +142,7 @@ end function pkg.remove(pkgname) -- string -- boolean -- Remove the package *pkgname* from the pkgfs and package directory. local installed = getInstalled() local pkginfo = installed[pkgname] - if not pkginfo then error(pkgname .." not installed") end + if not pkginfo then return true end pcall(deactivatePackage,"/boot/pkg/"..pkginfo.filename) fs.remove("/boot/pkg/"..pkginfo.filename) installed[pkgname] = nil