1 python populate_staging_prehook () {
5 python populate_staging_posthook () {
9 packagedstaging_fastpath () {
13 def package_stagefile(file, d):
14 if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1":
15 destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1))
16 bb.mkdirhier(os.path.dirname(destfile))
17 #print "%s to %s" % (file, destfile)
18 bb.copyfile(file, destfile)
20 package_stagefile_shell() {
21 if [ "$PSTAGING_ACTIVE" = "1" ]; then
23 destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#`
24 destdir=`dirname $destfile`
26 cp -dp $srcfile $destfile
33 # This will remove empty directories so we can ignore them
34 rmdir "$src" 2> /dev/null || true
35 if [ -d "$src" ]; then
37 cp -fpPR "$src"/* "$dest"
41 sysroot_stage_libdir() {
47 las=$(find . -name \*.la -type f)
49 echo "Found la files: $las"
52 sed -e 's/^installed=yes$/installed=no/' \
53 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
54 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
57 sysroot_stage_dir $src $dest
60 sysroot_stage_dirs() {
64 sysroot_stage_dir $from${includedir} $to${STAGING_INCDIR}
65 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
66 sysroot_stage_dir $from${bindir} $to${STAGING_DIR_HOST}${bindir}
67 sysroot_stage_dir $from${sbindir} $to${STAGING_DIR_HOST}${sbindir}
68 sysroot_stage_dir $from${base_bindir} $to${STAGING_DIR_HOST}${base_bindir}
69 sysroot_stage_dir $from${base_sbindir} $to${STAGING_DIR_HOST}${base_sbindir}
70 sysroot_stage_dir $from${libexecdir} $to${STAGING_DIR_HOST}${libexecdir}
71 if [ "${prefix}/lib" != "${libdir}" ]; then
72 # python puts its files in here, make sure they are staged as well
73 autotools_stage_dir $from/${prefix}/lib $to${STAGING_DIR_HOST}${prefix}/lib
76 if [ -d $from${libdir} ]
78 sysroot_stage_libdir $from/${libdir} $to${STAGING_LIBDIR}
80 if [ -d $from${base_libdir} ]
82 sysroot_stage_libdir $from${base_libdir} $to${STAGING_DIR_HOST}${base_libdir}
84 sysroot_stage_dir $from${datadir} $to${STAGING_DATADIR}
85 sysroot_stage_dir $from${sysconfdir} $to${STAGING_ETCDIR}
89 sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR}
92 def is_legacy_staging(d):
93 stagefunc = bb.data.getVar('do_stage', d, True)
97 elif stagefunc.strip() == "autotools_stage_all":
99 elif stagefunc.strip() == "do_stage_native" and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1":
101 elif bb.data.getVar('NATIVE_INSTALL_WORKS', d, 1) == "1":
103 if bb.data.getVar('PSTAGE_BROKEN_DESTDIR', d, 1) == "1":
105 if bb.data.getVar('FORCE_LEGACY_STAGING', d, 1) == "1":
109 do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${bindir} ${STAGING_DIR_TARGET}/${libdir} \
110 ${STAGING_DIR_TARGET}/${includedir} \
111 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
112 ${STAGING_INCDIR_NATIVE} \
116 # Could be compile but populate_staging and do_install shouldn't run at the same time
117 addtask populate_staging after do_install before do_build
119 SYSROOT_PREPROCESS_FUNCS ?= ""
120 SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir/"
121 SYSROOT_LOCK = "${STAGING_DIR}/staging.lock"
123 python do_populate_staging () {
125 # if do_stage exists, we're legacy. In that case run the do_stage,
126 # modify the SYSROOT_DESTDIR variable and then run the staging preprocess
127 # functions against staging directly.
129 # Otherwise setup a destdir, copy the results from do_install
130 # and run the staging preprocess against that
132 pstageactive = (bb.data.getVar("PSTAGING_ACTIVE", d, True) == "1")
133 lockfile = bb.data.getVar("SYSROOT_LOCK", d, True)
134 stagefunc = bb.data.getVar('do_stage', d, True)
135 legacy = is_legacy_staging(d)
137 bb.data.setVar("SYSROOT_DESTDIR", "", d)
138 bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
141 file = open("%s/legacy-staging.log" % bb.data.getVar("TMPDIR", d, 1), "a")
142 file.write("%s\n" % bb.data.getVar("FILE", d, True))
147 if bb.data.getVarFlags('do_stage', d) is None:
148 bb.fatal("This recipe (%s) has a do_stage_prepend or do_stage_append and do_stage now doesn't exist. Please rename this to do_stage()" % bb.data.getVar("FILE", d, True))
149 lock = bb.utils.lockfile(lockfile)
150 bb.build.exec_func('populate_staging_prehook', d)
151 bb.build.exec_func('do_stage', d)
152 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
153 bb.build.exec_func(f, d)
154 bb.build.exec_func('populate_staging_posthook', d)
155 bb.utils.unlockfile(lock)
157 dest = bb.data.getVar('D', d, True)
158 sysrootdest = bb.data.expand('${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}', d)
159 bb.mkdirhier(sysrootdest)
161 bb.build.exec_func("sysroot_stage_all", d)
162 #os.system('cp -pPR %s/* %s/' % (dest, sysrootdest))
163 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
164 bb.build.exec_func(f, d)
165 bb.build.exec_func("packagedstaging_fastpath", d)
167 lock = bb.utils.lockfile(lockfile)
168 os.system(bb.data.expand('cp -pPR ${SYSROOT_DESTDIR}${TMPDIR}/* ${TMPDIR}/', d))
169 bb.utils.unlockfile(lock)
173 if is_legacy_staging(d):
174 bb.debug(1, "Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
175 if bb.data.getVarFlags('do_stage', d) is None:
176 bb.error("This recipe (%s) has a do_stage_prepend or do_stage_append and do_stage now doesn't exist. Please rename this to do_stage()" % bb.data.getVar("FILE", d, True))