-- Log package installs, upgrades, downgrades and removals -- By pmatilai@welho.com -- Licenced under the GPL -- don't log when in --test mode configs = { "RPM::Options", "RPM::Install-Options", "RPM::Erase-Options" } for i, conf in ipairs(configs) do rpmopts = confgetlist(conf, "") for j, opt in ipairs(rpmopts) do if string.find(opt, "test") then return end end end if transaction_success == false then return end if confexists("Scripts::Options::ShowRpmCmd") and confget("Scripts::Options::ShowRpmCmd/b") == "true" then return end if confexists("Temp::LogList") then logfile = io.open(confget("Dir::State::Logfile"), "a+") for i, str in ipairs(confgetlist("Temp::LogList")) do logfile:write(os.date()..";"..str.."\n") end logfile:close() logfile = confget("Dir::State::Logfile") return end function log(pkg, oper) if statremove(pkg) then logstr = "remove;"..pkgname(pkg)..";"..verstr(pkgvercur(pkg)) elseif statnewinstall(pkg) then logstr = "install;"..pkgname(pkg)..";"..verstr(pkgverinst(pkg)) elseif statinstall(pkg) then logstr = "upgrade;"..pkgname(pkg)..";"..verstr(pkgvercur(pkg)).." => "..verstr(pkgverinst(pkg)) elseif statdowngrade(pkg) then logstr = "degrade;"..pkgname(pkg)..";"..verstr(pkgvercur(pkg)).." => "..verstr(pkgverinst(pkg)) end confset("Temp::LogList::", logstr) end for i, pkg in ipairs(pkglist()) do if not statkeep(pkg) then log(pkg) end end