Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # Records history of build output in order to detect regressions |
| 3 | # |
| 4 | # Based in part on testlab.bbclass and packagehistory.bbclass |
| 5 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6 | # Copyright (C) 2011-2016 Intel Corporation |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org> |
| 8 | # |
| 9 | |
| 10 | BUILDHISTORY_FEATURES ?= "image package sdk" |
| 11 | BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" |
| 12 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" |
| 13 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 14 | |
| 15 | # Setting this to non-empty will remove the old content of the buildhistory as part of |
| 16 | # the current bitbake invocation and replace it with information about what was built |
| 17 | # during the build. |
| 18 | # |
| 19 | # This is meant to be used in continuous integration (CI) systems when invoking bitbake |
| 20 | # for full world builds. The effect in that case is that information about packages |
| 21 | # that no longer get build also gets removed from the buildhistory, which is not |
| 22 | # the case otherwise. |
| 23 | # |
| 24 | # The advantage over manually cleaning the buildhistory outside of bitbake is that |
| 25 | # the "version-going-backwards" check still works. When relying on that, be careful |
| 26 | # about failed world builds: they will lead to incomplete information in the |
| 27 | # buildhistory because information about packages that could not be built will |
| 28 | # also get removed. A CI system should handle that by discarding the buildhistory |
| 29 | # of failed builds. |
| 30 | # |
| 31 | # The expected usage is via auto.conf, but passing via the command line also works |
| 32 | # with: BB_ENV_EXTRAWHITE=BUILDHISTORY_RESET BUILDHISTORY_RESET=1 |
| 33 | BUILDHISTORY_RESET ?= "" |
| 34 | |
| 35 | BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}" |
| 36 | BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" |
| 37 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 39 | BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | BUILDHISTORY_COMMIT ?= "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" |
| 42 | BUILDHISTORY_PUSH_REPO ?= "" |
| 43 | |
| 44 | SSTATEPOSTINSTFUNCS_append = " buildhistory_emit_pkghistory" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 45 | # We want to avoid influencing the signatures of sstate tasks - first the function itself: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | sstate_install[vardepsexclude] += "buildhistory_emit_pkghistory" |
| 47 | # then the value added to SSTATEPOSTINSTFUNCS: |
| 48 | SSTATEPOSTINSTFUNCS[vardepvalueexclude] .= "| buildhistory_emit_pkghistory" |
| 49 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 50 | # Similarly for our function that gets the output signatures |
| 51 | SSTATEPOSTUNPACKFUNCS_append = " buildhistory_emit_outputsigs" |
| 52 | sstate_installpkgdir[vardepsexclude] += "buildhistory_emit_outputsigs" |
| 53 | SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs" |
| 54 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 55 | # All items excepts those listed here will be removed from a recipe's |
| 56 | # build history directory by buildhistory_emit_pkghistory(). This is |
| 57 | # necessary because some of these items (package directories, files that |
| 58 | # we no longer emit) might be obsolete. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 60 | # When extending build history, derive your class from buildhistory.bbclass |
| 61 | # and extend this list here with the additional files created by the derived |
| 62 | # class. |
| 63 | BUILDHISTORY_PRESERVE = "latest latest_srcrev" |
| 64 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 65 | PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" |
| 66 | PATCH_GIT_USER_NAME ?= "OpenEmbedded" |
| 67 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 68 | # |
| 69 | # Write out metadata about this package for comparison when writing future packages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | # |
| 71 | python buildhistory_emit_pkghistory() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 72 | if not d.getVar('BB_CURRENTTASK') in ['packagedata', 'packagedata_setscene']: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | return 0 |
| 74 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | if not "package" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | return 0 |
| 77 | |
| 78 | import re |
| 79 | import json |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 80 | import shlex |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | import errno |
| 82 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 83 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
| 84 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
| 86 | class RecipeInfo: |
| 87 | def __init__(self, name): |
| 88 | self.name = name |
| 89 | self.pe = "0" |
| 90 | self.pv = "0" |
| 91 | self.pr = "r0" |
| 92 | self.depends = "" |
| 93 | self.packages = "" |
| 94 | self.srcrev = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 95 | self.layer = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | |
| 97 | |
| 98 | class PackageInfo: |
| 99 | def __init__(self, name): |
| 100 | self.name = name |
| 101 | self.pe = "0" |
| 102 | self.pv = "0" |
| 103 | self.pr = "r0" |
| 104 | # pkg/pkge/pkgv/pkgr should be empty because we want to be able to default them |
| 105 | self.pkg = "" |
| 106 | self.pkge = "" |
| 107 | self.pkgv = "" |
| 108 | self.pkgr = "" |
| 109 | self.size = 0 |
| 110 | self.depends = "" |
| 111 | self.rprovides = "" |
| 112 | self.rdepends = "" |
| 113 | self.rrecommends = "" |
| 114 | self.rsuggests = "" |
| 115 | self.rreplaces = "" |
| 116 | self.rconflicts = "" |
| 117 | self.files = "" |
| 118 | self.filelist = "" |
| 119 | # Variables that need to be written to their own separate file |
| 120 | self.filevars = dict.fromkeys(['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']) |
| 121 | |
| 122 | # Should check PACKAGES here to see if anything removed |
| 123 | |
| 124 | def readPackageInfo(pkg, histfile): |
| 125 | pkginfo = PackageInfo(pkg) |
| 126 | with open(histfile, "r") as f: |
| 127 | for line in f: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 128 | lns = line.split('=', 1) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | name = lns[0].strip() |
| 130 | value = lns[1].strip(" \t\r\n").strip('"') |
| 131 | if name == "PE": |
| 132 | pkginfo.pe = value |
| 133 | elif name == "PV": |
| 134 | pkginfo.pv = value |
| 135 | elif name == "PR": |
| 136 | pkginfo.pr = value |
| 137 | elif name == "PKG": |
| 138 | pkginfo.pkg = value |
| 139 | elif name == "PKGE": |
| 140 | pkginfo.pkge = value |
| 141 | elif name == "PKGV": |
| 142 | pkginfo.pkgv = value |
| 143 | elif name == "PKGR": |
| 144 | pkginfo.pkgr = value |
| 145 | elif name == "RPROVIDES": |
| 146 | pkginfo.rprovides = value |
| 147 | elif name == "RDEPENDS": |
| 148 | pkginfo.rdepends = value |
| 149 | elif name == "RRECOMMENDS": |
| 150 | pkginfo.rrecommends = value |
| 151 | elif name == "RSUGGESTS": |
| 152 | pkginfo.rsuggests = value |
| 153 | elif name == "RREPLACES": |
| 154 | pkginfo.rreplaces = value |
| 155 | elif name == "RCONFLICTS": |
| 156 | pkginfo.rconflicts = value |
| 157 | elif name == "PKGSIZE": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 158 | pkginfo.size = int(value) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | elif name == "FILES": |
| 160 | pkginfo.files = value |
| 161 | elif name == "FILELIST": |
| 162 | pkginfo.filelist = value |
| 163 | # Apply defaults |
| 164 | if not pkginfo.pkg: |
| 165 | pkginfo.pkg = pkginfo.name |
| 166 | if not pkginfo.pkge: |
| 167 | pkginfo.pkge = pkginfo.pe |
| 168 | if not pkginfo.pkgv: |
| 169 | pkginfo.pkgv = pkginfo.pv |
| 170 | if not pkginfo.pkgr: |
| 171 | pkginfo.pkgr = pkginfo.pr |
| 172 | return pkginfo |
| 173 | |
| 174 | def getlastpkgversion(pkg): |
| 175 | try: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 176 | histfile = os.path.join(oldpkghistdir, pkg, "latest") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | return readPackageInfo(pkg, histfile) |
| 178 | except EnvironmentError: |
| 179 | return None |
| 180 | |
| 181 | def sortpkglist(string): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 182 | pkgiter = re.finditer(r'[a-zA-Z0-9.+-]+( \([><=]+[^)]+\))?', string, 0) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | pkglist = [p.group(0) for p in pkgiter] |
| 184 | pkglist.sort() |
| 185 | return ' '.join(pkglist) |
| 186 | |
| 187 | def sortlist(string): |
| 188 | items = string.split(' ') |
| 189 | items.sort() |
| 190 | return ' '.join(items) |
| 191 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 192 | pn = d.getVar('PN') |
| 193 | pe = d.getVar('PE') or "0" |
| 194 | pv = d.getVar('PV') |
| 195 | pr = d.getVar('PR') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 196 | layer = bb.utils.get_file_layer(d.getVar('FILE'), d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 198 | pkgdata_dir = d.getVar('PKGDATA_DIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 199 | packages = "" |
| 200 | try: |
| 201 | with open(os.path.join(pkgdata_dir, pn)) as f: |
| 202 | for line in f.readlines(): |
| 203 | if line.startswith('PACKAGES: '): |
| 204 | packages = oe.utils.squashspaces(line.split(': ', 1)[1]) |
| 205 | break |
| 206 | except IOError as e: |
| 207 | if e.errno == errno.ENOENT: |
| 208 | # Probably a -cross recipe, just ignore |
| 209 | return 0 |
| 210 | else: |
| 211 | raise |
| 212 | |
| 213 | packagelist = packages.split() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 214 | preserve = d.getVar('BUILDHISTORY_PRESERVE').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | if not os.path.exists(pkghistdir): |
| 216 | bb.utils.mkdirhier(pkghistdir) |
| 217 | else: |
| 218 | # Remove files for packages that no longer exist |
| 219 | for item in os.listdir(pkghistdir): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 220 | if item not in preserve: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 221 | if item not in packagelist: |
| 222 | itempath = os.path.join(pkghistdir, item) |
| 223 | if os.path.isdir(itempath): |
| 224 | for subfile in os.listdir(itempath): |
| 225 | os.unlink(os.path.join(itempath, subfile)) |
| 226 | os.rmdir(itempath) |
| 227 | else: |
| 228 | os.unlink(itempath) |
| 229 | |
| 230 | rcpinfo = RecipeInfo(pn) |
| 231 | rcpinfo.pe = pe |
| 232 | rcpinfo.pv = pv |
| 233 | rcpinfo.pr = pr |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 234 | rcpinfo.depends = sortlist(oe.utils.squashspaces(d.getVar('DEPENDS') or "")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 235 | rcpinfo.packages = packages |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 236 | rcpinfo.layer = layer |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | write_recipehistory(rcpinfo, d) |
| 238 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 239 | pkgdest = d.getVar('PKGDEST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | for pkg in packagelist: |
| 241 | pkgdata = {} |
| 242 | with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f: |
| 243 | for line in f.readlines(): |
| 244 | item = line.rstrip('\n').split(': ', 1) |
| 245 | key = item[0] |
| 246 | if key.endswith('_' + pkg): |
| 247 | key = key[:-len(pkg)-1] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 248 | pkgdata[key] = item[1].encode('latin-1').decode('unicode_escape') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | |
| 250 | pkge = pkgdata.get('PKGE', '0') |
| 251 | pkgv = pkgdata['PKGV'] |
| 252 | pkgr = pkgdata['PKGR'] |
| 253 | # |
| 254 | # Find out what the last version was |
| 255 | # Make sure the version did not decrease |
| 256 | # |
| 257 | lastversion = getlastpkgversion(pkg) |
| 258 | if lastversion: |
| 259 | last_pkge = lastversion.pkge |
| 260 | last_pkgv = lastversion.pkgv |
| 261 | last_pkgr = lastversion.pkgr |
| 262 | r = bb.utils.vercmp((pkge, pkgv, pkgr), (last_pkge, last_pkgv, last_pkgr)) |
| 263 | if r < 0: |
| 264 | msg = "Package version for package %s went backwards which would break package feeds from (%s:%s-%s to %s:%s-%s)" % (pkg, last_pkge, last_pkgv, last_pkgr, pkge, pkgv, pkgr) |
| 265 | package_qa_handle_error("version-going-backwards", msg, d) |
| 266 | |
| 267 | pkginfo = PackageInfo(pkg) |
| 268 | # Apparently the version can be different on a per-package basis (see Python) |
| 269 | pkginfo.pe = pkgdata.get('PE', '0') |
| 270 | pkginfo.pv = pkgdata['PV'] |
| 271 | pkginfo.pr = pkgdata['PR'] |
| 272 | pkginfo.pkg = pkgdata['PKG'] |
| 273 | pkginfo.pkge = pkge |
| 274 | pkginfo.pkgv = pkgv |
| 275 | pkginfo.pkgr = pkgr |
| 276 | pkginfo.rprovides = sortpkglist(oe.utils.squashspaces(pkgdata.get('RPROVIDES', ""))) |
| 277 | pkginfo.rdepends = sortpkglist(oe.utils.squashspaces(pkgdata.get('RDEPENDS', ""))) |
| 278 | pkginfo.rrecommends = sortpkglist(oe.utils.squashspaces(pkgdata.get('RRECOMMENDS', ""))) |
| 279 | pkginfo.rsuggests = sortpkglist(oe.utils.squashspaces(pkgdata.get('RSUGGESTS', ""))) |
| 280 | pkginfo.rreplaces = sortpkglist(oe.utils.squashspaces(pkgdata.get('RREPLACES', ""))) |
| 281 | pkginfo.rconflicts = sortpkglist(oe.utils.squashspaces(pkgdata.get('RCONFLICTS', ""))) |
| 282 | pkginfo.files = oe.utils.squashspaces(pkgdata.get('FILES', "")) |
| 283 | for filevar in pkginfo.filevars: |
| 284 | pkginfo.filevars[filevar] = pkgdata.get(filevar, "") |
| 285 | |
| 286 | # Gather information about packaged files |
| 287 | val = pkgdata.get('FILES_INFO', '') |
| 288 | dictval = json.loads(val) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 289 | filelist = list(dictval.keys()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 290 | filelist.sort() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 291 | pkginfo.filelist = " ".join([shlex.quote(x) for x in filelist]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 292 | |
| 293 | pkginfo.size = int(pkgdata['PKGSIZE']) |
| 294 | |
| 295 | write_pkghistory(pkginfo, d) |
| 296 | |
| 297 | # Create files-in-<package-name>.txt files containing a list of files of each recipe's package |
| 298 | bb.build.exec_func("buildhistory_list_pkg_files", d) |
| 299 | } |
| 300 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 301 | python buildhistory_emit_outputsigs() { |
| 302 | if not "task" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): |
| 303 | return |
| 304 | |
| 305 | import hashlib |
| 306 | |
| 307 | taskoutdir = os.path.join(d.getVar('BUILDHISTORY_DIR'), 'task', 'output') |
| 308 | bb.utils.mkdirhier(taskoutdir) |
| 309 | currenttask = d.getVar('BB_CURRENTTASK') |
| 310 | pn = d.getVar('PN') |
| 311 | taskfile = os.path.join(taskoutdir, '%s.%s' % (pn, currenttask)) |
| 312 | |
| 313 | cwd = os.getcwd() |
| 314 | filesigs = {} |
| 315 | for root, _, files in os.walk(cwd): |
| 316 | for fname in files: |
| 317 | if fname == 'fixmepath': |
| 318 | continue |
| 319 | fullpath = os.path.join(root, fname) |
| 320 | try: |
| 321 | if os.path.islink(fullpath): |
| 322 | sha256 = hashlib.sha256(os.readlink(fullpath).encode('utf-8')).hexdigest() |
| 323 | elif os.path.isfile(fullpath): |
| 324 | sha256 = bb.utils.sha256_file(fullpath) |
| 325 | else: |
| 326 | continue |
| 327 | except OSError: |
| 328 | bb.warn('buildhistory: unable to read %s to get output signature' % fullpath) |
| 329 | continue |
| 330 | filesigs[os.path.relpath(fullpath, cwd)] = sha256 |
| 331 | with open(taskfile, 'w') as f: |
| 332 | for fpath, fsig in sorted(filesigs.items(), key=lambda item: item[0]): |
| 333 | f.write('%s %s\n' % (fpath, fsig)) |
| 334 | } |
| 335 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 336 | |
| 337 | def write_recipehistory(rcpinfo, d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 338 | bb.debug(2, "Writing recipe history") |
| 339 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 340 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 341 | |
| 342 | infofile = os.path.join(pkghistdir, "latest") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 343 | with open(infofile, "w") as f: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 344 | if rcpinfo.pe != "0": |
| 345 | f.write(u"PE = %s\n" % rcpinfo.pe) |
| 346 | f.write(u"PV = %s\n" % rcpinfo.pv) |
| 347 | f.write(u"PR = %s\n" % rcpinfo.pr) |
| 348 | f.write(u"DEPENDS = %s\n" % rcpinfo.depends) |
| 349 | f.write(u"PACKAGES = %s\n" % rcpinfo.packages) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 350 | f.write(u"LAYER = %s\n" % rcpinfo.layer) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 351 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 352 | write_latest_srcrev(d, pkghistdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 353 | |
| 354 | def write_pkghistory(pkginfo, d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 355 | bb.debug(2, "Writing package history for package %s" % pkginfo.name) |
| 356 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 357 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 358 | |
| 359 | pkgpath = os.path.join(pkghistdir, pkginfo.name) |
| 360 | if not os.path.exists(pkgpath): |
| 361 | bb.utils.mkdirhier(pkgpath) |
| 362 | |
| 363 | infofile = os.path.join(pkgpath, "latest") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 364 | with open(infofile, "w") as f: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 365 | if pkginfo.pe != "0": |
| 366 | f.write(u"PE = %s\n" % pkginfo.pe) |
| 367 | f.write(u"PV = %s\n" % pkginfo.pv) |
| 368 | f.write(u"PR = %s\n" % pkginfo.pr) |
| 369 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 370 | if pkginfo.pkg != pkginfo.name: |
| 371 | f.write(u"PKG = %s\n" % pkginfo.pkg) |
| 372 | if pkginfo.pkge != pkginfo.pe: |
| 373 | f.write(u"PKGE = %s\n" % pkginfo.pkge) |
| 374 | if pkginfo.pkgv != pkginfo.pv: |
| 375 | f.write(u"PKGV = %s\n" % pkginfo.pkgv) |
| 376 | if pkginfo.pkgr != pkginfo.pr: |
| 377 | f.write(u"PKGR = %s\n" % pkginfo.pkgr) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 378 | f.write(u"RPROVIDES = %s\n" % pkginfo.rprovides) |
| 379 | f.write(u"RDEPENDS = %s\n" % pkginfo.rdepends) |
| 380 | f.write(u"RRECOMMENDS = %s\n" % pkginfo.rrecommends) |
| 381 | if pkginfo.rsuggests: |
| 382 | f.write(u"RSUGGESTS = %s\n" % pkginfo.rsuggests) |
| 383 | if pkginfo.rreplaces: |
| 384 | f.write(u"RREPLACES = %s\n" % pkginfo.rreplaces) |
| 385 | if pkginfo.rconflicts: |
| 386 | f.write(u"RCONFLICTS = %s\n" % pkginfo.rconflicts) |
| 387 | f.write(u"PKGSIZE = %d\n" % pkginfo.size) |
| 388 | f.write(u"FILES = %s\n" % pkginfo.files) |
| 389 | f.write(u"FILELIST = %s\n" % pkginfo.filelist) |
| 390 | |
| 391 | for filevar in pkginfo.filevars: |
| 392 | filevarpath = os.path.join(pkgpath, "latest.%s" % filevar) |
| 393 | val = pkginfo.filevars[filevar] |
| 394 | if val: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 395 | with open(filevarpath, "w") as f: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 396 | f.write(val) |
| 397 | else: |
| 398 | if os.path.exists(filevarpath): |
| 399 | os.unlink(filevarpath) |
| 400 | |
| 401 | # |
| 402 | # rootfs_type can be: image, sdk_target, sdk_host |
| 403 | # |
| 404 | def buildhistory_list_installed(d, rootfs_type="image"): |
| 405 | from oe.rootfs import image_list_installed_packages |
| 406 | from oe.sdk import sdk_list_installed_packages |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 407 | from oe.utils import format_pkg_list |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 408 | |
| 409 | process_list = [('file', 'bh_installed_pkgs.txt'),\ |
| 410 | ('deps', 'bh_installed_pkgs_deps.txt')] |
| 411 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 412 | if rootfs_type == "image": |
| 413 | pkgs = image_list_installed_packages(d) |
| 414 | else: |
| 415 | pkgs = sdk_list_installed_packages(d, rootfs_type == "sdk_target") |
| 416 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 417 | for output_type, output_file in process_list: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 418 | output_file_full = os.path.join(d.getVar('WORKDIR'), output_file) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 419 | |
| 420 | with open(output_file_full, 'w') as output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 421 | output.write(format_pkg_list(pkgs, output_type)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 422 | |
| 423 | python buildhistory_list_installed_image() { |
| 424 | buildhistory_list_installed(d) |
| 425 | } |
| 426 | |
| 427 | python buildhistory_list_installed_sdk_target() { |
| 428 | buildhistory_list_installed(d, "sdk_target") |
| 429 | } |
| 430 | |
| 431 | python buildhistory_list_installed_sdk_host() { |
| 432 | buildhistory_list_installed(d, "sdk_host") |
| 433 | } |
| 434 | |
| 435 | buildhistory_get_installed() { |
| 436 | mkdir -p $1 |
| 437 | |
| 438 | # Get list of installed packages |
| 439 | pkgcache="$1/installed-packages.tmp" |
| 440 | cat ${WORKDIR}/bh_installed_pkgs.txt | sort > $pkgcache && rm ${WORKDIR}/bh_installed_pkgs.txt |
| 441 | |
| 442 | cat $pkgcache | awk '{ print $1 }' > $1/installed-package-names.txt |
| 443 | if [ -s $pkgcache ] ; then |
| 444 | cat $pkgcache | awk '{ print $2 }' | xargs -n1 basename > $1/installed-packages.txt |
| 445 | else |
| 446 | printf "" > $1/installed-packages.txt |
| 447 | fi |
| 448 | |
| 449 | # Produce dependency graph |
| 450 | # First, quote each name to handle characters that cause issues for dot |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 451 | sed 's:\([^| ]*\):"\1":g' ${WORKDIR}/bh_installed_pkgs_deps.txt > $1/depends.tmp && |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 452 | rm ${WORKDIR}/bh_installed_pkgs_deps.txt |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 453 | # Remove lines with rpmlib(...) and config(...) dependencies, change the |
| 454 | # delimiter from pipe to "->", set the style for recommend lines and |
| 455 | # turn versioned dependencies into edge labels. |
| 456 | sed -i -e '/rpmlib(/d' \ |
| 457 | -e '/config(/d' \ |
| 458 | -e 's:|: -> :' \ |
| 459 | -e 's:"\[REC\]":[style=dotted]:' \ |
| 460 | -e 's:"\([<>=]\+\)" "\([^"]*\)":[label="\1 \2"]:' \ |
| 461 | $1/depends.tmp |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 462 | # Add header, sorted and de-duped contents and footer and then delete the temp file |
| 463 | printf "digraph depends {\n node [shape=plaintext]\n" > $1/depends.dot |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 464 | cat $1/depends.tmp | sort -u >> $1/depends.dot |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 465 | echo "}" >> $1/depends.dot |
| 466 | rm $1/depends.tmp |
| 467 | |
| 468 | # Produce installed package sizes list |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 469 | oe-pkgdata-util -p ${PKGDATA_DIR} read-value "PKGSIZE" -n -f $pkgcache > $1/installed-package-sizes.tmp |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 470 | cat $1/installed-package-sizes.tmp | awk '{print $2 "\tKiB\t" $1}' | sort -n -r > $1/installed-package-sizes.txt |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 471 | rm $1/installed-package-sizes.tmp |
| 472 | |
| 473 | # We're now done with the cache, delete it |
| 474 | rm $pkgcache |
| 475 | |
| 476 | if [ "$2" != "sdk" ] ; then |
| 477 | # Produce some cut-down graphs (for readability) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 478 | grep -v kernel-image $1/depends.dot | grep -v kernel-3 | grep -v kernel-4 > $1/depends-nokernel.dot |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 479 | grep -v libc6 $1/depends-nokernel.dot | grep -v libgcc > $1/depends-nokernel-nolibc.dot |
| 480 | grep -v update- $1/depends-nokernel-nolibc.dot > $1/depends-nokernel-nolibc-noupdate.dot |
| 481 | grep -v kernel-module $1/depends-nokernel-nolibc-noupdate.dot > $1/depends-nokernel-nolibc-noupdate-nomodules.dot |
| 482 | fi |
| 483 | |
| 484 | # add complementary package information |
| 485 | if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then |
| 486 | cp ${WORKDIR}/complementary_pkgs.txt $1 |
| 487 | fi |
| 488 | } |
| 489 | |
| 490 | buildhistory_get_image_installed() { |
| 491 | # Anything requiring the use of the packaging system should be done in here |
| 492 | # in case the packaging files are going to be removed for this image |
| 493 | |
| 494 | if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then |
| 495 | return |
| 496 | fi |
| 497 | |
| 498 | buildhistory_get_installed ${BUILDHISTORY_DIR_IMAGE} |
| 499 | } |
| 500 | |
| 501 | buildhistory_get_sdk_installed() { |
| 502 | # Anything requiring the use of the packaging system should be done in here |
| 503 | # in case the packaging files are going to be removed for this SDK |
| 504 | |
| 505 | if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'sdk', '1', '0', d)}" = "0" ] ; then |
| 506 | return |
| 507 | fi |
| 508 | |
| 509 | buildhistory_get_installed ${BUILDHISTORY_DIR_SDK}/$1 sdk |
| 510 | } |
| 511 | |
| 512 | buildhistory_get_sdk_installed_host() { |
| 513 | buildhistory_get_sdk_installed host |
| 514 | } |
| 515 | |
| 516 | buildhistory_get_sdk_installed_target() { |
| 517 | buildhistory_get_sdk_installed target |
| 518 | } |
| 519 | |
| 520 | buildhistory_list_files() { |
| 521 | # List the files in the specified directory, but exclude date/time etc. |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 522 | # This is somewhat messy, but handles where the size is not printed for device files under pseudo |
| 523 | ( cd $1 |
| 524 | find_cmd='find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n"' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 525 | if [ "$3" = "fakeroot" ] ; then |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 526 | eval ${FAKEROOTENV} ${FAKEROOTCMD} $find_cmd |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 527 | else |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 528 | eval $find_cmd |
| 529 | fi | sort -k5 | sed 's/ * -> $//' > $2 ) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | buildhistory_list_pkg_files() { |
| 533 | # Create individual files-in-package for each recipe's package |
| 534 | for pkgdir in $(find ${PKGDEST}/* -maxdepth 0 -type d); do |
| 535 | pkgname=$(basename $pkgdir) |
| 536 | outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname" |
| 537 | outfile="$outfolder/files-in-package.txt" |
| 538 | # Make sure the output folder exists so we can create the file |
| 539 | if [ ! -d $outfolder ] ; then |
| 540 | bbdebug 2 "Folder $outfolder does not exist, file $outfile not created" |
| 541 | continue |
| 542 | fi |
| 543 | buildhistory_list_files $pkgdir $outfile fakeroot |
| 544 | done |
| 545 | } |
| 546 | |
| 547 | buildhistory_get_imageinfo() { |
| 548 | if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then |
| 549 | return |
| 550 | fi |
| 551 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 552 | mkdir -p ${BUILDHISTORY_DIR_IMAGE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 553 | buildhistory_list_files ${IMAGE_ROOTFS} ${BUILDHISTORY_DIR_IMAGE}/files-in-image.txt |
| 554 | |
| 555 | # Collect files requested in BUILDHISTORY_IMAGE_FILES |
| 556 | rm -rf ${BUILDHISTORY_DIR_IMAGE}/image-files |
| 557 | for f in ${BUILDHISTORY_IMAGE_FILES}; do |
| 558 | if [ -f ${IMAGE_ROOTFS}/$f ] ; then |
| 559 | mkdir -p ${BUILDHISTORY_DIR_IMAGE}/image-files/`dirname $f` |
| 560 | cp ${IMAGE_ROOTFS}/$f ${BUILDHISTORY_DIR_IMAGE}/image-files/$f |
| 561 | fi |
| 562 | done |
| 563 | |
| 564 | # Record some machine-readable meta-information about the image |
| 565 | printf "" > ${BUILDHISTORY_DIR_IMAGE}/image-info.txt |
| 566 | cat >> ${BUILDHISTORY_DIR_IMAGE}/image-info.txt <<END |
| 567 | ${@buildhistory_get_imagevars(d)} |
| 568 | END |
| 569 | imagesize=`du -ks ${IMAGE_ROOTFS} | awk '{ print $1 }'` |
| 570 | echo "IMAGESIZE = $imagesize" >> ${BUILDHISTORY_DIR_IMAGE}/image-info.txt |
| 571 | |
| 572 | # Add some configuration information |
| 573 | echo "${MACHINE}: ${IMAGE_BASENAME} configured for ${DISTRO} ${DISTRO_VERSION}" > ${BUILDHISTORY_DIR_IMAGE}/build-id.txt |
| 574 | |
| 575 | cat >> ${BUILDHISTORY_DIR_IMAGE}/build-id.txt <<END |
| 576 | ${@buildhistory_get_build_id(d)} |
| 577 | END |
| 578 | } |
| 579 | |
| 580 | buildhistory_get_sdkinfo() { |
| 581 | if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'sdk', '1', '0', d)}" = "0" ] ; then |
| 582 | return |
| 583 | fi |
| 584 | |
| 585 | buildhistory_list_files ${SDK_OUTPUT} ${BUILDHISTORY_DIR_SDK}/files-in-sdk.txt |
| 586 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 587 | # Collect files requested in BUILDHISTORY_SDK_FILES |
| 588 | rm -rf ${BUILDHISTORY_DIR_SDK}/sdk-files |
| 589 | for f in ${BUILDHISTORY_SDK_FILES}; do |
| 590 | if [ -f ${SDK_OUTPUT}/${SDKPATH}/$f ] ; then |
| 591 | mkdir -p ${BUILDHISTORY_DIR_SDK}/sdk-files/`dirname $f` |
| 592 | cp ${SDK_OUTPUT}/${SDKPATH}/$f ${BUILDHISTORY_DIR_SDK}/sdk-files/$f |
| 593 | fi |
| 594 | done |
| 595 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 596 | # Record some machine-readable meta-information about the SDK |
| 597 | printf "" > ${BUILDHISTORY_DIR_SDK}/sdk-info.txt |
| 598 | cat >> ${BUILDHISTORY_DIR_SDK}/sdk-info.txt <<END |
| 599 | ${@buildhistory_get_sdkvars(d)} |
| 600 | END |
| 601 | sdksize=`du -ks ${SDK_OUTPUT} | awk '{ print $1 }'` |
| 602 | echo "SDKSIZE = $sdksize" >> ${BUILDHISTORY_DIR_SDK}/sdk-info.txt |
| 603 | } |
| 604 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 605 | python buildhistory_get_extra_sdkinfo() { |
| 606 | import operator |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 607 | from oe.sdk import get_extra_sdkinfo |
| 608 | |
| 609 | sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache') |
| 610 | extra_info = get_extra_sdkinfo(sstate_dir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 611 | |
| 612 | if d.getVar('BB_CURRENTTASK') == 'populate_sdk_ext' and \ |
| 613 | "sdk" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 614 | with open(d.expand('${BUILDHISTORY_DIR_SDK}/sstate-package-sizes.txt'), 'w') as f: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 615 | filesizes_sorted = sorted(extra_info['filesizes'].items(), key=operator.itemgetter(1, 0), reverse=True) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 616 | for fn, size in filesizes_sorted: |
| 617 | f.write('%10d KiB %s\n' % (size, fn)) |
| 618 | with open(d.expand('${BUILDHISTORY_DIR_SDK}/sstate-task-sizes.txt'), 'w') as f: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 619 | tasksizes_sorted = sorted(extra_info['tasksizes'].items(), key=operator.itemgetter(1, 0), reverse=True) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 620 | for task, size in tasksizes_sorted: |
| 621 | f.write('%10d KiB %s\n' % (size, task)) |
| 622 | } |
| 623 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 624 | # By using ROOTFS_POSTUNINSTALL_COMMAND we get in after uninstallation of |
| 625 | # unneeded packages but before the removal of packaging files |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 626 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_list_installed_image ;" |
| 627 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_get_image_installed ;" |
| 628 | ROOTFS_POSTUNINSTALL_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_image ;| buildhistory_get_image_installed ;" |
| 629 | ROOTFS_POSTUNINSTALL_COMMAND[vardepsexclude] += "buildhistory_list_installed_image buildhistory_get_image_installed" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 630 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 631 | IMAGE_POSTPROCESS_COMMAND += "buildhistory_get_imageinfo ;" |
| 632 | IMAGE_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_imageinfo ;" |
| 633 | IMAGE_POSTPROCESS_COMMAND[vardepsexclude] += "buildhistory_get_imageinfo" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 634 | |
| 635 | # We want these to be the last run so that we get called after complementary package installation |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 636 | POPULATE_SDK_POST_TARGET_COMMAND_append = " buildhistory_list_installed_sdk_target;" |
| 637 | POPULATE_SDK_POST_TARGET_COMMAND_append = " buildhistory_get_sdk_installed_target;" |
| 638 | POPULATE_SDK_POST_TARGET_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_target;| buildhistory_get_sdk_installed_target;" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 639 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 640 | POPULATE_SDK_POST_HOST_COMMAND_append = " buildhistory_list_installed_sdk_host;" |
| 641 | POPULATE_SDK_POST_HOST_COMMAND_append = " buildhistory_get_sdk_installed_host;" |
| 642 | POPULATE_SDK_POST_HOST_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_host;| buildhistory_get_sdk_installed_host;" |
| 643 | |
| 644 | SDK_POSTPROCESS_COMMAND_append = " buildhistory_get_sdkinfo ; buildhistory_get_extra_sdkinfo; " |
| 645 | SDK_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_sdkinfo ; buildhistory_get_extra_sdkinfo; " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 646 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 647 | python buildhistory_write_sigs() { |
| 648 | if not "task" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): |
| 649 | return |
| 650 | |
| 651 | # Create sigs file |
| 652 | if hasattr(bb.parse.siggen, 'dump_siglist'): |
| 653 | taskoutdir = os.path.join(d.getVar('BUILDHISTORY_DIR'), 'task') |
| 654 | bb.utils.mkdirhier(taskoutdir) |
| 655 | bb.parse.siggen.dump_siglist(os.path.join(taskoutdir, 'tasksigs.txt')) |
| 656 | } |
| 657 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 658 | def buildhistory_get_build_id(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 659 | if d.getVar('BB_WORKERCONTEXT') != '1': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 660 | return "" |
| 661 | localdata = bb.data.createCopy(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 662 | statuslines = [] |
| 663 | for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata): |
| 664 | g = globals() |
| 665 | if func not in g: |
| 666 | bb.warn("Build configuration function '%s' does not exist" % func) |
| 667 | else: |
| 668 | flines = g[func](localdata) |
| 669 | if flines: |
| 670 | statuslines.extend(flines) |
| 671 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 672 | statusheader = d.getVar('BUILDCFG_HEADER') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 673 | return('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) |
| 674 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 675 | def buildhistory_get_modified(path): |
| 676 | # copied from get_layer_git_status() in image-buildinfo.bbclass |
| 677 | import subprocess |
| 678 | try: |
| 679 | subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e; |
| 680 | git diff --quiet --no-ext-diff |
| 681 | git diff --quiet --no-ext-diff --cached""" % path, |
| 682 | shell=True, |
| 683 | stderr=subprocess.STDOUT) |
| 684 | return "" |
| 685 | except subprocess.CalledProcessError as ex: |
| 686 | # Silently treat errors as "modified", without checking for the |
| 687 | # (expected) return code 1 in a modified git repo. For example, we get |
| 688 | # output and a 129 return code when a layer isn't a git repo at all. |
| 689 | return " -- modified" |
| 690 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 691 | def buildhistory_get_metadata_revs(d): |
| 692 | # We want an easily machine-readable format here, so get_layers_branch_rev isn't quite what we want |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 693 | layers = (d.getVar("BBLAYERS") or "").split() |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 694 | medadata_revs = ["%-17s = %s:%s%s" % (os.path.basename(i), \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 695 | base_get_metadata_git_branch(i, None).strip(), \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 696 | base_get_metadata_git_revision(i, None), \ |
| 697 | buildhistory_get_modified(i)) \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 698 | for i in layers] |
| 699 | return '\n'.join(medadata_revs) |
| 700 | |
| 701 | def outputvars(vars, listvars, d): |
| 702 | vars = vars.split() |
| 703 | listvars = listvars.split() |
| 704 | ret = "" |
| 705 | for var in vars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 706 | value = d.getVar(var) or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 707 | if var in listvars: |
| 708 | # Squash out spaces |
| 709 | value = oe.utils.squashspaces(value) |
| 710 | ret += "%s = %s\n" % (var, value) |
| 711 | return ret.rstrip('\n') |
| 712 | |
| 713 | def buildhistory_get_imagevars(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 714 | if d.getVar('BB_WORKERCONTEXT') != '1': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 715 | return "" |
| 716 | imagevars = "DISTRO DISTRO_VERSION USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS NO_RECOMMENDATIONS PACKAGE_EXCLUDE ROOTFS_POSTPROCESS_COMMAND IMAGE_POSTPROCESS_COMMAND" |
| 717 | listvars = "USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS PACKAGE_EXCLUDE" |
| 718 | return outputvars(imagevars, listvars, d) |
| 719 | |
| 720 | def buildhistory_get_sdkvars(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 721 | if d.getVar('BB_WORKERCONTEXT') != '1': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 722 | return "" |
| 723 | sdkvars = "DISTRO DISTRO_VERSION SDK_NAME SDK_VERSION SDKMACHINE SDKIMAGE_FEATURES BAD_RECOMMENDATIONS NO_RECOMMENDATIONS PACKAGE_EXCLUDE" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 724 | if d.getVar('BB_CURRENTTASK') == 'populate_sdk_ext': |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 725 | # Extensible SDK uses some additional variables |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 726 | sdkvars += " SDK_LOCAL_CONF_WHITELIST SDK_LOCAL_CONF_BLACKLIST SDK_INHERIT_BLACKLIST SDK_UPDATE_URL SDK_EXT_TYPE SDK_RECRDEP_TASKS SDK_INCLUDE_PKGDATA SDK_INCLUDE_TOOLCHAIN" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 727 | listvars = "SDKIMAGE_FEATURES BAD_RECOMMENDATIONS PACKAGE_EXCLUDE SDK_LOCAL_CONF_WHITELIST SDK_LOCAL_CONF_BLACKLIST SDK_INHERIT_BLACKLIST" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 728 | return outputvars(sdkvars, listvars, d) |
| 729 | |
| 730 | |
| 731 | def buildhistory_get_cmdline(d): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 732 | argv = d.getVar('BB_CMDLINE', False) |
| 733 | if argv: |
| 734 | if argv[0].endswith('bin/bitbake'): |
| 735 | bincmd = 'bitbake' |
| 736 | else: |
| 737 | bincmd = argv[0] |
| 738 | return '%s %s' % (bincmd, ' '.join(argv[1:])) |
| 739 | return '' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 740 | |
| 741 | |
| 742 | buildhistory_single_commit() { |
| 743 | if [ "$3" = "" ] ; then |
| 744 | commitopts="${BUILDHISTORY_DIR}/ --allow-empty" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 745 | shortlogprefix="No changes: " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 746 | else |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 747 | commitopts="" |
| 748 | shortlogprefix="" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 749 | fi |
| 750 | if [ "${BUILDHISTORY_BUILD_FAILURES}" = "0" ] ; then |
| 751 | result="succeeded" |
| 752 | else |
| 753 | result="failed" |
| 754 | fi |
| 755 | case ${BUILDHISTORY_BUILD_INTERRUPTED} in |
| 756 | 1) |
| 757 | result="$result (interrupted)" |
| 758 | ;; |
| 759 | 2) |
| 760 | result="$result (force interrupted)" |
| 761 | ;; |
| 762 | esac |
| 763 | commitmsgfile=`mktemp` |
| 764 | cat > $commitmsgfile << END |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 765 | ${shortlogprefix}Build ${BUILDNAME} of ${DISTRO} ${DISTRO_VERSION} for machine ${MACHINE} on $2 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 766 | |
| 767 | cmd: $1 |
| 768 | |
| 769 | result: $result |
| 770 | |
| 771 | metadata revisions: |
| 772 | END |
| 773 | cat ${BUILDHISTORY_DIR}/metadata-revs >> $commitmsgfile |
| 774 | git commit $commitopts -F $commitmsgfile --author "${BUILDHISTORY_COMMIT_AUTHOR}" > /dev/null |
| 775 | rm $commitmsgfile |
| 776 | } |
| 777 | |
| 778 | buildhistory_commit() { |
| 779 | if [ ! -d ${BUILDHISTORY_DIR} ] ; then |
| 780 | # Code above that creates this dir never executed, so there can't be anything to commit |
| 781 | return |
| 782 | fi |
| 783 | |
| 784 | # Create a machine-readable list of metadata revisions for each layer |
| 785 | cat > ${BUILDHISTORY_DIR}/metadata-revs <<END |
| 786 | ${@buildhistory_get_metadata_revs(d)} |
| 787 | END |
| 788 | |
| 789 | ( cd ${BUILDHISTORY_DIR}/ |
| 790 | # Initialise the repo if necessary |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 791 | if [ ! -e .git ] ; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 792 | git init -q |
| 793 | else |
| 794 | git tag -f build-minus-3 build-minus-2 > /dev/null 2>&1 || true |
| 795 | git tag -f build-minus-2 build-minus-1 > /dev/null 2>&1 || true |
| 796 | git tag -f build-minus-1 > /dev/null 2>&1 || true |
| 797 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 798 | |
| 799 | check_git_config |
| 800 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 801 | # Check if there are new/changed files to commit (other than metadata-revs) |
| 802 | repostatus=`git status --porcelain | grep -v " metadata-revs$"` |
| 803 | HOSTNAME=`hostname 2>/dev/null || echo unknown` |
| 804 | CMDLINE="${@buildhistory_get_cmdline(d)}" |
| 805 | if [ "$repostatus" != "" ] ; then |
| 806 | git add -A . |
| 807 | # porcelain output looks like "?? packages/foo/bar" |
| 808 | # Ensure we commit metadata-revs with the first commit |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 809 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" dummy |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 810 | git gc --auto --quiet |
| 811 | else |
| 812 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" |
| 813 | fi |
| 814 | if [ "${BUILDHISTORY_PUSH_REPO}" != "" ] ; then |
| 815 | git push -q ${BUILDHISTORY_PUSH_REPO} |
| 816 | fi) || true |
| 817 | } |
| 818 | |
| 819 | python buildhistory_eventhandler() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 820 | if e.data.getVar('BUILDHISTORY_FEATURES').strip(): |
| 821 | reset = e.data.getVar("BUILDHISTORY_RESET") |
| 822 | olddir = e.data.getVar("BUILDHISTORY_OLD_DIR") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 823 | if isinstance(e, bb.event.BuildStarted): |
| 824 | if reset: |
| 825 | import shutil |
| 826 | # Clean up after potentially interrupted build. |
| 827 | if os.path.isdir(olddir): |
| 828 | shutil.rmtree(olddir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 829 | rootdir = e.data.getVar("BUILDHISTORY_DIR") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 830 | entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ] |
| 831 | bb.utils.mkdirhier(olddir) |
| 832 | for entry in entries: |
| 833 | os.rename(os.path.join(rootdir, entry), |
| 834 | os.path.join(olddir, entry)) |
| 835 | elif isinstance(e, bb.event.BuildCompleted): |
| 836 | if reset: |
| 837 | import shutil |
| 838 | shutil.rmtree(olddir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 839 | if e.data.getVar("BUILDHISTORY_COMMIT") == "1": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 840 | bb.note("Writing buildhistory") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 841 | bb.build.exec_func("buildhistory_write_sigs", d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 842 | localdata = bb.data.createCopy(e.data) |
| 843 | localdata.setVar('BUILDHISTORY_BUILD_FAILURES', str(e._failures)) |
| 844 | interrupted = getattr(e, '_interrupted', 0) |
| 845 | localdata.setVar('BUILDHISTORY_BUILD_INTERRUPTED', str(interrupted)) |
| 846 | bb.build.exec_func("buildhistory_commit", localdata) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 847 | else: |
| 848 | bb.note("No commit since BUILDHISTORY_COMMIT != '1'") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | addhandler buildhistory_eventhandler |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 852 | buildhistory_eventhandler[eventmask] = "bb.event.BuildCompleted bb.event.BuildStarted" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 853 | |
| 854 | |
| 855 | # FIXME this ought to be moved into the fetcher |
| 856 | def _get_srcrev_values(d): |
| 857 | """ |
| 858 | Return the version strings for the current recipe |
| 859 | """ |
| 860 | |
| 861 | scms = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 862 | fetcher = bb.fetch.Fetch(d.getVar('SRC_URI').split(), d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 863 | urldata = fetcher.ud |
| 864 | for u in urldata: |
| 865 | if urldata[u].method.supports_srcrev(): |
| 866 | scms.append(u) |
| 867 | |
| 868 | autoinc_templ = 'AUTOINC+' |
| 869 | dict_srcrevs = {} |
| 870 | dict_tag_srcrevs = {} |
| 871 | for scm in scms: |
| 872 | ud = urldata[scm] |
| 873 | for name in ud.names: |
| 874 | try: |
| 875 | rev = ud.method.sortable_revision(ud, d, name) |
| 876 | except TypeError: |
| 877 | # support old bitbake versions |
| 878 | rev = ud.method.sortable_revision(scm, ud, d, name) |
| 879 | # Clean this up when we next bump bitbake version |
| 880 | if type(rev) != str: |
| 881 | autoinc, rev = rev |
| 882 | elif rev.startswith(autoinc_templ): |
| 883 | rev = rev[len(autoinc_templ):] |
| 884 | dict_srcrevs[name] = rev |
| 885 | if 'tag' in ud.parm: |
| 886 | tag = ud.parm['tag']; |
| 887 | key = name+'_'+tag |
| 888 | dict_tag_srcrevs[key] = rev |
| 889 | return (dict_srcrevs, dict_tag_srcrevs) |
| 890 | |
| 891 | do_fetch[postfuncs] += "write_srcrev" |
| 892 | do_fetch[vardepsexclude] += "write_srcrev" |
| 893 | python write_srcrev() { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 894 | write_latest_srcrev(d, d.getVar('BUILDHISTORY_DIR_PACKAGE')) |
| 895 | } |
| 896 | |
| 897 | def write_latest_srcrev(d, pkghistdir): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 898 | srcrevfile = os.path.join(pkghistdir, 'latest_srcrev') |
| 899 | |
| 900 | srcrevs, tag_srcrevs = _get_srcrev_values(d) |
| 901 | if srcrevs: |
| 902 | if not os.path.exists(pkghistdir): |
| 903 | bb.utils.mkdirhier(pkghistdir) |
| 904 | old_tag_srcrevs = {} |
| 905 | if os.path.exists(srcrevfile): |
| 906 | with open(srcrevfile) as f: |
| 907 | for line in f: |
| 908 | if line.startswith('# tag_'): |
| 909 | key, value = line.split("=", 1) |
| 910 | key = key.replace('# tag_', '').strip() |
| 911 | value = value.replace('"', '').strip() |
| 912 | old_tag_srcrevs[key] = value |
| 913 | with open(srcrevfile, 'w') as f: |
| 914 | orig_srcrev = d.getVar('SRCREV', False) or 'INVALID' |
| 915 | if orig_srcrev != 'INVALID': |
| 916 | f.write('# SRCREV = "%s"\n' % orig_srcrev) |
| 917 | if len(srcrevs) > 1: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 918 | for name, srcrev in sorted(srcrevs.items()): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 919 | orig_srcrev = d.getVar('SRCREV_%s' % name, False) |
| 920 | if orig_srcrev: |
| 921 | f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev)) |
| 922 | f.write('SRCREV_%s = "%s"\n' % (name, srcrev)) |
| 923 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 924 | f.write('SRCREV = "%s"\n' % next(iter(srcrevs.values()))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 925 | if len(tag_srcrevs) > 0: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 926 | for name, srcrev in sorted(tag_srcrevs.items()): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 927 | f.write('# tag_%s = "%s"\n' % (name, srcrev)) |
| 928 | if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 929 | pkg = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 930 | bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev)) |
| 931 | |
| 932 | else: |
| 933 | if os.path.exists(srcrevfile): |
| 934 | os.remove(srcrevfile) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 935 | |
| 936 | do_testimage[postfuncs] += "write_ptest_result" |
| 937 | do_testimage[vardepsexclude] += "write_ptest_result" |
| 938 | |
| 939 | python write_ptest_result() { |
| 940 | write_latest_ptest_result(d, d.getVar('BUILDHISTORY_DIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 941 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 942 | |
| 943 | def write_latest_ptest_result(d, histdir): |
| 944 | import glob |
| 945 | import subprocess |
| 946 | test_log_dir = d.getVar('TEST_LOG_DIR') |
| 947 | input_ptest = os.path.join(test_log_dir, 'ptest_log') |
| 948 | output_ptest = os.path.join(histdir, 'ptest') |
| 949 | if os.path.exists(input_ptest): |
| 950 | try: |
| 951 | # Lock it avoid race issue |
| 952 | lock = bb.utils.lockfile(output_ptest + "/ptest.lock") |
| 953 | bb.utils.mkdirhier(output_ptest) |
| 954 | oe.path.copytree(input_ptest, output_ptest) |
| 955 | # Sort test result |
| 956 | for result in glob.glob('%s/pass.fail.*' % output_ptest): |
| 957 | bb.debug(1, 'Processing %s' % result) |
| 958 | cmd = ['sort', result, '-o', result] |
| 959 | bb.debug(1, 'Running %s' % cmd) |
| 960 | ret = subprocess.call(cmd) |
| 961 | if ret != 0: |
| 962 | bb.error('Failed to run %s!' % cmd) |
| 963 | finally: |
| 964 | bb.utils.unlockfile(lock) |