summaryrefslogtreecommitdiffstats
path: root/meta/classes/distrodata.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/distrodata.bbclass')
-rw-r--r--meta/classes/distrodata.bbclass902
1 files changed, 902 insertions, 0 deletions
diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass
new file mode 100644
index 0000000000..a890de7911
--- /dev/null
+++ b/meta/classes/distrodata.bbclass
@@ -0,0 +1,902 @@
1include conf/distro/include/package_regex.inc
2addhandler distro_eventhandler
3distro_eventhandler[eventmask] = "bb.event.BuildStarted"
4python distro_eventhandler() {
5 import oe.distro_check as dc
6 logfile = dc.create_log_file(e.data, "distrodata.csv")
7 lf = bb.utils.lockfile("%s.lock" % logfile)
8 f = open(logfile, "a")
9 f.write("Package,Description,Owner,License,VerMatch,Version,Upsteam,Reason,Recipe Status,Distro 1,Distro 2,Distro 3\n")
10 f.close()
11 bb.utils.unlockfile(lf)
12
13 return
14}
15
16addtask distrodata_np
17do_distrodata_np[nostamp] = "1"
18python do_distrodata_np() {
19 localdata = bb.data.createCopy(d)
20 pn = d.getVar("PN", True)
21 bb.note("Package Name: %s" % pn)
22
23 import oe.distro_check as dist_check
24 tmpdir = d.getVar('TMPDIR', True)
25 distro_check_dir = os.path.join(tmpdir, "distro_check")
26 datetime = localdata.getVar('DATETIME', True)
27 dist_check.update_distro_data(distro_check_dir, datetime)
28
29 if pn.find("-native") != -1:
30 pnstripped = pn.split("-native")
31 bb.note("Native Split: %s" % pnstripped)
32 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
33 bb.data.update_data(localdata)
34
35 if pn.find("-cross") != -1:
36 pnstripped = pn.split("-cross")
37 bb.note("cross Split: %s" % pnstripped)
38 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
39 bb.data.update_data(localdata)
40
41 if pn.find("-crosssdk") != -1:
42 pnstripped = pn.split("-crosssdk")
43 bb.note("cross Split: %s" % pnstripped)
44 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
45 bb.data.update_data(localdata)
46
47 if pn.startswith("nativesdk-"):
48 pnstripped = pn.replace("nativesdk-", "")
49 bb.note("NativeSDK Split: %s" % pnstripped)
50 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
51 bb.data.update_data(localdata)
52
53
54 if pn.find("-initial") != -1:
55 pnstripped = pn.split("-initial")
56 bb.note("initial Split: %s" % pnstripped)
57 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
58 bb.data.update_data(localdata)
59
60 """generate package information from .bb file"""
61 pname = localdata.getVar('PN', True)
62 pcurver = localdata.getVar('PV', True)
63 pdesc = localdata.getVar('DESCRIPTION', True)
64 if pdesc is not None:
65 pdesc = pdesc.replace(',','')
66 pdesc = pdesc.replace('\n','')
67
68 pgrp = localdata.getVar('SECTION', True)
69 plicense = localdata.getVar('LICENSE', True).replace(',','_')
70
71 rstatus = localdata.getVar('RECIPE_COLOR', True)
72 if rstatus is not None:
73 rstatus = rstatus.replace(',','')
74
75 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION', True)
76 if pcurver == pupver:
77 vermatch="1"
78 else:
79 vermatch="0"
80 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON', True)
81 if noupdate_reason is None:
82 noupdate="0"
83 else:
84 noupdate="1"
85 noupdate_reason = noupdate_reason.replace(',','')
86
87 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
88 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE', True)
89 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
90
91 bb.note("DISTRO: %s,%s,%s,%s,%s,%s,%s,%s,%s\n" % \
92 (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus))
93 line = pn
94 for i in result:
95 line = line + "," + i
96 bb.note("%s\n" % line)
97}
98
99addtask distrodata
100do_distrodata[nostamp] = "1"
101python do_distrodata() {
102 logpath = d.getVar('LOG_DIR', True)
103 bb.utils.mkdirhier(logpath)
104 logfile = os.path.join(logpath, "distrodata.csv")
105
106 import oe.distro_check as dist_check
107 localdata = bb.data.createCopy(d)
108 tmpdir = d.getVar('TMPDIR', True)
109 distro_check_dir = os.path.join(tmpdir, "distro_check")
110 datetime = localdata.getVar('DATETIME', True)
111 dist_check.update_distro_data(distro_check_dir, datetime)
112
113 pn = d.getVar("PN", True)
114 bb.note("Package Name: %s" % pn)
115
116 if pn.find("-native") != -1:
117 pnstripped = pn.split("-native")
118 bb.note("Native Split: %s" % pnstripped)
119 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
120 bb.data.update_data(localdata)
121
122 if pn.startswith("nativesdk-"):
123 pnstripped = pn.replace("nativesdk-", "")
124 bb.note("NativeSDK Split: %s" % pnstripped)
125 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
126 bb.data.update_data(localdata)
127
128 if pn.find("-cross") != -1:
129 pnstripped = pn.split("-cross")
130 bb.note("cross Split: %s" % pnstripped)
131 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
132 bb.data.update_data(localdata)
133
134 if pn.find("-crosssdk") != -1:
135 pnstripped = pn.split("-crosssdk")
136 bb.note("cross Split: %s" % pnstripped)
137 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
138 bb.data.update_data(localdata)
139
140 if pn.find("-initial") != -1:
141 pnstripped = pn.split("-initial")
142 bb.note("initial Split: %s" % pnstripped)
143 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
144 bb.data.update_data(localdata)
145
146 """generate package information from .bb file"""
147 pname = localdata.getVar('PN', True)
148 pcurver = localdata.getVar('PV', True)
149 pdesc = localdata.getVar('DESCRIPTION', True)
150 if pdesc is not None:
151 pdesc = pdesc.replace(',','')
152 pdesc = pdesc.replace('\n','')
153
154 pgrp = localdata.getVar('SECTION', True)
155 plicense = localdata.getVar('LICENSE', True).replace(',','_')
156
157 rstatus = localdata.getVar('RECIPE_COLOR', True)
158 if rstatus is not None:
159 rstatus = rstatus.replace(',','')
160
161 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION', True)
162 if pcurver == pupver:
163 vermatch="1"
164 else:
165 vermatch="0"
166
167 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON', True)
168 if noupdate_reason is None:
169 noupdate="0"
170 else:
171 noupdate="1"
172 noupdate_reason = noupdate_reason.replace(',','')
173
174 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
175 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE', True)
176 # do the comparison
177 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
178
179 lf = bb.utils.lockfile("%s.lock" % logfile)
180 f = open(logfile, "a")
181 f.write("%s,%s,%s,%s,%s,%s,%s,%s,%s" % \
182 (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus))
183 line = ""
184 for i in result:
185 line = line + "," + i
186 f.write(line + "\n")
187 f.close()
188 bb.utils.unlockfile(lf)
189}
190
191addtask distrodataall after do_distrodata
192do_distrodataall[recrdeptask] = "do_distrodataall do_distrodata"
193do_distrodataall[recideptask] = "do_${BB_DEFAULT_TASK}"
194do_distrodataall[nostamp] = "1"
195do_distrodataall() {
196 :
197}
198
199addhandler checkpkg_eventhandler
200checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted"
201python checkpkg_eventhandler() {
202 def parse_csv_file(filename):
203 package_dict = {}
204 fd = open(filename, "r")
205 lines = fd.read().rsplit("\n")
206 fd.close()
207
208 first_line = ''
209 index = 0
210 for line in lines:
211 #Skip the first line
212 if index == 0:
213 first_line = line
214 index += 1
215 continue
216 elif line == '':
217 continue
218 index += 1
219 package_name = line.rsplit("\t")[0]
220 if '-native' in package_name or 'nativesdk-' in package_name:
221 original_name = package_name.rsplit('-native')[0]
222 if original_name == '':
223 original_name = package_name.rsplit('nativesdk-')[0]
224 if original_name in package_dict:
225 continue
226 else:
227 package_dict[package_name] = line
228 else:
229 new_name = package_name + "-native"
230 if not(new_name in package_dict):
231 new_name = 'nativesdk-' + package_name
232 if new_name in package_dict:
233 del package_dict[new_name]
234 package_dict[package_name] = line
235
236 fd = open(filename, "w")
237 fd.write("%s\n"%first_line)
238 for el in package_dict:
239 fd.write(package_dict[el] + "\n")
240 fd.close()
241
242 del package_dict
243
244 if bb.event.getName(e) == "BuildStarted":
245 import oe.distro_check as dc
246 logfile = dc.create_log_file(e.data, "checkpkg.csv")
247
248 lf = bb.utils.lockfile("%s.lock" % logfile)
249 f = open(logfile, "a")
250 f.write("Package\tVersion\tUpver\tLicense\tSection\tHome\tRelease\tDepends\tBugTracker\tPE\tDescription\tStatus\tTracking\tURI\tMAINTAINER\tNoUpReason\n")
251 f.close()
252 bb.utils.unlockfile(lf)
253 elif bb.event.getName(e) == "BuildCompleted":
254 import os
255 filename = "tmp/log/checkpkg.csv"
256 if os.path.isfile(filename):
257 lf = bb.utils.lockfile("%s.lock"%filename)
258 parse_csv_file(filename)
259 bb.utils.unlockfile(lf)
260 return
261}
262
263addtask checkpkg
264do_checkpkg[nostamp] = "1"
265python do_checkpkg() {
266 localdata = bb.data.createCopy(d)
267 import re
268 import tempfile
269 import subprocess
270
271 """
272 sanity check to ensure same name and type. Match as many patterns as possible
273 such as:
274 gnome-common-2.20.0.tar.gz (most common format)
275 gtk+-2.90.1.tar.gz
276 xf86-input-synaptics-12.6.9.tar.gz
277 dri2proto-2.3.tar.gz
278 blktool_4.orig.tar.gz
279 libid3tag-0.15.1b.tar.gz
280 unzip552.tar.gz
281 icu4c-3_6-src.tgz
282 genext2fs_1.3.orig.tar.gz
283 gst-fluendo-mp3
284 """
285 prefix1 = "[a-zA-Z][a-zA-Z0-9]*([\-_][a-zA-Z]\w+)*\+?[\-_]" # match most patterns which uses "-" as separator to version digits
286 prefix2 = "[a-zA-Z]+" # a loose pattern such as for unzip552.tar.gz
287 prefix3 = "[0-9]+[\-]?[a-zA-Z]+" # a loose pattern such as for 80325-quicky-0.4.tar.gz
288 prefix = "(%s|%s|%s)" % (prefix1, prefix2, prefix3)
289 ver_regex = "(([A-Z]*\d+[a-zA-Z]*[\.\-_]*)+)"#"((\d+[\.\-_[a-z]])+)"
290 # src.rpm extension was added only for rpm package. Can be removed if the rpm
291 # packaged will always be considered as having to be manually upgraded
292 suffix = "(tar\.gz|tgz|tar\.bz2|tar\.lz4|zip|xz|rpm|bz2|lz4|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)"
293
294 suffixtuple = ("tar.gz", "tgz", "zip", "tar.bz2", "tar.xz", "tar.lz4", "bz2", "lz4", "orig.tar.gz", "src.tar.gz", "src.rpm", "src.tgz", "svnr\d+.tar.bz2", "stable.tar.gz", "src.rpm")
295 sinterstr = "(?P<name>%s?)v?(?P<ver>%s)(\-source)?" % (prefix, ver_regex)
296 sdirstr = "(?P<name>%s)\.?v?(?P<ver>%s)(\-source)?[\.\-](?P<type>%s$)" % (prefix, ver_regex, suffix)
297
298 def parse_inter(s):
299 m = re.search(sinterstr, s)
300 if not m:
301 return None
302 else:
303 return (m.group('name'), m.group('ver'), "")
304
305 def parse_dir(s):
306 m = re.search(sdirstr, s)
307 if not m:
308 return None
309 else:
310 return (m.group('name'), m.group('ver'), m.group('type'))
311
312 def modelate_version(version):
313 if version[0] in ['.', '-']:
314 if version[1].isdigit():
315 version = version[1] + version[0] + version[2:len(version)]
316 else:
317 version = version[1:len(version)]
318
319 version = re.sub('\-', '.', version)
320 version = re.sub('_', '.', version)
321 version = re.sub('(rc)+', '.-1.', version)
322 version = re.sub('(alpha)+', '.-3.', version)
323 version = re.sub('(beta)+', '.-2.', version)
324 if version[0] == 'v':
325 version = version[1:len(version)]
326 return version
327
328 """
329 Check whether 'new' is newer than 'old' version. We use existing vercmp() for the
330 purpose. PE is cleared in comparison as it's not for build, and PV is cleared too
331 for simplicity as it's somehow difficult to get from various upstream format
332 """
333 def __vercmp(old, new):
334 (on, ov, ot) = old
335 (en, ev, et) = new
336 if on != en or (et and et not in suffixtuple):
337 return False
338 ov = modelate_version(ov)
339 ev = modelate_version(ev)
340
341 result = bb.utils.vercmp(("0", ov, ""), ("0", ev, ""))
342 if result < 0:
343 return True
344 else:
345 return False
346
347 """
348 wrapper for fetch upstream directory info
349 'url' - upstream link customized by regular expression
350 'd' - database
351 'tmpf' - tmpfile for fetcher output
352 We don't want to exit whole build due to one recipe error. So handle all exceptions
353 gracefully w/o leaking to outer.
354 """
355 def internal_fetch_wget(url, ud, d, tmpf):
356 status = "ErrFetchUnknown"
357
358 agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12"
359 fetchcmd = "/usr/bin/env wget -t 1 --passive-ftp -O %s --user-agent=\"%s\" '%s'" % (tmpf.name, agent, url)
360 try:
361 fetcher = bb.fetch2.wget.Wget(d)
362 fetcher._runwget(ud, d, fetchcmd, True)
363 status = "SUCC"
364 except bb.fetch2.BBFetchException, e:
365 status = "ErrFetch"
366
367 return status
368
369 """
370 Check on middle version directory such as "2.4/" in "http://xxx/2.4/pkg-2.4.1.tar.gz",
371 'url' - upstream link customized by regular expression
372 'd' - database
373 'curver' - current version
374 Return new version if success, or else error in "Errxxxx" style
375 """
376 def check_new_dir(url, curver, ud, d):
377 pn = d.getVar('PN', True)
378 f = tempfile.NamedTemporaryFile(delete=False, prefix="%s-1-" % pn)
379 status = internal_fetch_wget(url, ud, d, f)
380 fhtml = f.read()
381 if status == "SUCC" and len(fhtml):
382 newver = parse_inter(curver)
383
384 """
385 match "*4.1/">*4.1/ where '*' matches chars
386 N.B. add package name, only match for digits
387 """
388 regex = d.getVar('REGEX', True)
389 if regex == '':
390 regex = "^%s" %prefix
391 m = re.search("^%s" % regex, curver)
392 if m:
393 s = "%s[^\d\"]*?(\d+[\.\-_])+\d+/?" % m.group()
394 else:
395 s = "(\d+[\.\-_])+\d+/?"
396
397 searchstr = "[hH][rR][eE][fF]=\"%s\">" % s
398
399 reg = re.compile(searchstr)
400 valid = 0
401 for line in fhtml.split("\n"):
402 if line.find(curver) >= 0:
403 valid = 1
404 m = reg.search(line)
405 if m:
406 ver = m.group().split("\"")[1]
407 ver = ver.strip("/")
408 ver = parse_inter(ver)
409 if ver and __vercmp(newver, ver) == True:
410 newver = ver
411
412 """Expect a match for curver in directory list, or else it indicates unknown format"""
413 if not valid:
414 status = "ErrParseInterDir"
415 else:
416 """rejoin the path name"""
417 status = newver[0] + newver[1]
418 elif not len(fhtml):
419 status = "ErrHostNoDir"
420
421 f.close()
422 if status != "ErrHostNoDir" and re.match("Err", status):
423 logpath = d.getVar('LOG_DIR', True)
424 subprocess.call("cp %s %s/" % (f.name, logpath), shell=True)
425 os.unlink(f.name)
426 return status
427
428 """
429 Check on the last directory to search '2.4.1' in "http://xxx/2.4/pkg-2.4.1.tar.gz",
430 'url' - upstream link customized by regular expression
431 'd' - database
432 'curname' - current package name
433 Return new version if success, or else error in "Errxxxx" style
434 """
435 def check_new_version(url, curname, ud, d):
436 """possible to have no version in pkg name, such as spectrum-fw"""
437 if not re.search("\d+", curname):
438 return pcurver
439 pn = d.getVar('PN', True)
440 newver_regex = d.getVar('REGEX', True)
441 f = tempfile.NamedTemporaryFile(delete=False, prefix="%s-2-" % pn)
442 status = internal_fetch_wget(url, ud, d, f)
443 fhtml = f.read()
444
445 if status == "SUCC" and len(fhtml):
446 newver = parse_dir(curname)
447
448 if not newver_regex:
449 """this is the default matching pattern, if recipe does not """
450 """provide a regex expression """
451 """match "{PN}-5.21.1.tar.gz">{PN}-5.21.1.tar.gz """
452 pn1 = re.search("^%s" % prefix, curname).group()
453 s = "[^\"]*%s[^\d\"]*?(\d+[\.\-_])+[^\"]*" % pn1
454 searchstr = "[hH][rR][eE][fF]=\"%s\".*[>\"]" % s
455 reg = searchstr
456 else:
457 reg = newver_regex
458 valid = 0
459 count = 0
460 for line in fhtml.split("\n"):
461 if pn == 'kconfig-frontends':
462 m = re.findall(reg, line)
463 if m:
464 valid = 1
465 for match in m:
466 (on, ov, oe) = newver
467 ver = (on, match[0], oe)
468 if ver and __vercmp(newver, ver) == True:
469 newver = ver
470 continue
471 count += 1
472 m = re.search(reg, line)
473 if m:
474 valid = 1
475 if not newver_regex:
476 ver = m.group().split("\"")[1].split("/")[-1]
477 if ver == "download":
478 ver = m.group().split("\"")[1].split("/")[-2]
479 ver = parse_dir(ver)
480 else:
481 """ we cheat a little here, but we assume that the
482 regular expression in the recipe will extract exacly
483 the version """
484 (on, ov, oe) = newver
485 ver = (on, m.group('pver'), oe)
486 if ver and __vercmp(newver, ver) == True:
487 newver = ver
488 """Expect a match for curver in directory list, or else it indicates unknown format"""
489 if not valid:
490 status = "ErrParseDir"
491 else:
492 """newver still contains a full package name string"""
493 status = re.sub('_', '.', newver[1])
494 elif not len(fhtml):
495 status = "ErrHostNoDir"
496
497 f.close()
498 """if host hasn't directory information, no need to save tmp file"""
499 if status != "ErrHostNoDir" and re.match("Err", status):
500 logpath = d.getVar('LOG_DIR', True)
501 subprocess.call("cp %s %s/" % (f.name, logpath), shell=True)
502 os.unlink(f.name)
503 return status
504
505 """first check whether a uri is provided"""
506 src_uri = d.getVar('SRC_URI', True)
507 if not src_uri:
508 return
509
510 """initialize log files."""
511 logpath = d.getVar('LOG_DIR', True)
512 bb.utils.mkdirhier(logpath)
513 logfile = os.path.join(logpath, "checkpkg.csv")
514
515 """generate package information from .bb file"""
516 pname = d.getVar('PN', True)
517
518 if pname.find("-native") != -1:
519 if d.getVar('BBCLASSEXTEND', True):
520 return
521 pnstripped = pname.split("-native")
522 bb.note("Native Split: %s" % pnstripped)
523 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
524 bb.data.update_data(localdata)
525
526 if pname.startswith("nativesdk-"):
527 if d.getVar('BBCLASSEXTEND', True):
528 return
529 pnstripped = pname.replace("nativesdk-", "")
530 bb.note("NativeSDK Split: %s" % pnstripped)
531 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
532 bb.data.update_data(localdata)
533
534 if pname.find("-cross") != -1:
535 pnstripped = pname.split("-cross")
536 bb.note("cross Split: %s" % pnstripped)
537 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
538 bb.data.update_data(localdata)
539
540 if pname.find("-initial") != -1:
541 pnstripped = pname.split("-initial")
542 bb.note("initial Split: %s" % pnstripped)
543 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
544 bb.data.update_data(localdata)
545
546 chk_uri = d.getVar('REGEX_URI', True)
547 if not chk_uri:
548 chk_uri = src_uri
549 pdesc = localdata.getVar('DESCRIPTION', True)
550 pgrp = localdata.getVar('SECTION', True)
551 if localdata.getVar('PRSPV', True):
552 pversion = localdata.getVar('PRSPV', True)
553 else:
554 pversion = localdata.getVar('PV', True)
555 plicense = localdata.getVar('LICENSE', True)
556 psection = localdata.getVar('SECTION', True)
557 phome = localdata.getVar('HOMEPAGE', True)
558 prelease = localdata.getVar('PR', True)
559 pdepends = localdata.getVar('DEPENDS', True)
560 pbugtracker = localdata.getVar('BUGTRACKER', True)
561 ppe = localdata.getVar('PE', True)
562 psrcuri = localdata.getVar('SRC_URI', True)
563 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
564
565 found = 0
566 for uri in src_uri.split():
567 m = re.compile('(?P<type>[^:]*)').match(uri)
568 if not m:
569 raise MalformedUrl(uri)
570 elif m.group('type') in ('http', 'https', 'ftp', 'cvs', 'svn', 'git'):
571 found = 1
572 pproto = m.group('type')
573 break
574 if not found:
575 pproto = "file"
576 pupver = "N/A"
577 pstatus = "ErrUnknown"
578
579 (type, host, path, user, pswd, parm) = bb.fetch.decodeurl(uri)
580 if type in ['http', 'https', 'ftp']:
581 if d.getVar('PRSPV', True):
582 pcurver = d.getVar('PRSPV', True)
583 else:
584 pcurver = d.getVar('PV', True)
585 else:
586 if d.getVar('PRSPV', True):
587 pcurver = d.getVar('PRSPV', True)
588 else:
589 pcurver = d.getVar("SRCREV", True)
590
591
592 if type in ['http', 'https', 'ftp']:
593 ud = bb.fetch2.FetchData(uri, d)
594 newver = pcurver
595 altpath = path
596 dirver = "-"
597 curname = "-"
598
599 """
600 match version number amid the path, such as "5.7" in:
601 http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
602 N.B. how about sth. like "../5.7/5.8/..."? Not find such example so far :-P
603 """
604 m = re.search(r"[^/]*(\d+\.)+\d+([\-_]r\d+)*/", path)
605 if m:
606 altpath = path.split(m.group())[0]
607 dirver = m.group().strip("/")
608
609 """use new path and remove param. for wget only param is md5sum"""
610 alturi = bb.fetch.encodeurl([type, host, altpath, user, pswd, {}])
611 my_uri = d.getVar('REGEX_URI', True)
612 if my_uri:
613 if d.getVar('PRSPV', True):
614 newver = d.getVar('PRSPV', True)
615 else:
616 newver = d.getVar('PV', True)
617 else:
618 newver = check_new_dir(alturi, dirver, ud, d)
619 altpath = path
620 if not re.match("Err", newver) and dirver != newver:
621 altpath = altpath.replace(dirver, newver, True)
622 # For folder in folder cases - try to enter the folder again and then try parsing
623 """Now try to acquire all remote files in current directory"""
624 if not re.match("Err", newver):
625 curname = altpath.split("/")[-1]
626
627 """get remote name by skipping pacakge name"""
628 m = re.search(r"/.*/", altpath)
629 if not m:
630 altpath = "/"
631 else:
632 altpath = m.group()
633
634 chk_uri = d.getVar('REGEX_URI', True)
635 if not chk_uri:
636 alturi = bb.fetch.encodeurl([type, host, altpath, user, pswd, {}])
637 else:
638 alturi = chk_uri
639 newver = check_new_version(alturi, curname, ud, d)
640 while(newver == "ErrHostNoDir"):
641 if alturi == "/download":
642 break
643 else:
644 alturi = "/".join(alturi.split("/")[0:-2]) + "/download"
645 newver = check_new_version(alturi, curname, ud, d)
646 if not re.match("Err", newver):
647 pupver = newver
648 if pupver != pcurver:
649 pstatus = "UPDATE"
650 else:
651 pstatus = "MATCH"
652
653 if re.match("Err", newver):
654 pstatus = newver + ":" + altpath + ":" + dirver + ":" + curname
655 elif type == 'git':
656 if user:
657 gituser = user + '@'
658 else:
659 gituser = ""
660
661 if 'protocol' in parm:
662 gitproto = parm['protocol']
663 else:
664 gitproto = "git"
665
666 # Get all tags and HEAD
667 if d.getVar('GIT_REGEX', True):
668 gitcmd = "git ls-remote %s://%s%s%s %s 2>&1" % (gitproto, gituser, host, path, d.getVar('GIT_REGEX', True))
669 else:
670 gitcmd = "git ls-remote %s://%s%s%s *tag* 2>&1" % (gitproto, gituser, host, path)
671 gitcmd2 = "git ls-remote %s://%s%s%s HEAD 2>&1" % (gitproto, gituser, host, path)
672
673 tmp = os.popen(gitcmd).read()
674 if 'unable to connect' in tmp:
675 tmp = None
676 tmp2 = os.popen(gitcmd2).read()
677 if 'unable to connect' in tmp2:
678 tmp2 = None
679 #This is for those repos have tag like: refs/tags/1.2.2
680 phash = pversion.rsplit("+")[-1]
681 if tmp:
682 tmpline = tmp.split("\n")
683 verflag = 0
684 pupver = pversion
685 for line in tmpline:
686 if len(line)==0:
687 break;
688 puptag = line.split("/")[-1]
689 upstr_regex = d.getVar('REGEX', True)
690 if upstr_regex:
691 puptag = re.search(upstr_regex, puptag)
692 else:
693 puptag = re.search("(?P<pver>([0-9][\.|_]?)+)", puptag)
694 if puptag == None:
695 continue
696 puptag = puptag.group('pver')
697 puptag = re.sub("_",".",puptag)
698 plocaltag = pupver.split("+git")[0]
699 if "git" in plocaltag:
700 plocaltag = plocaltag.split("-")[0]
701 result = bb.utils.vercmp(("0", puptag, ""), ("0", plocaltag, ""))
702
703 if result > 0:
704 verflag = 1
705 pupver = puptag
706 elif verflag == 0 :
707 pupver = plocaltag
708 #This is for those no tag repo
709 elif tmp2:
710 pupver = pversion.rsplit("+")[0]
711 phash = pupver
712 else:
713 pstatus = "ErrGitAccess"
714 if not ('ErrGitAccess' in pstatus):
715
716 latest_head = tmp2.rsplit("\t")[0][:7]
717 tmp3 = re.search('(?P<git_ver>(\d+[\.-]?)+)(?P<git_prefix>(\+git[r|\-|]?)AUTOINC\+)(?P<head_md5>([\w|_]+))', pversion)
718 tmp4 = re.search('(?P<git_ver>(\d+[\.-]?)+)(?P<git_prefix>(\+git[r|\-|]?)AUTOINC\+)(?P<head_md5>([\w|_]+))', pupver)
719 if not tmp4:
720 tmp4 = re.search('(?P<git_ver>(\d+[\.-]?)+)', pupver)
721
722 if tmp3:
723 # Get status of the package - MATCH/UPDATE
724 result = bb.utils.vercmp(("0", tmp3.group('git_ver'), ""), ("0",tmp3.group('git_ver') , ""))
725 # Get the latest tag
726 pstatus = 'MATCH'
727 if result < 0:
728 latest_pv = tmp3.group('git_ver')
729 else:
730 latest_pv = pupver
731 if not(tmp3.group('head_md5')[:7] in latest_head) or not(latest_head in tmp3.group('head_md5')[:7]):
732 pstatus = 'UPDATE'
733
734 git_prefix = tmp3.group('git_prefix')
735 pupver = latest_pv + tmp3.group('git_prefix') + latest_head
736 else:
737 if not tmp3:
738 bb.plain("#DEBUG# Package %s: current version (%s) doesn't match the usual pattern" %(pname, pversion))
739 elif type == 'svn':
740 ud = bb.fetch2.FetchData(uri, d)
741
742 svnFetcher = bb.fetch2.svn.Svn(d)
743 svnFetcher.urldata_init(ud, d)
744 try:
745 pupver = svnFetcher.latest_revision(ud, d, ud.names[0])
746 except bb.fetch2.FetchError:
747 pstatus = "ErrSvnAccess"
748
749 if pupver:
750 if pupver in pversion:
751 pstatus = "MATCH"
752 else:
753 pstatus = "UPDATE"
754 else:
755 pstatus = "ErrSvnAccess"
756
757 if 'rev' in ud.parm:
758 pcurver = ud.parm['rev']
759
760 if pstatus != "ErrSvnAccess":
761 tag = pversion.rsplit("+svn")[0]
762 svn_prefix = re.search('(\+svn[r|\-]?)', pversion)
763 if tag and svn_prefix:
764 pupver = tag + svn_prefix.group() + pupver
765
766 elif type == 'cvs':
767 pupver = "HEAD"
768 pstatus = "UPDATE"
769 elif type == 'file':
770 """local file is always up-to-date"""
771 pupver = pcurver
772 pstatus = "MATCH"
773 else:
774 pstatus = "ErrUnsupportedProto"
775
776 if re.match("Err", pstatus):
777 pstatus += ":%s%s" % (host, path)
778
779 """Read from manual distro tracking fields as alternative"""
780 pmver = d.getVar("RECIPE_UPSTREAM_VERSION", True)
781 if not pmver:
782 pmver = "N/A"
783 pmstatus = "ErrNoRecipeData"
784 else:
785 if pmver == pcurver:
786 pmstatus = "MATCH"
787 else:
788 pmstatus = "UPDATE"
789
790 psrcuri = psrcuri.split()[0]
791 pdepends = "".join(pdepends.split("\t"))
792 pdesc = "".join(pdesc.split("\t"))
793 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON', True)
794 lf = bb.utils.lockfile("%s.lock" % logfile)
795 f = open(logfile, "a")
796 f.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % \
797 (pname,pversion,pupver,plicense,psection, phome,prelease, pdepends,pbugtracker,ppe,pdesc,pstatus,pmver,psrcuri,maintainer, no_upgr_reason))
798 f.close()
799 bb.utils.unlockfile(lf)
800}
801
802addtask checkpkgall after do_checkpkg
803do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg"
804do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}"
805do_checkpkgall[nostamp] = "1"
806do_checkpkgall() {
807 :
808}
809
810addhandler distro_check_eventhandler
811distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
812python distro_check_eventhandler() {
813 """initialize log files."""
814 import oe.distro_check as dc
815 result_file = dc.create_log_file(e.data, "distrocheck.csv")
816 return
817}
818
819addtask distro_check
820do_distro_check[nostamp] = "1"
821python do_distro_check() {
822 """checks if the package is present in other public Linux distros"""
823 import oe.distro_check as dc
824 import shutil
825 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('sdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('nativesdk',d):
826 return
827
828 localdata = bb.data.createCopy(d)
829 bb.data.update_data(localdata)
830 tmpdir = d.getVar('TMPDIR', True)
831 distro_check_dir = os.path.join(tmpdir, "distro_check")
832 logpath = d.getVar('LOG_DIR', True)
833 bb.utils.mkdirhier(logpath)
834 result_file = os.path.join(logpath, "distrocheck.csv")
835 datetime = localdata.getVar('DATETIME', True)
836 dc.update_distro_data(distro_check_dir, datetime)
837
838 # do the comparison
839 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
840
841 # save the results
842 dc.save_distro_check_result(result, datetime, result_file, d)
843}
844
845addtask distro_checkall after do_distro_check
846do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check"
847do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}"
848do_distro_checkall[nostamp] = "1"
849do_distro_checkall() {
850 :
851}
852#
853#Check Missing License Text.
854#Use this task to generate the missing license text data for pkg-report system,
855#then we can search those recipes which license text isn't exsit in common-licenses directory
856#
857addhandler checklicense_eventhandler
858checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
859python checklicense_eventhandler() {
860 """initialize log files."""
861 import oe.distro_check as dc
862 logfile = dc.create_log_file(e.data, "missinglicense.csv")
863 lf = bb.utils.lockfile("%s.lock" % logfile)
864 f = open(logfile, "a")
865 f.write("Package\tLicense\tMissingLicense\n")
866 f.close()
867 bb.utils.unlockfile(lf)
868 return
869}
870
871addtask checklicense
872do_checklicense[nostamp] = "1"
873python do_checklicense() {
874 import shutil
875 logpath = d.getVar('LOG_DIR', True)
876 bb.utils.mkdirhier(logpath)
877 pn = d.getVar('PN', True)
878 logfile = os.path.join(logpath, "missinglicense.csv")
879 generic_directory = d.getVar('COMMON_LICENSE_DIR', True)
880 license_types = d.getVar('LICENSE', True)
881 for license_type in ((license_types.replace('+', '').replace('|', '&')
882 .replace('(', '').replace(')', '').replace(';', '')
883 .replace(',', '').replace(" ", "").split("&"))):
884 if not os.path.isfile(os.path.join(generic_directory, license_type)):
885 lf = bb.utils.lockfile("%s.lock" % logfile)
886 f = open(logfile, "a")
887 f.write("%s\t%s\t%s\n" % \
888 (pn,license_types,license_type))
889 f.close()
890 bb.utils.unlockfile(lf)
891 return
892}
893
894addtask checklicenseall after do_checklicense
895do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense"
896do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}"
897do_checklicenseall[nostamp] = "1"
898do_checklicenseall() {
899 :
900}
901
902