package.bbclass 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. #
  7. # Packaging process
  8. #
  9. # Executive summary: This class iterates over the functions listed in PACKAGEFUNCS
  10. # Taking D and splitting it up into the packages listed in PACKAGES, placing the
  11. # resulting output in PKGDEST.
  12. #
  13. # There are the following default steps but PACKAGEFUNCS can be extended:
  14. #
  15. # a) package_convert_pr_autoinc - convert AUTOINC in PKGV to ${PRSERV_PV_AUTOINC}
  16. #
  17. # b) perform_packagecopy - Copy D into PKGD
  18. #
  19. # c) package_do_split_locales - Split out the locale files, updates FILES and PACKAGES
  20. #
  21. # d) split_and_strip_files - split the files into runtime and debug and strip them.
  22. # Debug files include debug info split, and associated sources that end up in -dbg packages
  23. #
  24. # e) fixup_perms - Fix up permissions in the package before we split it.
  25. #
  26. # f) populate_packages - Split the files in PKGD into separate packages in PKGDEST/<pkgname>
  27. # Also triggers the binary stripping code to put files in -dbg packages.
  28. #
  29. # g) package_do_filedeps - Collect perfile run-time dependency metadata
  30. # The data is stores in FILER{PROVIDES,DEPENDS}_file_pkg variables with
  31. # a list of affected files in FILER{PROVIDES,DEPENDS}FLIST_pkg
  32. #
  33. # h) package_do_shlibs - Look at the shared libraries generated and autotmatically add any
  34. # dependencies found. Also stores the package name so anyone else using this library
  35. # knows which package to depend on.
  36. #
  37. # i) package_do_pkgconfig - Keep track of which packages need and provide which .pc files
  38. #
  39. # j) read_shlibdeps - Reads the stored shlibs information into the metadata
  40. #
  41. # k) package_depchains - Adds automatic dependencies to -dbg and -dev packages
  42. #
  43. # l) emit_pkgdata - saves the packaging data into PKGDATA_DIR for use in later
  44. # packaging steps
  45. inherit packagedata
  46. inherit chrpath
  47. inherit package_pkgdata
  48. inherit insane
  49. PKGD = "${WORKDIR}/package"
  50. PKGDEST = "${WORKDIR}/packages-split"
  51. LOCALE_SECTION ?= ''
  52. ALL_MULTILIB_PACKAGE_ARCHS = "${@all_multilib_tune_values(d, 'PACKAGE_ARCHS')}"
  53. # rpm is used for the per-file dependency identification
  54. # dwarfsrcfiles is used to determine the list of debug source files
  55. PACKAGE_DEPENDS += "rpm-native dwarfsrcfiles-native"
  56. # If your postinstall can execute at rootfs creation time rather than on
  57. # target but depends on a native/cross tool in order to execute, you need to
  58. # list that tool in PACKAGE_WRITE_DEPS. Target package dependencies belong
  59. # in the package dependencies as normal, this is just for native/cross support
  60. # tools at rootfs build time.
  61. PACKAGE_WRITE_DEPS ??= ""
  62. def legitimize_package_name(s):
  63. return oe.package.legitimize_package_name(s)
  64. def do_split_packages(d, root, file_regex, output_pattern, description, postinst=None, recursive=False, hook=None, extra_depends=None, aux_files_pattern=None, postrm=None, allow_dirs=False, prepend=False, match_path=False, aux_files_pattern_verbatim=None, allow_links=False, summary=None):
  65. """
  66. Used in .bb files to split up dynamically generated subpackages of a
  67. given package, usually plugins or modules.
  68. Arguments:
  69. root -- the path in which to search
  70. file_regex -- regular expression to match searched files. Use
  71. parentheses () to mark the part of this expression
  72. that should be used to derive the module name (to be
  73. substituted where %s is used in other function
  74. arguments as noted below)
  75. output_pattern -- pattern to use for the package names. Must include %s.
  76. description -- description to set for each package. Must include %s.
  77. postinst -- postinstall script to use for all packages (as a
  78. string)
  79. recursive -- True to perform a recursive search - default False
  80. hook -- a hook function to be called for every match. The
  81. function will be called with the following arguments
  82. (in the order listed):
  83. f: full path to the file/directory match
  84. pkg: the package name
  85. file_regex: as above
  86. output_pattern: as above
  87. modulename: the module name derived using file_regex
  88. extra_depends -- extra runtime dependencies (RDEPENDS) to be set for
  89. all packages. The default value of None causes a
  90. dependency on the main package (${PN}) - if you do
  91. not want this, pass '' for this parameter.
  92. aux_files_pattern -- extra item(s) to be added to FILES for each
  93. package. Can be a single string item or a list of
  94. strings for multiple items. Must include %s.
  95. postrm -- postrm script to use for all packages (as a string)
  96. allow_dirs -- True allow directories to be matched - default False
  97. prepend -- if True, prepend created packages to PACKAGES instead
  98. of the default False which appends them
  99. match_path -- match file_regex on the whole relative path to the
  100. root rather than just the file name
  101. aux_files_pattern_verbatim -- extra item(s) to be added to FILES for
  102. each package, using the actual derived module name
  103. rather than converting it to something legal for a
  104. package name. Can be a single string item or a list
  105. of strings for multiple items. Must include %s.
  106. allow_links -- True to allow symlinks to be matched - default False
  107. summary -- Summary to set for each package. Must include %s;
  108. defaults to description if not set.
  109. """
  110. dvar = d.getVar('PKGD')
  111. root = d.expand(root)
  112. output_pattern = d.expand(output_pattern)
  113. extra_depends = d.expand(extra_depends)
  114. # If the root directory doesn't exist, don't error out later but silently do
  115. # no splitting.
  116. if not os.path.exists(dvar + root):
  117. return []
  118. ml = d.getVar("MLPREFIX")
  119. if ml:
  120. if not output_pattern.startswith(ml):
  121. output_pattern = ml + output_pattern
  122. newdeps = []
  123. for dep in (extra_depends or "").split():
  124. if dep.startswith(ml):
  125. newdeps.append(dep)
  126. else:
  127. newdeps.append(ml + dep)
  128. if newdeps:
  129. extra_depends = " ".join(newdeps)
  130. packages = d.getVar('PACKAGES').split()
  131. split_packages = set()
  132. if postinst:
  133. postinst = '#!/bin/sh\n' + postinst + '\n'
  134. if postrm:
  135. postrm = '#!/bin/sh\n' + postrm + '\n'
  136. if not recursive:
  137. objs = os.listdir(dvar + root)
  138. else:
  139. objs = []
  140. for walkroot, dirs, files in os.walk(dvar + root):
  141. for file in files:
  142. relpath = os.path.join(walkroot, file).replace(dvar + root + '/', '', 1)
  143. if relpath:
  144. objs.append(relpath)
  145. if extra_depends == None:
  146. extra_depends = d.getVar("PN")
  147. if not summary:
  148. summary = description
  149. for o in sorted(objs):
  150. import re, stat
  151. if match_path:
  152. m = re.match(file_regex, o)
  153. else:
  154. m = re.match(file_regex, os.path.basename(o))
  155. if not m:
  156. continue
  157. f = os.path.join(dvar + root, o)
  158. mode = os.lstat(f).st_mode
  159. if not (stat.S_ISREG(mode) or (allow_links and stat.S_ISLNK(mode)) or (allow_dirs and stat.S_ISDIR(mode))):
  160. continue
  161. on = oe.package.legitimize_package_name(m.group(1))
  162. pkg = output_pattern % on
  163. split_packages.add(pkg)
  164. if not pkg in packages:
  165. if prepend:
  166. packages = [pkg] + packages
  167. else:
  168. packages.append(pkg)
  169. oldfiles = d.getVar('FILES:' + pkg)
  170. newfile = os.path.join(root, o)
  171. # These names will be passed through glob() so if the filename actually
  172. # contains * or ? (rare, but possible) we need to handle that specially
  173. newfile = newfile.replace('*', '[*]')
  174. newfile = newfile.replace('?', '[?]')
  175. if not oldfiles:
  176. the_files = [newfile]
  177. if aux_files_pattern:
  178. if type(aux_files_pattern) is list:
  179. for fp in aux_files_pattern:
  180. the_files.append(fp % on)
  181. else:
  182. the_files.append(aux_files_pattern % on)
  183. if aux_files_pattern_verbatim:
  184. if type(aux_files_pattern_verbatim) is list:
  185. for fp in aux_files_pattern_verbatim:
  186. the_files.append(fp % m.group(1))
  187. else:
  188. the_files.append(aux_files_pattern_verbatim % m.group(1))
  189. d.setVar('FILES:' + pkg, " ".join(the_files))
  190. else:
  191. d.setVar('FILES:' + pkg, oldfiles + " " + newfile)
  192. if extra_depends != '':
  193. d.appendVar('RDEPENDS:' + pkg, ' ' + extra_depends)
  194. if not d.getVar('DESCRIPTION:' + pkg):
  195. d.setVar('DESCRIPTION:' + pkg, description % on)
  196. if not d.getVar('SUMMARY:' + pkg):
  197. d.setVar('SUMMARY:' + pkg, summary % on)
  198. if postinst:
  199. d.setVar('pkg_postinst:' + pkg, postinst)
  200. if postrm:
  201. d.setVar('pkg_postrm:' + pkg, postrm)
  202. if callable(hook):
  203. hook(f, pkg, file_regex, output_pattern, m.group(1))
  204. d.setVar('PACKAGES', ' '.join(packages))
  205. return list(split_packages)
  206. PACKAGE_DEPENDS += "file-native"
  207. python () {
  208. if d.getVar('PACKAGES') != '':
  209. deps = ""
  210. for dep in (d.getVar('PACKAGE_DEPENDS') or "").split():
  211. deps += " %s:do_populate_sysroot" % dep
  212. if bb.utils.contains('DISTRO_FEATURES', 'minidebuginfo', True, False, d):
  213. deps += ' xz-native:do_populate_sysroot'
  214. d.appendVarFlag('do_package', 'depends', deps)
  215. # shlibs requires any DEPENDS to have already packaged for the *.list files
  216. d.appendVarFlag('do_package', 'deptask', " do_packagedata")
  217. }
  218. PRSERV_ACTIVE = "${@bool(d.getVar("PRSERV_HOST"))}"
  219. PRSERV_ACTIVE[vardepvalue] = "${PRSERV_ACTIVE}"
  220. package_get_auto_pr[vardepsexclude] = "BB_TASKDEPDATA"
  221. package_get_auto_pr[vardeps] += "PRSERV_ACTIVE"
  222. python package_get_auto_pr() {
  223. import oe.prservice
  224. def get_do_package_hash(pn):
  225. if d.getVar("BB_RUNTASK") != "do_package":
  226. taskdepdata = d.getVar("BB_TASKDEPDATA", False)
  227. for dep in taskdepdata:
  228. if taskdepdata[dep][1] == "do_package" and taskdepdata[dep][0] == pn:
  229. return taskdepdata[dep][6]
  230. return None
  231. # Support per recipe PRSERV_HOST
  232. pn = d.getVar('PN')
  233. host = d.getVar("PRSERV_HOST_" + pn)
  234. if not (host is None):
  235. d.setVar("PRSERV_HOST", host)
  236. pkgv = d.getVar("PKGV")
  237. # PR Server not active, handle AUTOINC
  238. if not d.getVar('PRSERV_HOST'):
  239. d.setVar("PRSERV_PV_AUTOINC", "0")
  240. return
  241. auto_pr = None
  242. pv = d.getVar("PV")
  243. version = d.getVar("PRAUTOINX")
  244. pkgarch = d.getVar("PACKAGE_ARCH")
  245. checksum = get_do_package_hash(pn)
  246. # If do_package isn't in the dependencies, we can't get the checksum...
  247. if not checksum:
  248. bb.warn('Task %s requested do_package unihash, but it was not available.' % d.getVar('BB_RUNTASK'))
  249. #taskdepdata = d.getVar("BB_TASKDEPDATA", False)
  250. #for dep in taskdepdata:
  251. # bb.warn('%s:%s = %s' % (taskdepdata[dep][0], taskdepdata[dep][1], taskdepdata[dep][6]))
  252. return
  253. if d.getVar('PRSERV_LOCKDOWN'):
  254. auto_pr = d.getVar('PRAUTO_' + version + '_' + pkgarch) or d.getVar('PRAUTO_' + version) or None
  255. if auto_pr is None:
  256. bb.fatal("Can NOT get PRAUTO from lockdown exported file")
  257. d.setVar('PRAUTO',str(auto_pr))
  258. return
  259. try:
  260. conn = oe.prservice.prserv_make_conn(d)
  261. if conn is not None:
  262. if "AUTOINC" in pkgv:
  263. srcpv = bb.fetch2.get_srcrev(d)
  264. base_ver = "AUTOINC-%s" % version[:version.find(srcpv)]
  265. value = conn.getPR(base_ver, pkgarch, srcpv)
  266. d.setVar("PRSERV_PV_AUTOINC", str(value))
  267. auto_pr = conn.getPR(version, pkgarch, checksum)
  268. conn.close()
  269. except Exception as e:
  270. bb.fatal("Can NOT get PRAUTO, exception %s" % str(e))
  271. if auto_pr is None:
  272. bb.fatal("Can NOT get PRAUTO from remote PR service")
  273. d.setVar('PRAUTO',str(auto_pr))
  274. }
  275. #
  276. # Package functions suitable for inclusion in PACKAGEFUNCS
  277. #
  278. python package_setup_pkgv() {
  279. pkgv = d.getVar("PKGV")
  280. # Expand SRCPV into PKGV if not present
  281. srcpv = bb.fetch.get_pkgv_string(d)
  282. if srcpv and "+" in pkgv:
  283. d.appendVar("PKGV", srcpv)
  284. pkgv = d.getVar("PKGV")
  285. # Adjust pkgv as necessary...
  286. if 'AUTOINC' in pkgv:
  287. d.setVar("PKGV", pkgv.replace("AUTOINC", "${PRSERV_PV_AUTOINC}"))
  288. }
  289. python package_convert_pr_autoinc() {
  290. # Change PRSERV_PV_AUTOINC and EXTENDPRAUTO usage to special values
  291. d.setVar('PRSERV_PV_AUTOINC', '@PRSERV_PV_AUTOINC@')
  292. d.setVar('EXTENDPRAUTO', '@EXTENDPRAUTO@')
  293. }
  294. LOCALEBASEPN ??= "${PN}"
  295. LOCALE_PATHS ?= "${datadir}/locale"
  296. python package_do_split_locales() {
  297. oe.package.split_locales(d)
  298. }
  299. python perform_packagecopy () {
  300. import subprocess
  301. import shutil
  302. dest = d.getVar('D')
  303. dvar = d.getVar('PKGD')
  304. # Start by package population by taking a copy of the installed
  305. # files to operate on
  306. # Preserve sparse files and hard links
  307. cmd = 'tar --exclude=./sysroot-only -cf - -C %s -p -S . | tar -xf - -C %s' % (dest, dvar)
  308. subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
  309. # replace RPATHs for the nativesdk binaries, to make them relocatable
  310. if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d):
  311. rpath_replace (dvar, d)
  312. }
  313. perform_packagecopy[cleandirs] = "${PKGD}"
  314. perform_packagecopy[dirs] = "${PKGD}"
  315. python populate_packages () {
  316. oe.package.populate_packages(d)
  317. }
  318. populate_packages[dirs] = "${D}"
  319. python package_fixsymlinks () {
  320. oe.package.process_fixsymlinks(pkgfiles, d)
  321. }
  322. python package_package_name_hook() {
  323. """
  324. A package_name_hook function can be used to rewrite the package names by
  325. changing PKG. For an example, see debian.bbclass.
  326. """
  327. pass
  328. }
  329. EXPORT_FUNCTIONS package_name_hook
  330. PKGDESTWORK = "${WORKDIR}/pkgdata"
  331. PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS RPROVIDES RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS SECTION PKG ALLOW_EMPTY FILES CONFFILES FILES_INFO PACKAGE_ADD_METADATA pkg_postinst pkg_postrm pkg_preinst pkg_prerm"
  332. python emit_pkgdata() {
  333. import oe.packagedata
  334. oe.packagedata.emit_pkgdata(pkgfiles, d)
  335. }
  336. emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides ${PKGDESTWORK}/extended"
  337. ldconfig_postinst_fragment() {
  338. if [ x"$D" = "x" ]; then
  339. if [ -x /sbin/ldconfig ]; then /sbin/ldconfig ; fi
  340. fi
  341. }
  342. RPMDEPS = "${STAGING_LIBDIR_NATIVE}/rpm/rpmdeps --alldeps --define '__font_provides %{nil}'"
  343. python package_do_filedeps() {
  344. oe.package.process_filedeps(pkgfiles, d)
  345. }
  346. SHLIBSDIRS = "${WORKDIR_PKGDATA}/${MLPREFIX}shlibs2"
  347. SHLIBSWORKDIR = "${PKGDESTWORK}/${MLPREFIX}shlibs2"
  348. python package_do_shlibs() {
  349. oe.package.process_shlibs(pkgfiles, d)
  350. }
  351. python package_do_pkgconfig () {
  352. oe.package.process_pkgconfig(pkgfiles, d)
  353. }
  354. python read_shlibdeps () {
  355. pkglibdeps = oe.package.read_libdep_files(d)
  356. packages = d.getVar('PACKAGES').split()
  357. for pkg in packages:
  358. rdepends = bb.utils.explode_dep_versions2(d.getVar('RDEPENDS:' + pkg) or "")
  359. for dep in sorted(pkglibdeps[pkg]):
  360. # Add the dep if it's not already there, or if no comparison is set
  361. if dep not in rdepends:
  362. rdepends[dep] = []
  363. for v in pkglibdeps[pkg][dep]:
  364. if v not in rdepends[dep]:
  365. rdepends[dep].append(v)
  366. d.setVar('RDEPENDS:' + pkg, bb.utils.join_deps(rdepends, commasep=False))
  367. }
  368. python package_depchains() {
  369. oe.package.process_depchains(pkgfiles, d)
  370. }
  371. # Since bitbake can't determine which variables are accessed during package
  372. # iteration, we need to list them here:
  373. PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm pkg_postinst_ontarget INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR USERADD_PARAM GROUPADD_PARAM CONFFILES SYSTEMD_SERVICE LICENSE SECTION pkg_preinst pkg_prerm RREPLACES GROUPMEMS_PARAM SYSTEMD_AUTO_ENABLE SKIP_FILEDEPS PRIVATE_LIBS PACKAGE_ADD_METADATA"
  374. def gen_packagevar(d, pkgvars="PACKAGEVARS"):
  375. ret = []
  376. pkgs = (d.getVar("PACKAGES") or "").split()
  377. vars = (d.getVar(pkgvars) or "").split()
  378. for v in vars:
  379. ret.append(v)
  380. for p in pkgs:
  381. for v in vars:
  382. ret.append(v + ":" + p)
  383. return " ".join(ret)
  384. # Functions for setting up PKGD
  385. PACKAGE_PREPROCESS_FUNCS ?= ""
  386. # Functions which split PKGD up into separate packages
  387. PACKAGESPLITFUNCS ?= " \
  388. package_do_split_locales \
  389. populate_packages"
  390. # Functions which process metadata based on split packages
  391. PACKAGEFUNCS += " \
  392. package_fixsymlinks \
  393. package_name_hook \
  394. package_do_filedeps \
  395. package_do_shlibs \
  396. package_do_pkgconfig \
  397. read_shlibdeps \
  398. package_depchains \
  399. emit_pkgdata"
  400. python do_package () {
  401. # Change the following version to cause sstate to invalidate the package
  402. # cache. This is useful if an item this class depends on changes in a
  403. # way that the output of this class changes. rpmdeps is a good example
  404. # as any change to rpmdeps requires this to be rerun.
  405. # PACKAGE_BBCLASS_VERSION = "6"
  406. # Init cachedpath
  407. global cpath
  408. cpath = oe.cachedpath.CachedPath()
  409. ###########################################################################
  410. # Sanity test the setup
  411. ###########################################################################
  412. packages = (d.getVar('PACKAGES') or "").split()
  413. if len(packages) < 1:
  414. bb.debug(1, "No packages to build, skipping do_package")
  415. return
  416. workdir = d.getVar('WORKDIR')
  417. outdir = d.getVar('DEPLOY_DIR')
  418. dest = d.getVar('D')
  419. dvar = d.getVar('PKGD')
  420. pn = d.getVar('PN')
  421. if not workdir or not outdir or not dest or not dvar or not pn:
  422. msg = "WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package"
  423. oe.qa.handle_error("var-undefined", msg, d)
  424. return
  425. bb.build.exec_func("package_setup_pkgv", d)
  426. bb.build.exec_func("package_convert_pr_autoinc", d)
  427. # Check for conflict between renamed packages and existing ones
  428. # for each package in PACKAGES, check if it will be renamed to an existing one
  429. for p in packages:
  430. rename = d.getVar('PKG:%s' % p)
  431. if rename and rename in packages:
  432. bb.fatal('package "%s" is renamed to "%s" using PKG:%s, but package name already exists' % (p, rename, p))
  433. ###########################################################################
  434. # Optimisations
  435. ###########################################################################
  436. # Continually expanding complex expressions is inefficient, particularly
  437. # when we write to the datastore and invalidate the expansion cache. This
  438. # code pre-expands some frequently used variables
  439. def expandVar(x, d):
  440. d.setVar(x, d.getVar(x))
  441. for x in 'PN', 'PV', 'BPN', 'TARGET_SYS', 'EXTENDPRAUTO':
  442. expandVar(x, d)
  443. ###########################################################################
  444. # Setup PKGD (from D)
  445. ###########################################################################
  446. bb.build.exec_func("package_prepare_pkgdata", d)
  447. bb.build.exec_func("perform_packagecopy", d)
  448. for f in (d.getVar('PACKAGE_PREPROCESS_FUNCS') or '').split():
  449. bb.build.exec_func(f, d)
  450. oe.package.process_split_and_strip_files(d)
  451. oe.package.fixup_perms(d)
  452. ###########################################################################
  453. # Split up PKGD into PKGDEST
  454. ###########################################################################
  455. cpath = oe.cachedpath.CachedPath()
  456. for f in (d.getVar('PACKAGESPLITFUNCS') or '').split():
  457. bb.build.exec_func(f, d)
  458. ###########################################################################
  459. # Process PKGDEST
  460. ###########################################################################
  461. # Build global list of files in each split package
  462. global pkgfiles
  463. pkgfiles = {}
  464. packages = d.getVar('PACKAGES').split()
  465. pkgdest = d.getVar('PKGDEST')
  466. for pkg in packages:
  467. pkgfiles[pkg] = []
  468. for walkroot, dirs, files in cpath.walk(pkgdest + "/" + pkg):
  469. for file in files:
  470. pkgfiles[pkg].append(walkroot + os.sep + file)
  471. for f in (d.getVar('PACKAGEFUNCS') or '').split():
  472. bb.build.exec_func(f, d)
  473. oe.qa.exit_if_errors(d)
  474. }
  475. do_package[dirs] = "${SHLIBSWORKDIR} ${D}"
  476. do_package[vardeps] += "${PACKAGE_PREPROCESS_FUNCS} ${PACKAGESPLITFUNCS} ${PACKAGEFUNCS} ${@gen_packagevar(d)}"
  477. addtask package after do_install
  478. SSTATETASKS += "do_package"
  479. do_package[cleandirs] = "${PKGDEST} ${PKGDESTWORK}"
  480. do_package[sstate-plaindirs] = "${PKGD} ${PKGDEST} ${PKGDESTWORK}"
  481. do_package_setscene[dirs] = "${STAGING_DIR}"
  482. python do_package_setscene () {
  483. sstate_setscene(d)
  484. }
  485. addtask do_package_setscene
  486. # Copy from PKGDESTWORK to tempdirectory as tempdirectory can be cleaned at both
  487. # do_package_setscene and do_packagedata_setscene leading to races
  488. python do_packagedata () {
  489. bb.build.exec_func("package_setup_pkgv", d)
  490. bb.build.exec_func("package_get_auto_pr", d)
  491. src = d.expand("${PKGDESTWORK}")
  492. dest = d.expand("${WORKDIR}/pkgdata-pdata-input")
  493. oe.path.copyhardlinktree(src, dest)
  494. bb.build.exec_func("packagedata_translate_pr_autoinc", d)
  495. }
  496. do_packagedata[cleandirs] += "${WORKDIR}/pkgdata-pdata-input"
  497. # Translate the EXTENDPRAUTO and AUTOINC to the final values
  498. packagedata_translate_pr_autoinc() {
  499. find ${WORKDIR}/pkgdata-pdata-input -type f | xargs --no-run-if-empty \
  500. sed -e 's,@PRSERV_PV_AUTOINC@,${PRSERV_PV_AUTOINC},g' \
  501. -e 's,@EXTENDPRAUTO@,${EXTENDPRAUTO},g' -i
  502. }
  503. addtask packagedata before do_build after do_package
  504. SSTATETASKS += "do_packagedata"
  505. do_packagedata[sstate-inputdirs] = "${WORKDIR}/pkgdata-pdata-input"
  506. do_packagedata[sstate-outputdirs] = "${PKGDATA_DIR}"
  507. do_packagedata[stamp-extra-info] = "${MACHINE_ARCH}"
  508. python do_packagedata_setscene () {
  509. sstate_setscene(d)
  510. }
  511. addtask do_packagedata_setscene