blob: 522824ba5865d0816f9fdd8aca283bdc2e481f4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/usr/bin/env python
# This script can be used to verify HOMEPAGE values for all recipes in
# the current configuration.
# The result is influenced by network environment, since the timeout of connect url is 5 seconds as default.
import sys
import os
import subprocess
import urllib2
# Allow importing scripts/lib modules
scripts_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/..')
lib_path = scripts_path + '/lib'
sys.path = sys.path + [lib_path]
import scriptpath
import scriptutils
# Allow importing bitbake modules
bitbakepath = scriptpath.add_bitbake_lib_path()
import bb.tinfoil
logger = scriptutils.logger_create('verify_homepage')
def wgetHomepage(pn, homepage):
result = subprocess.call('wget ' + '-q -T 5 -t 1 --spider ' + homepage, shell = True)
if result:
logger.warn("%s: failed to verify HOMEPAGE: %s " % (pn, homepage))
return 1
else:
return 0
def verifyHomepage(bbhandler):
pkg_pn = bbhandler.cooker.recipecache.pkg_pn
pnlist = sorted(pkg_pn)
count = 0
for pn in pnlist:
fn = pkg_pn[pn].pop()
data = bb.cache.Cache.loadDataFull(fn, bbhandler.cooker.collection.get_file_appends(fn), bbhandler.config_data)
homepage = data.getVar("HOMEPAGE", True)
if homepage:
try:
urllib2.urlopen(homepage, timeout=5)
except Exception:
count = count + wgetHomepage(pn, homepage)
return count
if __name__=='__main__':
bbhandler = bb.tinfoil.Tinfoil()
bbhandler.prepare()
logger.info("Start verifying HOMEPAGE:")
failcount = verifyHomepage(bbhandler)
logger.info("Finished verifying HOMEPAGE.")
logger.info("Summary: %s failed" % failcount)
|