summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Lu <Chong.Lu@windriver.com>2014-06-25 17:39:44 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-07-03 17:41:17 +0100
commitfd4eca071c8ee19420bd7c862df1d31e89c49f37 (patch)
treedb746bc17bc9f4a654b506488a7a52ae161d9f32
parentab1dce9bd593beff9b85482dda704529766beb6d (diff)
downloadpoky-fd4eca071c8ee19420bd7c862df1d31e89c49f37.tar.gz
scripts/contrib/verify-homepage.py: add a script to verify HOMEPAGE
Add a script to verify all the recipes' HOMEPAGE. [YOCTO #5689] (From OE-Core rev: 2dfb2ef06763cb6044dc1630875024e7310b3df4) Signed-off-by: Chong Lu <Chong.Lu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/contrib/verify-homepage.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/contrib/verify-homepage.py b/scripts/contrib/verify-homepage.py
new file mode 100755
index 0000000000..86cc82bca3
--- /dev/null
+++ b/scripts/contrib/verify-homepage.py
@@ -0,0 +1,63 @@
1#!/usr/bin/env python
2
3# This script is used for verify HOMEPAGE.
4# The result is influenced by network environment, since the timeout of connect url is 5 seconds as default.
5
6import sys
7import os
8import subprocess
9import urllib2
10
11def search_bitbakepath():
12 bitbakepath = ""
13
14 # Search path to bitbake lib dir in order to load bb modules
15 if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib/bb')):
16 bitbakepath = os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib')
17 bitbakepath = os.path.abspath(bitbakepath)
18 else:
19 # Look for bitbake/bin dir in PATH
20 for pth in os.environ['PATH'].split(':'):
21 if os.path.exists(os.path.join(pth, '../lib/bb')):
22 bitbakepath = os.path.abspath(os.path.join(pth, '../lib'))
23 break
24 if not bitbakepath:
25 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
26 sys.exit(1)
27 return bitbakepath
28
29# For importing the following modules
30sys.path.insert(0, search_bitbakepath())
31import bb.tinfoil
32
33def wgetHomepage(pn, homepage):
34 result = subprocess.call('wget ' + '-q -T 5 -t 1 --spider ' + homepage, shell = True)
35 if result:
36 bb.warn("Failed to verify HOMEPAGE (%s) of %s" % (homepage, pn))
37 return 1
38 else:
39 return 0
40
41def verifyHomepage(bbhandler):
42 pkg_pn = bbhandler.cooker.recipecache.pkg_pn
43 pnlist = sorted(pkg_pn)
44 count = 0
45 for pn in pnlist:
46 fn = pkg_pn[pn].pop()
47 data = bb.cache.Cache.loadDataFull(fn, bbhandler.cooker.collection.get_file_appends(fn), bbhandler.config_data)
48 homepage = data.getVar("HOMEPAGE")
49 if homepage:
50 try:
51 urllib2.urlopen(homepage, timeout=5)
52 except Exception:
53 count = count + wgetHomepage(pn, homepage)
54 return count
55
56if __name__=='__main__':
57 failcount = 0
58 bbhandler = bb.tinfoil.Tinfoil()
59 bbhandler.prepare()
60 print "Start to verify HOMEPAGE:"
61 failcount = verifyHomepage(bbhandler)
62 print "finish to verify HOMEPAGE."
63 print "Summary: %s failed" % failcount