Indentation fixups, caught by python -t
[openembedded.git] / classes / packaged-staging.bbclass
blob09e86ae99ea4e3ae47fdaaef1c4c8f3830de6af8
2 # Populate builds using prebuilt packages where possible to speed up builds
3 # and allow staging to be reconstructed.
5 # To use it add that line to conf/local.conf:
7 # INHERIT += "packaged-staging"
12 # bitbake.conf set PSTAGING_ACTIVE = "0", this class sets to "1" if we're active
14 PSTAGE_PKGVERSION = "${PV}-${PR}"
15 PSTAGE_PKGARCH    = "${BUILD_SYS}"
16 PSTAGE_EXTRAPATH  ?= "/${OELAYOUT_ABI}/${DISTRO_PR}/"
17 PSTAGE_PKGPATH    = "${DISTRO}${PSTAGE_EXTRAPATH}"
18 PSTAGE_PKGPN      = "${@bb.data.expand('staging-${PN}-${MULTIMACH_ARCH}${TARGET_VENDOR}-${TARGET_OS}', d).replace('_', '-')}"
19 PSTAGE_PKGNAME    = "${PSTAGE_PKGPN}_${PSTAGE_PKGVERSION}_${PSTAGE_PKGARCH}.ipk"
20 PSTAGE_PKG        = "${PSTAGE_DIR}/${PSTAGE_PKGPATH}/${PSTAGE_PKGNAME}"
21 PSTAGE_WORKDIR   = "${TMPDIR}/pstage"
22 PSTAGE_SCAN_CMD ?= "find ${PSTAGE_TMPDIR_STAGE} \( -name "*.la" -o -name "*-config" \) -type f"
24 PSTAGE_NATIVEDEPENDS = "\
25     shasum-native \
26     stagemanager-native \
27     "
29 BB_STAMP_WHITELIST = "${PSTAGE_NATIVEDEPENDS}"
31 python () {
32     pstage_allowed = True
34     # These classes encode staging paths into the binary data so can only be
35     # reused if the path doesn't change/
36     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):
37         path = bb.data.getVar('PSTAGE_PKGPATH', d, 1)
38         path = path + bb.data.getVar('TMPDIR', d, 1).replace('/', '-')
39         bb.data.setVar('PSTAGE_PKGPATH', path, d)
40         scan_cmd = "grep -Irl ${STAGING_DIR} ${PSTAGE_TMPDIR_STAGE}"
41         bb.data.setVar('PSTAGE_SCAN_CMD', scan_cmd, d)
43     # PSTAGE_NATIVEDEPENDS lists the packages we need before we can use packaged 
44     # staging. There will always be some packages we depend on.
45     if bb.data.inherits_class('native', d):
46         pn = bb.data.getVar('PN', d, True)
47         nativedeps = bb.data.getVar('PSTAGE_NATIVEDEPENDS', d, True).split()
48         if pn in nativedeps:
49             pstage_allowed = False
51     # Images aren't of interest to us
52     if bb.data.inherits_class('image', d):
53         pstage_allowed = False
55     if bb.data.getVar('PSTAGING_DISABLED', d, True) == "1":
56         pstage_allowed = False
58     # Add task dependencies if we're active, otherwise mark packaged staging
59     # as inactive.
60     if pstage_allowed:
61         deps = bb.data.getVarFlag('do_setscene', 'depends', d) or ""
62         deps += " stagemanager-native:do_populate_sysroot"
63         bb.data.setVarFlag('do_setscene', 'depends', deps, d)
65         policy = bb.data.getVar("BB_STAMP_POLICY", d, True)
66         if policy == "whitelist" or policy == "full":
67            deps = bb.data.getVarFlag('do_setscene', 'recrdeptask', d) or ""
68            deps += " do_setscene"
69            bb.data.setVarFlag('do_setscene', 'recrdeptask', deps, d)
71         bb.data.setVar("PSTAGING_ACTIVE", "1", d)
72     else:
73         bb.data.setVar("PSTAGING_ACTIVE", "0", d)
76 PSTAGE_MACHCONFIG   = "${PSTAGE_WORKDIR}/opkg.conf"
78 PSTAGE_PKGMANAGER = "stage-manager-ipkg"
80 PSTAGE_BUILD_CMD        = "stage-manager-ipkg-build -o 0 -g 0"
81 PSTAGE_INSTALL_CMD      = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${TMPDIR} install"
82 PSTAGE_UPDATE_CMD       = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -o ${TMPDIR} update"
83 PSTAGE_REMOVE_CMD       = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${TMPDIR} remove"
84 PSTAGE_LIST_CMD         = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -o ${TMPDIR} list_installed"
86 PSTAGE_TMPDIR_STAGE     = "${WORKDIR}/staging-pkg"
88 def pstage_manualclean(srcname, destvarname, d):
89         src = os.path.join(bb.data.getVar('PSTAGE_TMPDIR_STAGE', d, True), srcname)
90         dest = bb.data.getVar(destvarname, d, True)
92         for walkroot, dirs, files in os.walk(src):
93                 bb.debug("rm %s" % walkroot)
94                 for file in files:
95                         # Avoid breaking the held lock
96                         if (file == "staging.lock"):
97                                 continue
98                         filepath = os.path.join(walkroot, file).replace(src, dest)
99                         oe.path.remove(filepath)
101 def pstage_set_pkgmanager(d):
102     path = bb.data.getVar("PATH", d, 1)
103     pkgmanager = bb.which(path, 'opkg-cl')
104     if pkgmanager == "":
105         pkgmanager = bb.which(path, 'ipkg-cl')
106     if pkgmanager != "":
107         bb.data.setVar("PSTAGE_PKGMANAGER", pkgmanager, d)
110 def pstage_cleanpackage(pkgname, d):
111         path = bb.data.getVar("PATH", d, 1)
112         pstage_set_pkgmanager(d)
113         list_cmd = bb.data.getVar("PSTAGE_LIST_CMD", d, True)
115         bb.debug(2, "Checking if staging package installed")
116         lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d))
117         ret = os.system("PATH=\"%s\" %s | grep %s" % (path, list_cmd, pkgname))
118         if ret == 0:
119                 bb.debug(1, "Uninstalling package from staging...")
120                 removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1)
121                 ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, pkgname))
122                 if ret != 0:
123                         bb.note("Failure removing staging package")
124         else:
125                 bb.debug(1, "Manually removing any installed files from staging...")
126                 pstage_manualclean("sysroots", "STAGING_DIR", d)
127                 pstage_manualclean("cross", "CROSS_DIR", d)
128                 pstage_manualclean("deploy", "DEPLOY_DIR", d)
130         bb.utils.unlockfile(lf)
132 do_clean_prepend() {
133         """
134         Clear the build and temp directories
135         """
137         removepkg = bb.data.expand("${PSTAGE_PKGPN}", d)
138         pstage_cleanpackage(removepkg, d)
140         stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
141         if os.path.exists(stagepkg):
142                 bb.note("Removing staging package %s" % base_path_out(stagepkg, d))
143         oe.path.remove(stagepkg)
144         oe.path.remove(stagepkg + ".md5")
147 staging_helper () {
148         # Assemble appropriate opkg.conf
149         conffile=${PSTAGE_MACHCONFIG}
150         mkdir -p ${PSTAGE_WORKDIR}/pstaging_lists
151         if [ ! -e $conffile ]; then
152                 ipkgarchs="${BUILD_SYS}"
153                 priority=1
154                 for arch in $ipkgarchs; do
155                         echo "arch $arch $priority" >> $conffile
156                         priority=$(expr $priority + 5)
157                 done
158                 echo "dest root /" >> $conffile
159         fi
160         if [ ! -e ${TMPDIR}${libdir_native}/opkg/info/ ]; then
161                 mkdir -p ${TMPDIR}${libdir_native}/opkg/info/
162         fi
163         if [ ! -e ${TMPDIR}${libdir_native}/ipkg/ ]; then
164                 ln -sf opkg/ ${TMPDIR}${libdir_native}/ipkg || true
165         fi
168 def staging_fetch(stagepkg, d):
169     import bb.fetch
171     # only try and fetch if the user has configured a mirror
172     if bb.data.getVar('PSTAGE_MIRROR', d) != "":
173         # Copy the data object and override DL_DIR and SRC_URI
174         pd = d.createCopy()
175         dldir = bb.data.expand("${PSTAGE_DIR}/${PSTAGE_PKGPATH}", pd)
176         mirror = bb.data.expand("${PSTAGE_MIRROR}/${PSTAGE_PKGPATH}/", pd)
177         srcuri = mirror + os.path.basename(stagepkg)
178         bb.data.setVar('DL_DIR', dldir, pd)
179         bb.data.setVar('SRC_URI', srcuri, pd)
181         # Try a fetch from the pstage mirror, if it fails just return and
182         # we will build the package
183         try:
184             bb.fetch.init([srcuri], pd)
185             bb.fetch.go(pd, [srcuri])
186         except:
187             return
189 PSTAGE_TASKS_COVERED = "fetch unpack munge patch configure qa_configure rig_locales compile sizecheck install deploy package populate_sysroot package_write_deb package_write_ipk package_write package_stage qa_staging"
191 SCENEFUNCS += "packagestage_scenefunc"
193 python packagestage_scenefunc () {
194     import glob
195     if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "0":
196         return
198     bb.build.exec_func("staging_helper", d)
200     removepkg = bb.data.expand("${PSTAGE_PKGPN}", d)
202     pstage_cleanpackage(removepkg, d)
204     stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
205     if not os.path.exists(stagepkg):
206         staging_fetch(stagepkg, d)
208     if os.path.exists(stagepkg):
209         path = bb.data.getVar("PATH", d, 1)
210         pstage_set_pkgmanager(d)
211         file = bb.data.getVar("FILE", d, True)
212         bb.debug(2, "Packaged staging active for %s\n" % file)
214         #
215         # Install the staging package somewhere temporarily so we can extract the stamp files
216         #
217         bb.mkdirhier(bb.data.expand("${WORKDIR}/tstage/${libdir_native}/opkg/info/ ", d))
218         cmd = bb.data.expand("${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${WORKDIR}/tstage install", d)
219         ret = os.system("PATH=\"%s\" %s %s" % (path, cmd, stagepkg))
220         if ret != 0:
221             bb.fatal("Couldn't install the staging package to a temp directory")
223         #
224         # Grab the staging lock now so that we don't have other threads try and
225         # validate or install based on these stamps being valid.  This is a
226         # potential issue for certain BB_STAMP_POLICY values and enough
227         # concurrent threads.
228         #
229         lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d))
231         #
232         # Copy the stamp files into the main stamps directoy
233         #
234         cmd = bb.data.expand("cp -dpR ${WORKDIR}/tstage/stamps/* ${TMPDIR}/stamps/", d)
235         ret = os.system(cmd)
236         if ret != 0:
237             bb.utils.unlockfile(lf)
238             bb.fatal("Couldn't copy the staging package stamp files")
240         #
241         # Iterate over the stamps seeing if they're valid. If we find any that
242         # are invalid or the task wasn't in the taskgraph, assume caution and 
243         # do a rebuild.
244         #
245         # FIXME - some tasks are safe to ignore in the task graph. e.g. package_write_*
246         stageok = True
247         taskscovered = bb.data.getVar("PSTAGE_TASKS_COVERED", d, True).split()
248         stamp = bb.data.getVar("STAMP", d, True)
249         for task in taskscovered:
250             task = 'do_' + task
251             stampfn = "%s.%s" % (stamp, task)
252             bb.debug(1, "Checking %s" % (stampfn))
253             if os.path.exists(stampfn):
254                 stageok = bb.runqueue.check_stamp_fn(file, task, d)
255                 bb.debug(1, "Result %s" % (stageok))
256                 if not stageok:
257                     bb.utils.unlockfile(lf)
258                     break
260         # Remove the stamps and files we added above
261         # FIXME - we should really only remove the stamps we added
262         for fname in glob.glob(stamp + '.*'):
263             oe.path.remove(fname)
265         oe.path.remove(bb.data.expand("${WORKDIR}/tstage", d))
266         if stageok:
267             bb.note("Staging package found, using it for %s." % file)
268             installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1)
269             ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg))
270             bb.utils.unlockfile(lf)
271             if ret != 0:
272                 bb.note("Failure installing prestage package")
274             bb.build.exec_func("staging_package_libtoolhack", d)
276             bb.build.make_stamp("do_stage_package_populated", d)
277         else:
278             bb.note("Staging package found but invalid for %s" % file)
281 packagestage_scenefunc[cleandirs] = "${PSTAGE_TMPDIR_STAGE}"
282 packagestage_scenefunc[dirs] = "${STAGING_DIR}"
284 addhandler packagedstage_stampfixing_eventhandler
285 python packagedstage_stampfixing_eventhandler() {
286     if bb.event.getName(e) == "StampUpdate":
287         taskscovered = bb.data.getVar("PSTAGE_TASKS_COVERED", e.data, 1).split()
288         for (fn, task) in e.targets:
289             # strip off 'do_'
290             task = task[3:]
291             if task in taskscovered:
292                 stamp = "%s.do_stage_package_populated" % e.stampPrefix[fn]
293                 if os.path.exists(stamp):
294                     # We're targetting a task which was skipped with packaged staging
295                     # so we need to remove the autogenerated stamps.
296                     for task in taskscovered:
297                         covered = "%s.do_%s" % (e.stampPrefix[fn], task)
298                         oe.path.remove(covered)
299                     oe.path.remove(stamp)
302 populate_sysroot_preamble () {
303         if [ "$PSTAGING_ACTIVE" = "1" ]; then
304                 stage-manager -p ${STAGING_DIR} -c ${PSTAGE_WORKDIR}/stamp-cache-staging -u || true
305                 stage-manager -p ${CROSS_DIR} -c ${PSTAGE_WORKDIR}/stamp-cache-cross -u || true
306         fi
309 populate_sysroot_postamble () {
310         if [ "$PSTAGING_ACTIVE" = "1" ]; then
311                 # list the packages currently installed in staging
312                 # ${PSTAGE_LIST_CMD} | awk '{print $1}' > ${PSTAGE_WORKDIR}/installed-list
314                 # exitcode == 5 is ok, it means the files change
315                 set +e
316                 stage-manager -p ${STAGING_DIR} -c ${PSTAGE_WORKDIR}/stamp-cache-staging -u -d ${PSTAGE_TMPDIR_STAGE}/sysroots
317                 exitcode=$?
318                 if [ "$exitcode" != "5" -a "$exitcode" != "0" ]; then
319                         exit $exitcode
320                 fi
321                 stage-manager -p ${CROSS_DIR} -c ${PSTAGE_WORKDIR}/stamp-cache-cross -u -d ${PSTAGE_TMPDIR_STAGE}/cross/${BASE_PACKAGE_ARCH}
322                 if [ "$exitcode" != "5" -a "$exitcode" != "0" ]; then
323                         exit $exitcode
324                 fi
325                 set -e
326         fi
329 packagedstaging_fastpath () {
330         if [ "$PSTAGING_ACTIVE" = "1" ]; then
331                 mkdir -p ${PSTAGE_TMPDIR_STAGE}/sysroots/
332                 mkdir -p ${PSTAGE_TMPDIR_STAGE}/cross/${BASE_PACKAGE_ARCH}/
333                 cp -fpPR ${SYSROOT_DESTDIR}/${STAGING_DIR}/* ${PSTAGE_TMPDIR_STAGE}/sysroots/ || /bin/true
334                 cp -fpPR ${SYSROOT_DESTDIR}/${CROSS_DIR}/* ${PSTAGE_TMPDIR_STAGE}/cross/${BASE_PACKAGE_ARCH}/ || /bin/true
335         fi
338 do_populate_sysroot[dirs] =+ "${PSTAGE_DIR}"
339 python populate_sysroot_prehook() {
340     bb.build.exec_func("populate_sysroot_preamble", d)
343 python populate_sysroot_posthook() {
344     bb.build.exec_func("populate_sysroot_postamble", d)
348 staging_packager () {
350         mkdir -p ${PSTAGE_TMPDIR_STAGE}/CONTROL
351         mkdir -p ${PSTAGE_DIR}/${PSTAGE_PKGPATH}
353         echo "Package: ${PSTAGE_PKGPN}"         >  ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
354         echo "Version: ${PSTAGE_PKGVERSION}"    >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
355         echo "Description: ${DESCRIPTION}"      >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
356         echo "Section: ${SECTION}"              >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
357         echo "Priority: Optional"               >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
358         echo "Maintainer: ${MAINTAINER}"        >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
359         echo "Architecture: ${PSTAGE_PKGARCH}"  >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
360         
361         # Protect against empty SRC_URI
362         srcuri="${SRC_URI}"
363         if [ "$srcuri" == "" ]; then
364                 srcuri="OpenEmbedded"
365         fi
366         echo "Source: $srcuri"               >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
368         # Deal with libtool not supporting sysroots
369         # Need to remove hardcoded paths and fix these when we install the
370         # staging packages.
371         # Could someone please add sysroot support to libtool!
372         for i in `${PSTAGE_SCAN_CMD}` ; do \
373                 sed -i -e s:${STAGING_DIR}:FIXMESTAGINGDIR:g $i
374                 echo $i | sed -e 's:${PSTAGE_TMPDIR_STAGE}/::' >> ${PSTAGE_TMPDIR_STAGE}/sysroots/fixmepath
375         done
376         
377         ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${PSTAGE_DIR}/${PSTAGE_PKGPATH}
380 staging_package_installer () {
381         #${PSTAGE_INSTALL_CMD} ${PSTAGE_PKG}
383         STATUSFILE=${TMPDIR}${libdir_native}/opkg/status
384         echo "Package: ${PSTAGE_PKGPN}"        >> $STATUSFILE
385         echo "Version: ${PSTAGE_PKGVERSION}"   >> $STATUSFILE
386         echo "Status: install user installed"  >> $STATUSFILE
387         echo "Architecture: ${PSTAGE_PKGARCH}" >> $STATUSFILE
388         echo "" >> $STATUSFILE
390         CTRLFILE=${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.control
391         echo "Package: ${PSTAGE_PKGPN}"        > $CTRLFILE
392         echo "Version: ${PSTAGE_PKGVERSION}"   >> $CTRLFILE
393         echo "Architecture: ${PSTAGE_PKGARCH}" >> $CTRLFILE
395         cd ${PSTAGE_TMPDIR_STAGE}
396         find -type f | grep -v ./CONTROL | sed -e 's/^\.//' > ${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.list
399 python staging_package_libtoolhack () {
400         # Deal with libtool not supporting sysroots and add our new
401         # staging location
402         tmpdir = bb.data.getVar('TMPDIR', d, True)
403         staging = bb.data.getVar('STAGING_DIR', d, True)
404         fixmefn =  staging + "/fixmepath"
405         try:
406             fixmefd = open(fixmefn,"r")
407             fixmefiles = fixmefd.readlines()
408             fixmefd.close()
409             oe.path.remove(fixmefn)
410             for file in fixmefiles:
411                 os.system("sed -i -e s:FIXMESTAGINGDIR:%s:g %s" % (staging, tmpdir + '/' + file))
412         except IOError:
413             pass
416 python do_package_stage () {
417     if bb.data.getVar("PSTAGING_ACTIVE", d, 1) != "1":
418         return
420     #
421     # Handle deploy/ packages
422     #
423     bb.build.exec_func("read_subpackage_metadata", d)
424     stagepath = bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1)
425     tmpdir = bb.data.getVar("TMPDIR", d, True)
426     packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
427     if len(packages) > 0:
428         if bb.data.inherits_class('package_ipk', d):
429             ipkpath = bb.data.getVar('DEPLOY_DIR_IPK', d, True).replace(tmpdir, stagepath)
430         if bb.data.inherits_class('package_deb', d):
431             debpath = bb.data.getVar('DEPLOY_DIR_DEB', d, True).replace(tmpdir, stagepath)
432         if bb.data.inherits_class('package_rpm', d):
433             rpmpath = bb.data.getVar('DEPLOY_DIR_RPM', d, True).replace(tmpdir, stagepath)
435         for pkg in packages:
436             pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1)
437             if not pkgname:
438                 pkgname = pkg
439             arch = bb.data.getVar('PACKAGE_ARCH_%s' % pkg, d, 1)
440             if not arch:
441                 arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
442             pr = bb.data.getVar('PR_%s' % pkg, d, 1)
443             if not pr:
444                 pr = bb.data.getVar('PR', d, 1)
445             if not packaged(pkg, d):
446                 continue
447             if bb.data.inherits_class('package_ipk', d):
448                 srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "${DISTRO_PR}" + "_" + arch + ".ipk", d)
449                 srcfile = bb.data.expand("${DEPLOY_DIR_IPK}/" + arch + "/" + srcname, d)
450                 if os.path.exists(srcfile):
451                     destpath = ipkpath + "/" + arch + "/"
452                     bb.mkdirhier(destpath)
453                     print destpath
454                     bb.copyfile(srcfile, destpath + srcname)
456             if bb.data.inherits_class('package_deb', d):
457                 if arch == 'all':
458                     srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "${DISTRO_PR}" + "_all.deb", d)
459                 else:
460                     srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "${DISTRO_PR}" + "_${DPKG_ARCH}.deb", d)
461                 srcfile = bb.data.expand("${DEPLOY_DIR_DEB}/" + arch + "/" + srcname, d)
462                 if os.path.exists(srcfile):
463                     destpath = debpath + "/" + arch + "/" 
464                     bb.mkdirhier(destpath)
465                     bb.copyfile(srcfile, destpath + srcname)
467             if bb.data.inherits_class('package_rpm', d):
468                 version = bb.data.getVar('PV', d, 1)
469                 version = version.replace('-', '+')
470                 bb.data.setVar('RPMPV', version, d)
471                 srcname = bb.data.expand(pkgname + "-${RPMPV}-" + pr + "${DISTRO_PR}" + ".${TARGET_ARCH}.rpm", d)
472                 srcfile = bb.data.expand("${DEPLOY_DIR_RPM}/" + arch + "/" + srcname, d)
473                 if os.path.exists(srcfile):
474                     destpath = rpmpath + "/" + arch + "/" 
475                     bb.mkdirhier(destpath)
476                     bb.copyfile(srcfile, destpath + srcname)
479     #
480     # Handle stamps/ files
481     #
482     stampfn = bb.data.getVar("STAMP", d, True)
483     destdir = os.path.dirname(stampfn.replace(tmpdir, stagepath))
484     bb.mkdirhier(destdir)
485     # We need to include the package_stage stamp in the staging package so create one
486     bb.build.make_stamp("do_package_stage", d)
487     os.system("cp -dpR %s.do_* %s/" % (stampfn, destdir))
489     pstage_set_pkgmanager(d)
490     bb.build.exec_func("staging_helper", d)
491     bb.build.exec_func("staging_packager", d)
492     lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d))
493     bb.build.exec_func("staging_package_installer", d)
494     bb.utils.unlockfile(lf)
498 # Note an assumption here is that do_deploy runs before do_package_write/do_populate_sysroot
500 addtask package_stage after do_package_write do_populate_sysroot before do_build
502 do_package_stage_all () {
503         :
505 do_package_stage_all[recrdeptask] = "do_package_stage"
506 addtask package_stage_all after do_package_stage before do_build