From 056b00f7096b43cc05dcec3373be205062ac4b6d Mon Sep 17 00:00:00 2001 From: volpino Date: Fri, 14 Sep 2012 16:56:52 +0200 Subject: [PATCH] euscan: Adding naive deb handler, TODO updated Signed-off-by: volpino --- TODO | 18 ++++++++----- pym/euscan/handlers/deb.py | 46 +++++++++++++++++++++++++++++++++ pym/euscan/handlers/freecode.py | 2 +- 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 pym/euscan/handlers/deb.py diff --git a/TODO b/TODO index 1cc313f..da0f38f 100644 --- a/TODO +++ b/TODO @@ -41,12 +41,18 @@ packages: ### handlers -- freecode: to scan freecode.com -- remote-id: type deb repository. Example I always scan: - http://dl.google.com/linux/musicmanager/deb/dists/stable/main/binary-i386/Packages - to see if google has release an update, same would help for all google - packages and some of the actual debian packages. - Something similar could be done for rpm repositories. +- remote-id type deb repository: + - Fix handler to support Packages.gz or Packages.bz2 + - find out how to get download url + +### remote-id +- Propose new remote-id: deb + e.g.: + http://mysite.com/deb/dists/stable/main/binary-i386/Packages + +- Propose new remote-id: freecode + e.g.: projectname + euscanwww --------- diff --git a/pym/euscan/handlers/deb.py b/pym/euscan/handlers/deb.py new file mode 100644 index 0000000..156158b --- /dev/null +++ b/pym/euscan/handlers/deb.py @@ -0,0 +1,46 @@ +import urllib +import re + +import portage + +from euscan import mangling, helpers, output + +HANDLER_NAME = "deb" +CONFIDENCE = 100 +PRIORITY = 90 + + +def can_handle(pkg, url=None): + return False + + +def scan_pkg(pkg, options): + cp, ver, rev = portage.pkgsplit(pkg.cpv) + + packages_url, package_name = options['data'].strip().split(" ", 1) + + output.einfo("Using Debian Packages: " + packages_url) + + fp = urllib.urlopen(packages_url) + content = fp.read() + + # TODO: Add support for .gz and .bz2 Packages file + + content = content.split("\n\n") + + result = [] + + for package_info in content: + for line in package_info.split("\n"): + res = re.search("^Version: (.*)$", line) + if res: + result.append(res.group(1)) + + ret = [] + for up_pv in result: + url = "" # TODO: How to find the url? + pv = mangling.mangle_version(up_pv, options) + if helpers.version_filtered(cp, ver, pv): + continue + ret.append((url, pv, HANDLER_NAME, CONFIDENCE)) + return ret diff --git a/pym/euscan/handlers/freecode.py b/pym/euscan/handlers/freecode.py index ebfe852..b811e32 100644 --- a/pym/euscan/handlers/freecode.py +++ b/pym/euscan/handlers/freecode.py @@ -17,7 +17,7 @@ def can_handle(pkg, url=None): def scan_pkg(pkg, options): cp, ver, rev = portage.pkgsplit(pkg.cpv) - package = options['data'] + package = options['data'].strip() output.einfo("Using FreeCode handler: " + package)