#!/usr/bin/python -O # # Copyright 2005 Sven Wegener # Distributed under the terms of the GNU General Public License v2 # # $Id: check-failing-src_uri 256 2005-08-31 23:48:36Z sven $ # import portage, portage_dep, pycurl, sys, os dbapi = portage.db['/']['porttree'].dbapi checked = {} fetcher = pycurl.Curl() fetcher.setopt(pycurl.FOLLOWLOCATION, 1) fetcher.setopt(pycurl.NOBODY, 1) cp_all = dbapi.cp_all() for c in portage.settings.categories: if c.startswith('cross-'): continue if os.fork(): continue for cp in [cp for cp in dbapi.cp_all() if cp.startswith(c + '/')]: for cpv in dbapi.cp_list(cp): restrict, src_uri = dbapi.aux_get(cpv, ['RESTRICT', 'SRC_URI']) restrict = restrict.split() if 'fetch' in restrict: continue for url in portage.flatten(portage_dep.use_reduce(portage_dep.paren_reduce(src_uri), matchall = True)): if url.startswith('mirror://'): continue try: if checked.has_key(url): code = checked[url] else: fetcher.setopt(pycurl.URL, url) fetcher.perform() code = checked[url] = fetcher.getinfo(pycurl.RESPONSE_CODE) except SystemExit: raise except Exception, e: print '%s: %s failed with exception, %s' % (cpv, url, e) continue if not (url.startswith('http://') and code == 200 or url.startswith('ftp://') and code == 250): if 'nomirror' in restrict: print '%s: %s failed with code %d (nomirror)' % (cpv, url, code) else: print '%s: %s failed with code %d' % (cpv, url, code) sys.exit(0) os.wait()