summaryrefslogtreecommitdiff
path: root/meta/classes/distrodata.bbclass
blob: 72dded6e9e32535bb0d56c88dc821e3f78314bf1 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

require conf/distro/include/distro_tracking_fields.inc

addhandler distro_eventhandler
python distro_eventhandler() {
    from bb.event import Handled, NotHandled
    # if bb.event.getName(e) == "TaskStarted":

    if bb.event.getName(e) == "BuildStarted":
	"""initialize log files."""
	logpath = bb.data.getVar('LOG_DIR', e.data, 1)
	bb.utils.mkdirhier(logpath)
	logfile = os.path.join(logpath, "distrodata.%s.csv" % bb.data.getVar('DATETIME', e.data, 1))
	if not os.path.exists(logfile):
		slogfile = os.path.join(logpath, "distrodata.csv")
		if os.path.exists(slogfile):
			os.remove(slogfile)
		os.system("touch %s" % logfile)
		os.symlink(logfile, slogfile)
		bb.data.setVar('LOG_FILE', logfile, e.data)

    return NotHandled
}

addtask distrodata_np
do_distrodata_np[nostamp] = "1"
python do_distrodata_np() {

	localdata = bb.data.createCopy(d)
        pn = bb.data.getVar("PN", d, True)
        bb.note("Package Name: %s" % pn)

	if pn.find("-native") != -1:
	    pnstripped = pn.split("-native")
	    bb.note("Native Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	if pn.find("-cross") != -1:
	    pnstripped = pn.split("-cross")
	    bb.note("cross Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	if pn.find("-initial") != -1:
	    pnstripped = pn.split("-initial")
	    bb.note("initial Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	"""generate package information from .bb file"""
	pname = bb.data.getVar('PN', localdata, True)
	pcurver = bb.data.getVar('PV', localdata, True)
	pdesc = bb.data.getVar('DESCRIPTION', localdata, True)
	pgrp = bb.data.getVar('SECTION', localdata, True)
	plicense = bb.data.getVar('LICENSE', localdata, True).replace(',','_')
	if bb.data.getVar('LIC_FILES_CHKSUM', localdata, True):
		pchksum="1"
	else:
		pchksum="0"

	if bb.data.getVar('RECIPE_STATUS', localdata, True):
		hasrstatus="1"
	else:
		hasrstatus="0"

	rstatus = bb.data.getVar('RECIPE_STATUS', localdata, True)
		
	pupver = bb.data.getVar('RECIPE_LATEST_VERSION', localdata, True)
	if pcurver == pupver:
		vermatch="1"
	else:
		vermatch="0"

	noupdate_reason = bb.data.getVar('RECIPE_NO_UPDATE_REASON', localdata, True)
	if noupdate_reason is None:
		noupdate="0"
	else:
		noupdate="1"

	ris = bb.data.getVar('RECIPE_INTEL_SECTION', localdata, True)
	maintainer = bb.data.getVar('RECIPE_MAINTAINER', localdata, True)
	rttr = bb.data.getVar('RECIPE_TIME_BETWEEN_LAST_TWO_RELEASES', localdata, True)
	rlrd = bb.data.getVar('RECIPE_LATEST_RELEASE_DATE', localdata, True)
	dc = bb.data.getVar('DEPENDENCY_CHECK', localdata, True)
	rc = bb.data.getVar('RECIPE_COMMENTS', localdata, True)

	bb.note("DISTRO: %s,%s,%s,%s,%s,%s,%s,%s, %s, %s, %s\n" % \
		  (pname, maintainer, plicense, pchksum, hasrstatus, vermatch, pcurver, pupver, noupdate, noupdate_reason, rstatus))
}

addtask distrodata
do_distrodata[nostamp] = "1"
python do_distrodata() {

	logpath = bb.data.getVar('LOG_DIR', d, 1)
	bb.utils.mkdirhier(logpath)
	logfile = os.path.join(logpath, "distrodata.csv")
        bb.note("LOG_FILE: %s\n" % logfile)

	localdata = bb.data.createCopy(d)
        pn = bb.data.getVar("PN", d, True)
        bb.note("Package Name: %s" % pn)

	if pn.find("-native") != -1:
	    pnstripped = pn.split("-native")
	    bb.note("Native Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	if pn.find("-cross") != -1:
	    pnstripped = pn.split("-cross")
	    bb.note("cross Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	if pn.find("-initial") != -1:
	    pnstripped = pn.split("-initial")
	    bb.note("initial Split: %s" % pnstripped)
	    bb.data.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + bb.data.getVar('OVERRIDES', d, True), localdata)
	    bb.data.update_data(localdata)

	"""generate package information from .bb file"""
	pname = bb.data.getVar('PN', localdata, True)
	pcurver = bb.data.getVar('PV', localdata, True)
	pdesc = bb.data.getVar('DESCRIPTION', localdata, True)
	pgrp = bb.data.getVar('SECTION', localdata, True)
	plicense = bb.data.getVar('LICENSE', localdata, True).replace(',','_')
	if bb.data.getVar('LIC_FILES_CHKSUM', localdata, True):
		pchksum="1"
	else:
		pchksum="0"

	if bb.data.getVar('RECIPE_STATUS', localdata, True):
		hasrstatus="1"
	else:
		hasrstatus="0"

	rstatus = bb.data.getVar('RECIPE_STATUS', localdata, True)
		
	pupver = bb.data.getVar('RECIPE_LATEST_VERSION', localdata, True)
	if pcurver == pupver:
		vermatch="1"
	else:
		vermatch="0"

	noupdate_reason = bb.data.getVar('RECIPE_NO_UPDATE_REASON', localdata, True)
	if noupdate_reason is None:
		noupdate="0"
	else:
		noupdate="1"

	ris = bb.data.getVar('RECIPE_INTEL_SECTION', localdata, True)
	maintainer = bb.data.getVar('RECIPE_MAINTAINER', localdata, True)
	rttr = bb.data.getVar('RECIPE_TIME_BETWEEN_LAST_TWO_RELEASES', localdata, True)
	rlrd = bb.data.getVar('RECIPE_LATEST_RELEASE_DATE', localdata, True)
	dc = bb.data.getVar('DEPENDENCY_CHECK', localdata, True)
	rc = bb.data.getVar('RECIPE_COMMENTS', localdata, True)

	lf = bb.utils.lockfile(logfile + ".lock")
	f = open(logfile, "a")
	f.write("%s,%s,%s,%s,%s,%s,%s,%s, %s, %s, %s\n" % \
		  (pname, maintainer, plicense, pchksum, hasrstatus, vermatch, pcurver, pupver, noupdate, noupdate_reason, rstatus))
	f.close()
	bb.utils.unlockfile(lf)
}

addtask distrodataall after do_distrodata
do_distrodataall[recrdeptask] = "do_distrodata"
do_distrodataall[nostamp] = "1"
do_distrodataall() {
	:
}