This commit is contained in:
volpino 2012-05-05 14:28:48 +02:00
parent 52fc4a5df4
commit 058b50556b
3 changed files with 103 additions and 10 deletions

View File

@ -42,7 +42,7 @@ def setupSignals():
def exithandler(signum, frame): def exithandler(signum, frame):
signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN)
print () print()
sys.exit(errno.EINTR) sys.exit(errno.EINTR)
signal.signal(signal.SIGINT, exithandler) signal.signal(signal.SIGINT, exithandler)
@ -236,19 +236,19 @@ def main():
pp.die(1, '%s: %s' % (package, str(err))) pp.die(1, '%s: %s' % (package, str(err)))
if not CONFIG['quiet']: if not CONFIG['quiet']:
print () print()
for cp, url, version in ret: for cp, url, version in ret:
if not CONFIG['quiet']: if not CONFIG['quiet']:
print ("Upstream Version: " print("Upstream Version: "
+ pp.number("%s" % version) + pp.number("%s" % version)
+ pp.path(" %s" % url)) + pp.path(" %s" % url))
else: else:
print (pp.cpv("%s-%s" % (cp, version)) print(pp.cpv("%s-%s" % (cp, version))
+ ": " + pp.path(url)) + ": " + pp.path(url))
if not len(ret) and not CONFIG['quiet']: if not len(ret) and not CONFIG['quiet']:
print (pp.warn("Didn't find any new version, " print(pp.warn("Didn't find any new version, "
+ "check package's homepage for " + "check package's homepage for "
+ "more informations")) + "more informations"))

View File

@ -1,7 +1,9 @@
import os import os
import sys
import re import re
import pkg_resources import pkg_resources
import errno import errno
import imp
import urllib2 import urllib2
@ -14,6 +16,11 @@ except ImportError:
import portage import portage
from portage import dep from portage import dep
from portage.const import VDB_PATH
from portage import _encodings
from portage import _shell_quote
from portage import _unicode_decode
from portage import _unicode_encode
from euscan import CONFIG, BLACKLIST_VERSIONS, ROBOTS_TXT_BLACKLIST_DOMAINS from euscan import CONFIG, BLACKLIST_VERSIONS, ROBOTS_TXT_BLACKLIST_DOMAINS
import euscan import euscan
@ -566,3 +573,82 @@ def parse_mirror(uri):
return None return None
return uri return uri
# Stolen from ebuild
def query_from_ebuild(ebuild):
pf = None
if ebuild.endswith(".ebuild"):
pf = os.path.basename(ebuild)[:-7]
else:
return False
if not os.path.isabs(ebuild):
mycwd = os.getcwd()
# Try to get the non-canonical path from the PWD evironment variable,
# since the canonical path returned from os.getcwd() may may be
# unusable in cases where the directory stucture is built from
# symlinks.
pwd = os.environ.get('PWD', '')
if sys.hexversion < 0x3000000:
pwd = _unicode_decode(pwd, encoding=_encodings['content'],
errors='strict')
if pwd and pwd != mycwd and \
os.path.realpath(pwd) == mycwd:
mycwd = portage.normalize_path(pwd)
ebuild = os.path.join(mycwd, ebuild)
ebuild = portage.normalize_path(ebuild)
# portdbapi uses the canonical path for the base of the portage tree, but
# subdirectories of the base can be built from symlinks (like crossdev
# does).
ebuild_portdir = os.path.realpath(
os.path.dirname(os.path.dirname(os.path.dirname(ebuild))))
ebuild = os.path.join(ebuild_portdir, *ebuild.split(os.path.sep)[-3:])
vdb_path = os.path.join(portage.settings['ROOT'], VDB_PATH)
# Make sure that portdb.findname() returns the correct ebuild.
if ebuild_portdir != vdb_path and \
ebuild_portdir not in portage.portdb.porttrees:
if sys.hexversion >= 0x3000000:
os.environ["PORTDIR_OVERLAY"] = \
os.environ.get("PORTDIR_OVERLAY", "") + \
" " + _shell_quote(ebuild_portdir)
else:
os.environ["PORTDIR_OVERLAY"] = \
os.environ.get("PORTDIR_OVERLAY", "") + \
" " + _unicode_encode(_shell_quote(ebuild_portdir),
encoding=_encodings['content'], errors='strict')
portage.close_portdbapi_caches()
imp.reload(portage)
del portage.portdb.porttrees[1:]
if ebuild_portdir != portage.portdb.porttree_root:
portage.portdb.porttrees.append(ebuild_portdir)
if not os.path.exists(ebuild):
return False
ebuild_split = ebuild.split("/")
cpv = "%s/%s" % (ebuild_split[-3], pf)
if not portage.catpkgsplit(cpv):
return False
if ebuild.startswith(os.path.join(portage.root, portage.const.VDB_PATH)):
mytree = "vartree"
portage_ebuild = portage.db[portage.root][mytree].dbapi.findname(cpv)
if os.path.realpath(portage_ebuild) != ebuild:
return False
else:
mytree = "porttree"
portage_ebuild = portage.portdb.findname(cpv)
if not portage_ebuild or portage_ebuild != ebuild:
return False
return cpv

View File

@ -66,6 +66,13 @@ def scan_upstream_urls(cpv, urls):
def scan_upstream(query): def scan_upstream(query):
# check if the query is an ebuild file.
# if it's a valid ebuild convert the filename in an euscan query
ebuild_query = helpers.query_from_ebuild(query)
if ebuild_query:
query = ebuild_query
matches = Query(query).find( matches = Query(query).find(
include_masked=True, include_masked=True,
in_installed=False in_installed=False