summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-12-17 16:01:14 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-12-17 16:01:14 +0000
commit8bdce87ea33366b25bb622eb69fc47bbc21130cb (patch)
tree292e9cebf0b805dda3ea2829be1c307d6dec86dd
downloadupstream-monitor-8bdce87ea33366b25bb622eb69fc47bbc21130cb.tar.bz2
upstream-monitor-8bdce87ea33366b25bb622eb69fc47bbc21130cb.tar.xz
initial commit
-rw-r--r--aports-vercmp40
-rw-r--r--archlinux.lua127
-rw-r--r--upstream.lua100
3 files changed, 267 insertions, 0 deletions
diff --git a/aports-vercmp b/aports-vercmp
new file mode 100644
index 0000000..7d9f0a2
--- /dev/null
+++ b/aports-vercmp
@@ -0,0 +1,40 @@
+#!/usr/bin/lua
+
+require("aports")
+
+upstream = require("archlinux").Init()
+--upstream = require("upstream").Init()
+
+maintainer = {}
+
+io.stderr:write("Reading aports...\n")
+adb = aports.new{"~/aports/main"}
+
+adb:foreach_aport(function(p)
+ newver = upstream:find_newer(p.pkgname, p.pkgver)
+ if newver ~= nil then
+ local m = aports.get_maintainer(p)
+ local t = {
+ ["name"] = p.pkgname,
+ ["current"] = p.pkgver,
+ ["new"] = newver,
+ }
+ if maintainer[m] == nil then
+ maintainer[m] = {}
+ end
+ table.insert(maintainer[m], t)
+ end
+end)
+
+print(os.date())
+for m, pkgs in pairs(maintainer) do
+ if m == nil or m == "" then
+ m = "(unmaintained)"
+ end
+ table.sort(pkgs, function(a,b) return a.name<b.name end)
+ print("==== "..m.." ====")
+ for i,p in pairs(pkgs) do
+ print(string.format("%-40s(current: %s)", p.name.."-"..p.new, p.current))
+ end
+ print()
+end
diff --git a/archlinux.lua b/archlinux.lua
new file mode 100644
index 0000000..584b366
--- /dev/null
+++ b/archlinux.lua
@@ -0,0 +1,127 @@
+module(..., package.seeall)
+
+require("apk")
+
+--"http://mirrors.kernel.org/archlinux/"
+local url_base="http://ftp.lysator.liu.se/pub/archlinux/"
+local upstream_repos = {
+ "core/os/i686/core.db.tar.gz",
+ "extra/os/i686/extra.db.tar.gz",
+ "community/os/i686/community.db.tar.gz",
+}
+
+local db = {}
+
+local pkgmap = {
+ ["freetype"] = "freetype2",
+ ["gmp5"] = "gmp",
+ ["gstreamer" ] = "gstreamer0.10",
+ ["gstreamer1"] = "gstreamer",
+ ["gtk+2.0"] = "gtk2",
+ ["mpfr3"] = "mpfr",
+ ["python"] = "python2",
+ ["mpc1" ] = "libmpc",
+ [ "libmpc" ] = "",
+ ["glib" ] = "glib2",
+ ["libnl3" ] = "libnl",
+ ["libnl" ] = "",
+}
+
+local version_regex = {
+ ["%.[pP](%d+)$"] = "_p%1",
+ ["([^_])p(%d+)$"] = "%1_p%2",
+ ["%.([a-z])$"] = "_%1",
+ ["(%d)[Rr][Cc](%d+)"] = "%1_rc%2",
+ ["(%d)b(%d+)$"] = "%1_beta%2",
+}
+
+local function fix_version(ver)
+ local search, replace
+ local str = ver
+ for search, replace in pairs(version_regex) do
+ str = string.gsub(str, search, replace)
+ end
+ return str
+end
+
+local function add_version(repodb, pkgname, pkgver, pkgrel)
+ if pkgname == nil then
+ return
+ end
+ local name = pkgmap[pkgname]
+ if name == nil then
+ name = pkgname
+ end
+ if db[name] == nil then
+ db[name] = {}
+ end
+ table.insert(db[name], {
+ repo = repodb,
+ origver=pkgver,
+ pkgver=fix_version(pkgver),
+ pkgrel=pkgrel,
+ pkgname=pkgname,
+ })
+end
+
+local function read_upstream_repodb(repodb)
+ local f
+ local url = url_base..repodb
+ local dbfile = string.gsub(repodb, ".*/", "")
+
+ local line
+-- os.execute("wget "..url)
+-- local f = io.popen("tar -ztf "..dbfile.." 2>/dev/null")
+ local f = io.popen("curl --silent "..url.." | tar -zt 2>/dev/null")
+ local pkgdb = {}
+ for line in f:lines() do
+ local pkgname, pkgver, pkgrel = string.match(line, "^(.*)-([0-9]+.*)-([0-9]+)/$")
+ add_version(repodb, pkgname, pkgver, pkgrel)
+ end
+ f:close()
+end
+
+local function is_newer(arch, pkgver)
+ if not apk.version_is_less(pkgver, arch) then
+ return nil
+ end
+ return arch
+-- print(pkgname.."-"..arch.pkgver.." (current: "..pkgver..")")
+end
+
+local function find_newer(self, pkgname, pkgver)
+ local i, p, newest
+ if self.db[pkgname] == nil then
+ return
+ end
+ newest = "0"
+ for i, p in pairs(self.db[pkgname]) do
+ if apk.version_is_less(newest, p.pkgver) then
+ newest = p.pkgver
+ end
+ end
+ if is_newer(newest, pkgver) then
+ return newest
+ end
+ return nil
+end
+
+local function exists(self, pkgname)
+ return self.db[pkgname] ~= nil
+end
+
+function Init()
+ local i, repo
+ local handle = {}
+ for i,repo in pairs(upstream_repos) do
+ io.stderr:write("Reading upstream "..repo.."\n")
+ read_upstream_repodb(repo)
+ end
+
+ handle.db = db
+ handle.find_newer = find_newer
+ handle.exists = exists
+ return handle
+end
+
+
diff --git a/upstream.lua b/upstream.lua
new file mode 100644
index 0000000..2c8fd2c
--- /dev/null
+++ b/upstream.lua
@@ -0,0 +1,100 @@
+module(..., package.seeall)
+
+require("apk")
+require("download")
+
+local pkg_list_file = "upstream.list"
+
+local url_alias = {
+ ["SF-DEFAULT"] = "http://sourceforge.net/api/file/index/project-name/%s/mtime/desc/limit/20/rss",
+ ["FM-DEFAULT"] = "http://freshmeat.net/projects/%s",
+ ["GNU-DEFAULT"] = "http://ftp.gnu.org/gnu/%s/",
+ ["CPAN-DEFAULT"] = "http://search.cpan.org/dist/%s/",
+ ["HACKAGE-DEFAULT"] = "http://hackage.haskell.org/packages/archive/%s/",
+ ["DEBIAN-DEFAULT"] = "http://ftp.debian.org/debian/pool/main/first-char-of-%s/%s/",
+ ["GOOGLE-DEFAULT"] = "http://code.google.com/p/%s/downloads/list",
+ ["PYPI-DEFAULT"] = "http://pypi.python.org/packages/source/first-char-of-%s/%s",
+ ["LP-DEFAULT"] = "https://launchpad.net/%s/+download",
+ ["GNOME-DEFAULT"] = "http://download.gnome.org/sources/%s/*/",
+}
+
+local version_regex = {
+ ["DEFAULT"] = function(name)
+ return "%A"..name.."[-_](%d+[^-/_%s]*?).tar."
+ end,
+}
+
+local version_replace = {
+ ["%.[pP](%d+)$"] = "_p%1",
+ ["([^_])p(%d+)$"] = "%1_p%2",
+ ["%.([a-z])$"] = "_%1",
+ ["(%d)[Rr][Cc](%d+)"] = "%1_rc%2",
+ ["(%d)b(%d+)$"] = "%1_beta%2",
+}
+
+
+local function fix_version(ver)
+ local search, replace
+ local str = ver
+ for search, replace in pairs(version_regex) do
+ str = string.gsub(str, search, replace)
+ end
+ return str
+end
+
+local function read_list_file()
+ local db = {}
+ local line
+ local f = io.open(pkg_list_file)
+ if f == nil then
+ return nil
+ end
+ for line in f:lines() do
+ local name = nil
+ local pkgname, regex, url = string.match(line, "(.*)%s+(.*)%s+(.*)")
+ if regex then
+ local re, name = string.match(regex, "(.*):(.*)")
+ if re then
+ regex = re
+ end
+ end
+ if name == nil then
+ name = pkgname
+ end
+ if pkgname ~= nil then
+ db[pkgname] = {
+ ["regex"] = regex,
+ ["url"] = url,
+ ["name"] = name,
+ }
+ end
+ print(pkgname, regex, url, name)
+ end
+ f:close()
+ return db
+end
+
+local function find_newer(self, pkg)
+ local p = self.db[pkg]
+ if p == nil then
+ --log_missing(pkg)
+ return nil
+ end
+ local url = string.format(p.url, p.name)
+ print("Searching upstream version of "..pkg.."...")
+ local buf = download.get(url)
+ io.stdout:write(buf)
+end
+
+function Init()
+ local i, repo
+ local handle = {}
+ handle.db = read_list_file()
+ if handle.db == nil then
+ return nil
+ end
+ handle.find_newer = find_newer
+ handle.exists = exists
+ return handle
+end
+