summaryrefslogtreecommitdiff
path: root/meta/classes/packagedata.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@ted.(none)>2009-01-25 17:14:57 +0000
committerRichard Purdie <richard@ted.(none)>2009-02-05 23:54:11 +0000
commitc2c16bced84f488622467ae31e60aa07253b24cf (patch)
treeca3c4e1eedf70ae51c33f61a347f46ded6eba843 /meta/classes/packagedata.bbclass
parent0903f6a455ff194a49ebbdb6bf1a6c03eeb970a2 (diff)
downloadopenembedded-core-c2c16bced84f488622467ae31e60aa07253b24cf.tar.gz
openembedded-core-c2c16bced84f488622467ae31e60aa07253b24cf.tar.bz2
openembedded-core-c2c16bced84f488622467ae31e60aa07253b24cf.tar.xz
openembedded-core-c2c16bced84f488622467ae31e60aa07253b24cf.zip
base.bbclass: Move package metadata handling functions into their own class file
Diffstat (limited to 'meta/classes/packagedata.bbclass')
-rw-r--r--meta/classes/packagedata.bbclass82
1 files changed, 82 insertions, 0 deletions
diff --git a/meta/classes/packagedata.bbclass b/meta/classes/packagedata.bbclass
new file mode 100644
index 000000000..c9d64d6da
--- /dev/null
+++ b/meta/classes/packagedata.bbclass
@@ -0,0 +1,82 @@
+def packaged(pkg, d):
+ import os, bb
+ return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
+
+def read_pkgdatafile(fn):
+ pkgdata = {}
+
+ def decode(str):
+ import codecs
+ c = codecs.getdecoder("string_escape")
+ return c(str)[0]
+
+ import os
+ if os.access(fn, os.R_OK):
+ import re
+ f = file(fn, 'r')
+ lines = f.readlines()
+ f.close()
+ r = re.compile("([^:]+):\s*(.*)")
+ for l in lines:
+ m = r.match(l)
+ if m:
+ pkgdata[m.group(1)] = decode(m.group(2))
+
+ return pkgdata
+
+def get_subpkgedata_fn(pkg, d):
+ import bb, os
+ archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
+ archs.reverse()
+ pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
+ targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
+ for arch in archs:
+ fn = pkgdata + arch + targetdir + pkg
+ if os.path.exists(fn):
+ return fn
+ return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
+
+def has_subpkgdata(pkg, d):
+ import bb, os
+ return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
+
+def read_subpkgdata(pkg, d):
+ import bb
+ return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+
+def has_pkgdata(pn, d):
+ import bb, os
+ fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+ return os.access(fn, os.R_OK)
+
+def read_pkgdata(pn, d):
+ import bb
+ fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+ return read_pkgdatafile(fn)
+
+python read_subpackage_metadata () {
+ import bb
+ data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
+
+ for key in data.keys():
+ bb.data.setVar(key, data[key], d)
+
+ for pkg in bb.data.getVar('PACKAGES', d, 1).split():
+ sdata = read_subpkgdata(pkg, d)
+ for key in sdata.keys():
+ bb.data.setVar(key, sdata[key], d)
+}
+
+
+#
+# Collapse FOO_pkg variables into FOO
+#
+def read_subpkgdata_dict(pkg, d):
+ import bb
+ ret = {}
+ subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+ for var in subd:
+ newvar = var.replace("_" + pkg, "")
+ ret[newvar] = subd[var]
+ return ret
+
id='n273' href='#n273'>273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491