diff options
| -rw-r--r-- | meta/classes/base.bbclass | 18 | ||||
| -rw-r--r-- | meta/classes/packaged-staging.bbclass | 456 |
2 files changed, 0 insertions, 474 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 3805dd3506..2fff8b4438 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
| @@ -70,24 +70,6 @@ oe_runmake() { | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | def package_stagefile(file, d): | ||
| 74 | |||
| 75 | if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1": | ||
| 76 | destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1)) | ||
| 77 | bb.mkdirhier(os.path.dirname(destfile)) | ||
| 78 | #print "%s to %s" % (file, destfile) | ||
| 79 | bb.copyfile(file, destfile) | ||
| 80 | |||
| 81 | package_stagefile_shell() { | ||
| 82 | if [ "$PSTAGING_ACTIVE" = "1" ]; then | ||
| 83 | srcfile=$1 | ||
| 84 | destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#` | ||
| 85 | destdir=`dirname $destfile` | ||
| 86 | mkdir -p $destdir | ||
| 87 | cp -dp $srcfile $destfile | ||
| 88 | fi | ||
| 89 | } | ||
| 90 | |||
| 91 | def base_dep_prepend(d): | 73 | def base_dep_prepend(d): |
| 92 | # | 74 | # |
| 93 | # Ideally this will check a flag so we will operate properly in | 75 | # Ideally this will check a flag so we will operate properly in |
diff --git a/meta/classes/packaged-staging.bbclass b/meta/classes/packaged-staging.bbclass index 1ea5718699..139597f9cb 100644 --- a/meta/classes/packaged-staging.bbclass +++ b/meta/classes/packaged-staging.bbclass | |||
| @@ -1,458 +1,2 @@ | |||
| 1 | # | ||
| 2 | # Populate builds using prebuilt packages where possible to speed up builds | ||
| 3 | # and allow staging to be reconstructed. | ||
| 4 | # | ||
| 5 | # To use it add that line to conf/local.conf: | ||
| 6 | # | ||
| 7 | # INHERIT += "packaged-staging" | ||
| 8 | # | ||
| 9 | 1 | ||
| 10 | 2 | ||
| 11 | # | ||
| 12 | # bitbake.conf set PSTAGING_ACTIVE = "0", this class sets to "1" if we're active | ||
| 13 | # | ||
| 14 | PSTAGE_PKGVERSION = "${PV}-${PR}" | ||
| 15 | PSTAGE_PKGARCH = "${TARGET_ARCH}" | ||
| 16 | PSTAGE_EXTRAPATH ?= "" | ||
| 17 | PSTAGE_PKGPATH = "${DISTRO}/${OELAYOUT_ABI}${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" | ||
| 23 | |||
| 24 | PSTAGE_NATIVEDEPENDS = "\ | ||
| 25 | shasum-native \ | ||
| 26 | " | ||
| 27 | |||
| 28 | BB_STAMP_WHITELIST = "${PSTAGE_NATIVEDEPENDS}" | ||
| 29 | |||
| 30 | python () { | ||
| 31 | if bb.data.inherits_class('native', d): | ||
| 32 | bb.data.setVar('PSTAGE_PKGARCH', bb.data.getVar('BUILD_ARCH', d), d) | ||
| 33 | elif bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d): | ||
| 34 | bb.data.setVar('PSTAGE_PKGARCH', bb.data.expand("${BUILD_ARCH}_${TARGET_ARCH}", d), d) | ||
| 35 | elif bb.data.inherits_class('nativesdk', d): | ||
| 36 | bb.data.setVar('PSTAGE_PKGARCH', bb.data.expand("${SDK_ARCH}", d), d) | ||
| 37 | elif bb.data.inherits_class('cross-canadian', d): | ||
| 38 | bb.data.setVar('PSTAGE_PKGARCH', bb.data.expand("${SDK_ARCH}_${TARGET_ARCH}", d), d) | ||
| 39 | |||
| 40 | pstage_allowed = True | ||
| 41 | |||
| 42 | # These classes encode staging paths into their scripts data so can only be | ||
| 43 | # reused if we manipulate the paths | ||
| 44 | 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): | ||
| 45 | scan_cmd = "grep -Irl ${STAGING_DIR} ${PSTAGE_TMPDIR_STAGE}" | ||
| 46 | bb.data.setVar('PSTAGE_SCAN_CMD', scan_cmd, d) | ||
| 47 | |||
| 48 | # PSTAGE_NATIVEDEPENDS lists the packages we need before we can use packaged | ||
| 49 | # staging. There will always be some packages we depend on. | ||
| 50 | if bb.data.inherits_class('native', d): | ||
| 51 | pn = bb.data.getVar('PN', d, True) | ||
| 52 | nativedeps = bb.data.getVar('PSTAGE_NATIVEDEPENDS', d, True).split() | ||
| 53 | if pn in nativedeps: | ||
| 54 | pstage_allowed = False | ||
| 55 | |||
| 56 | # Images aren't of interest to us | ||
| 57 | if bb.data.inherits_class('image', d): | ||
| 58 | pstage_allowed = False | ||
| 59 | |||
| 60 | if bb.data.getVar('PSTAGING_DISABLED', d, True) == "1": | ||
| 61 | pstage_allowed = False | ||
| 62 | |||
| 63 | # Add task dependencies if we're active, otherwise mark packaged staging | ||
| 64 | # as inactive. | ||
| 65 | if pstage_allowed: | ||
| 66 | policy = bb.data.getVar("BB_STAMP_POLICY", d, True) | ||
| 67 | if policy == "whitelist" or policy == "full": | ||
| 68 | deps = bb.data.getVarFlag('do_setscene', 'recrdeptask', d) or "" | ||
| 69 | deps += " do_setscene" | ||
| 70 | bb.data.setVarFlag('do_setscene', 'recrdeptask', deps, d) | ||
| 71 | |||
| 72 | bb.data.setVar("PSTAGING_ACTIVE", "1", d) | ||
| 73 | else: | ||
| 74 | bb.data.setVar("PSTAGING_ACTIVE", "0", d) | ||
| 75 | } | ||
| 76 | |||
| 77 | PSTAGE_MACHCONFIG = "${PSTAGE_WORKDIR}/${TARGET_ARCH}-opkg.conf" | ||
| 78 | |||
| 79 | PSTAGE_PKGMANAGER = "stage-manager-ipkg" | ||
| 80 | |||
| 81 | PSTAGE_BUILD_CMD = "stage-manager-ipkg-build -o 0 -g 0" | ||
| 82 | PSTAGE_INSTALL_CMD = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${TMPDIR} install" | ||
| 83 | PSTAGE_UPDATE_CMD = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -o ${TMPDIR} update" | ||
| 84 | PSTAGE_REMOVE_CMD = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${TMPDIR} remove" | ||
| 85 | PSTAGE_LIST_CMD = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -o ${TMPDIR} list_installed" | ||
| 86 | |||
| 87 | PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" | ||
| 88 | |||
| 89 | def pstage_manualclean(srcname, destvarname, d): | ||
| 90 | src = os.path.join(bb.data.getVar('PSTAGE_TMPDIR_STAGE', d, True), srcname) | ||
| 91 | dest = bb.data.getVar(destvarname, d, True) | ||
| 92 | |||
| 93 | for walkroot, dirs, files in os.walk(src): | ||
| 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 | os.system("rm %s 2> /dev/null" % filepath) | ||
| 100 | |||
| 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) | ||
| 108 | |||
| 109 | |||
| 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) | ||
| 114 | |||
| 115 | bb.note("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.note("Yes. 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.note("No. Manually removing any installed files") | ||
| 126 | pstage_manualclean("sysroots", "STAGING_DIR", d) | ||
| 127 | pstage_manualclean("deploy", "DEPLOY_DIR", d) | ||
| 128 | |||
| 129 | bb.utils.unlockfile(lf) | ||
| 130 | |||
| 131 | python do_clean_prepend() { | ||
| 132 | """ | ||
| 133 | Clear the build and temp directories | ||
| 134 | """ | ||
| 135 | |||
| 136 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) | ||
| 137 | pstage_cleanpackage(removepkg, d) | ||
| 138 | |||
| 139 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) | ||
| 140 | bb.note("Removing staging package %s" % stagepkg) | ||
| 141 | # Add a wildcard to the end of stagepkg to also get its md5 | ||
| 142 | # if it's a fetched package | ||
| 143 | os.system('rm -rf ' + stagepkg + '*') | ||
| 144 | } | ||
| 145 | |||
| 146 | staging_helper () { | ||
| 147 | # Assemble appropriate opkg.conf for the target arch | ||
| 148 | conffile=${PSTAGE_MACHCONFIG} | ||
| 149 | mkdir -p ${PSTAGE_WORKDIR}/pstaging_lists | ||
| 150 | if [ ! -e $conffile ]; then | ||
| 151 | ipkgarchs="${TARGET_ARCH} ${BUILD_ARCH} ${BUILD_ARCH}_${TARGET_ARCH}" | ||
| 152 | priority=1 | ||
| 153 | for arch in $ipkgarchs; do | ||
| 154 | echo "arch $arch $priority" >> $conffile | ||
| 155 | priority=$(expr $priority + 5) | ||
| 156 | done | ||
| 157 | echo "dest root /" >> $conffile | ||
| 158 | fi | ||
| 159 | if [ ! -e ${TMPDIR}${libdir_native}/opkg/info/ ]; then | ||
| 160 | mkdir -p ${TMPDIR}${libdir_native}/opkg/info/ | ||
| 161 | fi | ||
| 162 | if [ ! -e ${TMPDIR}${libdir_native}/ipkg/ ]; then | ||
| 163 | ln -sf opkg/ ${TMPDIR}${libdir_native}/ipkg || true | ||
| 164 | fi | ||
| 165 | } | ||
| 166 | |||
| 167 | def staging_fetch(stagepkg, d): | ||
| 168 | import bb.fetch | ||
| 169 | |||
| 170 | # only try and fetch if the user has configured a mirror | ||
| 171 | if bb.data.getVar('PSTAGE_MIRROR', d) != "": | ||
| 172 | # Copy the data object and override DL_DIR and SRC_URI | ||
| 173 | pd = d.createCopy() | ||
| 174 | dldir = bb.data.expand("${PSTAGE_DIR}/${PSTAGE_PKGPATH}", pd) | ||
| 175 | mirror = bb.data.expand("${PSTAGE_MIRROR}/${PSTAGE_PKGPATH}/", pd) | ||
| 176 | srcuri = mirror + os.path.basename(stagepkg) | ||
| 177 | bb.data.setVar('DL_DIR', dldir, pd) | ||
| 178 | bb.data.setVar('SRC_URI', srcuri, pd) | ||
| 179 | |||
| 180 | # Try a fetch from the pstage mirror, if it fails just return and | ||
| 181 | # we will build the package | ||
| 182 | try: | ||
| 183 | bb.fetch.init([srcuri], pd) | ||
| 184 | bb.fetch.go(pd, [srcuri]) | ||
| 185 | except: | ||
| 186 | return | ||
| 187 | |||
| 188 | 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" | ||
| 189 | |||
| 190 | SCENEFUNCS += "packagestage_scenefunc" | ||
| 191 | |||
| 192 | python packagestage_scenefunc () { | ||
| 193 | if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "0": | ||
| 194 | return | ||
| 195 | |||
| 196 | bb.build.exec_func("staging_helper", d) | ||
| 197 | |||
| 198 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) | ||
| 199 | |||
| 200 | pstage_cleanpackage(removepkg, d) | ||
| 201 | |||
| 202 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) | ||
| 203 | if not os.path.exists(stagepkg): | ||
| 204 | staging_fetch(stagepkg, d) | ||
| 205 | |||
| 206 | if os.path.exists(stagepkg): | ||
| 207 | path = bb.data.getVar("PATH", d, 1) | ||
| 208 | pstage_set_pkgmanager(d) | ||
| 209 | file = bb.data.getVar("FILE", d, True) | ||
| 210 | bb.debug(2, "Packaged staging active for %s\n" % file) | ||
| 211 | |||
| 212 | # | ||
| 213 | # Install the staging package somewhere temporarily so we can extract the stamp files | ||
| 214 | # | ||
| 215 | bb.mkdirhier(bb.data.expand("${WORKDIR}/tstage/${libdir_native}/opkg/info/ ", d)) | ||
| 216 | cmd = bb.data.expand("${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${WORKDIR}/tstage install", d) | ||
| 217 | ret = os.system("PATH=\"%s\" %s %s" % (path, cmd, stagepkg)) | ||
| 218 | if ret != 0: | ||
| 219 | bb.fatal("Couldn't install the staging package to a temp directory") | ||
| 220 | |||
| 221 | # | ||
| 222 | # Copy the stamp files into the main stamps directoy | ||
| 223 | # | ||
| 224 | cmd = bb.data.expand("cp -dpR ${WORKDIR}/tstage/stamps/* ${TMPDIR}/stamps/", d) | ||
| 225 | ret = os.system(cmd) | ||
| 226 | if ret != 0: | ||
| 227 | bb.fatal("Couldn't copy the staging package stamp files") | ||
| 228 | |||
| 229 | # | ||
| 230 | # Iterate over the stamps seeing if they're valid. If we find any that | ||
| 231 | # are invalid or the task wasn't in the taskgraph, assume caution and | ||
| 232 | # do a rebuild. | ||
| 233 | # | ||
| 234 | # FIXME - some tasks are safe to ignore in the task graph. e.g. package_write_* | ||
| 235 | stageok = True | ||
| 236 | taskscovered = bb.data.getVar("PSTAGE_TASKS_COVERED", d, True).split() | ||
| 237 | stamp = bb.data.getVar("STAMP", d, True) | ||
| 238 | for task in taskscovered: | ||
| 239 | task = 'do_' + task | ||
| 240 | stampfn = "%s.%s" % (stamp, task) | ||
| 241 | bb.debug(1, "Checking %s" % (stampfn)) | ||
| 242 | if os.path.exists(stampfn): | ||
| 243 | stageok = bb.runqueue.check_stamp_fn(file, task, d) | ||
| 244 | bb.debug(1, "Result %s" % (stageok)) | ||
| 245 | if not stageok: | ||
| 246 | break | ||
| 247 | |||
| 248 | # Remove the stamps and files we added above | ||
| 249 | # FIXME - we should really only remove the stamps we added | ||
| 250 | os.system('rm -f ' + stamp + '.*') | ||
| 251 | os.system(bb.data.expand("rm -rf ${WORKDIR}/tstage", d)) | ||
| 252 | |||
| 253 | if stageok: | ||
| 254 | bb.note("Staging package found, using it for %s." % file) | ||
| 255 | installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1) | ||
| 256 | lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d)) | ||
| 257 | ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg)) | ||
| 258 | bb.utils.unlockfile(lf) | ||
| 259 | if ret != 0: | ||
| 260 | bb.note("Failure installing prestage package") | ||
| 261 | |||
| 262 | bb.build.exec_func("staging_package_libtoolhack", d) | ||
| 263 | |||
| 264 | bb.build.make_stamp("do_stage_package_populated", d) | ||
| 265 | else: | ||
| 266 | bb.note("Staging package found but invalid for %s" % file) | ||
| 267 | |||
| 268 | } | ||
| 269 | packagestage_scenefunc[cleandirs] = "${PSTAGE_TMPDIR_STAGE}" | ||
| 270 | packagestage_scenefunc[dirs] = "${STAGING_DIR}" | ||
| 271 | |||
| 272 | addhandler packagedstage_stampfixing_eventhandler | ||
| 273 | python packagedstage_stampfixing_eventhandler() { | ||
| 274 | if bb.event.getName(e) == "StampUpdate": | ||
| 275 | taskscovered = bb.data.getVar("PSTAGE_TASKS_COVERED", e.data, 1).split() | ||
| 276 | for (fn, task) in e.targets: | ||
| 277 | # strip off 'do_' | ||
| 278 | task = task[3:] | ||
| 279 | if task in taskscovered: | ||
| 280 | stamp = "%s.do_stage_package_populated" % e.stampPrefix[fn] | ||
| 281 | if os.path.exists(stamp): | ||
| 282 | # We're targetting a task which was skipped with packaged staging | ||
| 283 | # so we need to remove the autogenerated stamps. | ||
| 284 | for task in taskscovered: | ||
| 285 | dir = "%s.do_%s" % (e.stampPrefix[fn], task) | ||
| 286 | os.system('rm -f ' + dir) | ||
| 287 | os.system('rm -f ' + stamp) | ||
| 288 | |||
| 289 | return NotHandled | ||
| 290 | } | ||
| 291 | |||
| 292 | packagedstaging_fastpath () { | ||
| 293 | if [ "$PSTAGING_ACTIVE" = "1" ]; then | ||
| 294 | mkdir -p ${PSTAGE_TMPDIR_STAGE}/sysroots/ | ||
| 295 | cp -fpPR ${SYSROOT_DESTDIR}/${STAGING_DIR}/* ${PSTAGE_TMPDIR_STAGE}/sysroots/ || /bin/true | ||
| 296 | fi | ||
| 297 | } | ||
| 298 | |||
| 299 | do_populate_sysroot[dirs] =+ "${PSTAGE_DIR}" | ||
| 300 | |||
| 301 | staging_packager () { | ||
| 302 | |||
| 303 | mkdir -p ${PSTAGE_TMPDIR_STAGE}/CONTROL | ||
| 304 | mkdir -p ${PSTAGE_DIR}/${PSTAGE_PKGPATH} | ||
| 305 | |||
| 306 | echo "Package: ${PSTAGE_PKGPN}" > ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 307 | echo "Version: ${PSTAGE_PKGVERSION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 308 | echo "Description: ${DESCRIPTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 309 | echo "Section: ${SECTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 310 | echo "Priority: Optional" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 311 | echo "Maintainer: ${MAINTAINER}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 312 | echo "Architecture: ${PSTAGE_PKGARCH}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 313 | |||
| 314 | # Protect against empty SRC_URI | ||
| 315 | srcuri="${SRC_URI}" | ||
| 316 | if [ "$srcuri" == "" ]; then | ||
| 317 | srcuri="OpenEmbedded" | ||
| 318 | fi | ||
| 319 | echo "Source: ${SRC_URI}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control | ||
| 320 | |||
| 321 | # Deal with libtool not supporting sysroots | ||
| 322 | # Need to remove hardcoded paths and fix these when we install the | ||
| 323 | # staging packages. | ||
| 324 | # Could someone please add sysroot support to libtool! | ||
| 325 | for i in `${PSTAGE_SCAN_CMD}` ; do \ | ||
| 326 | sed -i -e s:${STAGING_DIR}:FIXMESTAGINGDIR:g $i | ||
| 327 | echo $i | sed -e 's:${PSTAGE_TMPDIR_STAGE}/::' >> ${PSTAGE_TMPDIR_STAGE}/sysroots/fixmepath | ||
| 328 | done | ||
| 329 | |||
| 330 | ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${PSTAGE_DIR}/${PSTAGE_PKGPATH} | ||
| 331 | } | ||
| 332 | |||
| 333 | staging_package_installer () { | ||
| 334 | #${PSTAGE_INSTALL_CMD} ${PSTAGE_PKG} | ||
| 335 | |||
| 336 | STATUSFILE=${TMPDIR}${libdir_native}/opkg/status | ||
| 337 | echo "Package: ${PSTAGE_PKGPN}" >> $STATUSFILE | ||
| 338 | echo "Version: ${PSTAGE_PKGVERSION}" >> $STATUSFILE | ||
| 339 | echo "Status: install user installed" >> $STATUSFILE | ||
| 340 | echo "Architecture: ${PSTAGE_PKGARCH}" >> $STATUSFILE | ||
| 341 | echo "" >> $STATUSFILE | ||
| 342 | |||
| 343 | CTRLFILE=${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.control | ||
| 344 | echo "Package: ${PSTAGE_PKGPN}" > $CTRLFILE | ||
| 345 | echo "Version: ${PSTAGE_PKGVERSION}" >> $CTRLFILE | ||
| 346 | echo "Architecture: ${PSTAGE_PKGARCH}" >> $CTRLFILE | ||
| 347 | |||
| 348 | cd ${PSTAGE_TMPDIR_STAGE} | ||
| 349 | find -type f | grep -v ./CONTROL | sed -e 's/^\.//' > ${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.list | ||
| 350 | } | ||
| 351 | |||
| 352 | python staging_package_libtoolhack () { | ||
| 353 | # Deal with libtool not supporting sysroots and add our new | ||
| 354 | # staging location | ||
| 355 | tmpdir = bb.data.getVar('TMPDIR', d, True) | ||
| 356 | staging = bb.data.getVar('STAGING_DIR', d, True) | ||
| 357 | fixmefn = staging + "/fixmepath" | ||
| 358 | try: | ||
| 359 | fixmefd = open(fixmefn,"r") | ||
| 360 | fixmefiles = fixmefd.readlines() | ||
| 361 | fixmefd.close() | ||
| 362 | os.system('rm -f ' + fixmefn) | ||
| 363 | for file in fixmefiles: | ||
| 364 | os.system("sed -i -e s:FIXMESTAGINGDIR:%s:g %s" % (staging, tmpdir + '/' + file)) | ||
| 365 | except IOError: | ||
| 366 | pass | ||
| 367 | } | ||
| 368 | |||
| 369 | python do_package_stage () { | ||
| 370 | if bb.data.getVar("PSTAGING_ACTIVE", d, 1) != "1": | ||
| 371 | return | ||
| 372 | |||
| 373 | # | ||
| 374 | # Handle deploy/ packages | ||
| 375 | # | ||
| 376 | bb.build.exec_func("read_subpackage_metadata", d) | ||
| 377 | stagepath = bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1) | ||
| 378 | tmpdir = bb.data.getVar("TMPDIR", d, True) | ||
| 379 | packages = (bb.data.getVar('PACKAGES', d, 1) or "").split() | ||
| 380 | if len(packages) > 0: | ||
| 381 | if bb.data.inherits_class('package_ipk', d): | ||
| 382 | ipkpath = bb.data.getVar('DEPLOY_DIR_IPK', d, True).replace(tmpdir, stagepath) | ||
| 383 | if bb.data.inherits_class('package_deb', d): | ||
| 384 | debpath = bb.data.getVar('DEPLOY_DIR_DEB', d, True).replace(tmpdir, stagepath) | ||
| 385 | if bb.data.inherits_class('package_rpm', d): | ||
| 386 | rpmpath = bb.data.getVar('DEPLOY_DIR_RPM', d, True).replace(tmpdir, stagepath) | ||
| 387 | |||
| 388 | for pkg in packages: | ||
| 389 | pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) | ||
| 390 | if not pkgname: | ||
| 391 | pkgname = pkg | ||
| 392 | arch = bb.data.getVar('PACKAGE_ARCH_%s' % pkg, d, 1) | ||
| 393 | if not arch: | ||
| 394 | arch = bb.data.getVar('PACKAGE_ARCH', d, 1) | ||
| 395 | pr = bb.data.getVar('PR_%s' % pkg, d, 1) | ||
| 396 | if not pr: | ||
| 397 | pr = bb.data.getVar('PR', d, 1) | ||
| 398 | if not packaged(pkg, d): | ||
| 399 | continue | ||
| 400 | if bb.data.inherits_class('package_ipk', d): | ||
| 401 | srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "_" + arch + ".ipk", d) | ||
| 402 | srcfile = bb.data.expand("${DEPLOY_DIR_IPK}/" + arch + "/" + srcname, d) | ||
| 403 | if os.path.exists(srcfile): | ||
| 404 | destpath = ipkpath + "/" + arch + "/" | ||
| 405 | bb.mkdirhier(destpath) | ||
| 406 | bb.copyfile(srcfile, destpath + srcname) | ||
| 407 | |||
| 408 | if bb.data.inherits_class('package_deb', d): | ||
| 409 | if arch == 'all': | ||
| 410 | srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "_all.deb", d) | ||
| 411 | else: | ||
| 412 | srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "_${DPKG_ARCH}.deb", d) | ||
| 413 | srcfile = bb.data.expand("${DEPLOY_DIR_DEB}/" + arch + "/" + srcname, d) | ||
| 414 | if os.path.exists(srcfile): | ||
| 415 | destpath = debpath + "/" + arch + "/" | ||
| 416 | bb.mkdirhier(destpath) | ||
| 417 | bb.copyfile(srcfile, destpath + srcname) | ||
| 418 | |||
| 419 | if bb.data.inherits_class('package_rpm', d): | ||
| 420 | version = bb.data.getVar('PV', d, 1) | ||
| 421 | version = version.replace('-', '+') | ||
| 422 | bb.data.setVar('RPMPV', version, d) | ||
| 423 | srcname = bb.data.expand(pkgname + "-${RPMPV}-" + pr + ".${TARGET_ARCH}.rpm", d) | ||
| 424 | srcfile = bb.data.expand("${DEPLOY_DIR_RPM}/" + arch + "/" + srcname, d) | ||
| 425 | if os.path.exists(srcfile): | ||
| 426 | destpath = rpmpath + "/" + arch + "/" | ||
| 427 | bb.mkdirhier(destpath) | ||
| 428 | bb.copyfile(srcfile, destpath + srcname) | ||
| 429 | |||
| 430 | |||
| 431 | # | ||
| 432 | # Handle stamps/ files | ||
| 433 | # | ||
| 434 | stampfn = bb.data.getVar("STAMP", d, True) | ||
| 435 | destdir = os.path.dirname(stampfn.replace(tmpdir, stagepath)) | ||
| 436 | bb.mkdirhier(destdir) | ||
| 437 | # We need to include the package_stage stamp in the staging package so create one | ||
| 438 | bb.build.make_stamp("do_package_stage", d) | ||
| 439 | os.system("cp -dpR %s.do_* %s/" % (stampfn, destdir)) | ||
| 440 | |||
| 441 | pstage_set_pkgmanager(d) | ||
| 442 | bb.build.exec_func("staging_helper", d) | ||
| 443 | bb.build.exec_func("staging_packager", d) | ||
| 444 | lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d)) | ||
| 445 | bb.build.exec_func("staging_package_installer", d) | ||
| 446 | bb.utils.unlockfile(lf) | ||
| 447 | } | ||
| 448 | |||
| 449 | # | ||
| 450 | # Note an assumption here is that do_deploy runs before do_package_write/do_populate_sysroot | ||
| 451 | # | ||
| 452 | addtask package_stage after do_package_write do_populate_sysroot before do_build | ||
| 453 | |||
| 454 | do_package_stage_all () { | ||
| 455 | : | ||
| 456 | } | ||
| 457 | do_package_stage_all[recrdeptask] = "do_package_stage" | ||
| 458 | addtask package_stage_all after do_package_stage before do_build | ||
