diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2014-07-09 13:42:10 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2014-07-09 13:42:10 +0000 |
commit | 10866da12f0896d7ddd0e562e0942a29a0f2f720 (patch) | |
tree | 8e7863309b75068e6af9df0a4fcad52075d613be | |
parent | 35fc117ae46a403d4051ef7891819b5c1431132e (diff) | |
download | upstream-monitor-10866da12f0896d7ddd0e562e0942a29a0f2f720.tar.bz2 upstream-monitor-10866da12f0896d7ddd0e562e0942a29a0f2f720.tar.xz |
use general upstream providers
-rwxr-xr-x | aports-vercmp | 26 | ||||
-rw-r--r-- | upstream/archlinux.lua | 36 |
2 files changed, 39 insertions, 23 deletions
diff --git a/aports-vercmp b/aports-vercmp index 8fdd91f..5199fec 100755 --- a/aports-vercmp +++ b/aports-vercmp @@ -1,9 +1,10 @@ #!/usr/bin/lua5.2 - -archlinux = require("upstream.archlinux").Init() -gnome = require("upstream.gnome") +upstream_providers = { + (require("upstream.gnome")), + (require("upstream.archlinux")), +} maintainer = {} @@ -11,13 +12,14 @@ io.stderr:write("Reading aports...\n") db = require("aports.db").new("~/aports", "main") for p in db:each_aport() do - local upstream_pkg = gnome.init(p) - if upstream_pkg then - newver = upstream_pkg:find_newer() - upstream = upstream_pkg.provider_name - else - newver = archlinux:find_newer(p.pkgname, p.pkgver) - upstream = "archlinux" + local upstream_pkg = nil + local newver = nil + for _,provider in pairs(upstream_providers) do + upstream_pkg = provider.init(p) + if upstream_pkg then + newver = upstream_pkg:find_newer() + break + end end if newver ~= nil then local m = p:get_maintainer() @@ -25,8 +27,8 @@ for p in db:each_aport() do ["name"] = p.pkgname, ["current"] = p.pkgver, ["new"] = newver, - ["upstream"] = upstream, - } + ["upstream"] = upstream_pkg.provider_name, + } if maintainer[m] == nil then maintainer[m] = {} end diff --git a/upstream/archlinux.lua b/upstream/archlinux.lua index 584b366..7b5229f 100644 --- a/upstream/archlinux.lua +++ b/upstream/archlinux.lua @@ -1,7 +1,6 @@ -module(..., package.seeall) - -require("apk") +apk = require("apk") +local M = {} --"http://mirrors.kernel.org/archlinux/" local url_base="http://ftp.lysator.liu.se/pub/archlinux/" local upstream_repos = { @@ -89,7 +88,9 @@ local function is_newer(arch, pkgver) -- print(pkgname.."-"..arch.pkgver.." (current: "..pkgver..")") end -local function find_newer(self, pkgname, pkgver) +local function find_newer(self) + local pkgname = self.pkg.pkgname + local pkgver = self.pkg.pkgver local i, p, newest if self.db[pkgname] == nil then return @@ -110,18 +111,31 @@ local function exists(self, pkgname) return self.db[pkgname] ~= nil end -function Init() - local i, repo - local handle = {} +local repos_initialized = false +local function init_repos() + if repos_initialized then + return db + end for i,repo in pairs(upstream_repos) do io.stderr:write("Reading upstream "..repo.."\n") read_upstream_repodb(repo) end + repos_initialized = true + return db +end - handle.db = db - handle.find_newer = find_newer - handle.exists = exists - return handle +function M.init(pkg) + init_repos() + if db[pkg.pkgname] == nil then + return nil + end + return { + provider_name = "archlinux", + db = db, + find_newer = find_newer, + pkg = pkg + } end +return M |