[OE-core] [PATCH v2 1/1] archive.bbclass: archive work directory

wenzong.fan at windriver.com wenzong.fan at windriver.com
Wed Jan 11 07:34:11 UTC 2012


From: Wenzong Fan <wenzong.fan at windriver.com>

Some legal departments believe a complete archive of the work directory
is required for certain license compliance issues. We could therefore
do with a class which archives up the work directories in each build and
provide them so those legal departments can be happy.

Implementations:

Add a new class named 'archive.bbclass' to provide task 'do_archive',
and get it called after 'do_patch' before 'do_configure'.

Following cases should be considered to the sources dirs:
1) The sources dir is under $WORKDIR:
Just archive sources and temp/run.* up.

2) The sources dir is outside of $WORKDIR, such as gcc:
Copy its sources and temp/run.* to a temporary dir and then archive
them up.

3) The sources dir is equal to $WORKDIR:
Just archive whole work dir up.

[YOCTO #1590]

Signed-off-by: Wenzong Fan <wenzong.fan at windriver.com>
---
 meta/classes/archive.bbclass |   49 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 meta/classes/archive.bbclass

diff --git a/meta/classes/archive.bbclass b/meta/classes/archive.bbclass
new file mode 100644
index 0000000..e529793
--- /dev/null
+++ b/meta/classes/archive.bbclass
@@ -0,0 +1,49 @@
+# Archive the patched sources and build scripts to assist in license
+# compliance by the end user or legal departments.
+
+ARCHIVE_DIR = "${TMPDIR}/archives/${MULTIMACH_TARGET_SYS}/"
+do_archive[dirs] = "${ARCHIVE_DIR}"
+
+archive_do_archive() {
+    # In mostly scenarios the $S is under $WORKDIR and has a separate
+    # dir for storing the sources; but sometimes we also put the same
+    # sources 'tmp/work-shared/' for sharing between different build.
+    if [ -d ${S} -a ${S} != ${WORKDIR} ]; then
+        sources_shared="0"
+
+        if echo ${S} | grep "${TMPDIR}/work-shared" > /dev/null; then
+            sources_shared="1"
+        fi
+
+        if [ x$sources_shared == "x1" ]; then
+            # Create temporary sources directory
+            mkdir -p ${PF}/temp
+            cp -r ${S} ${PF}
+            cp -r ${S}/../temp/* ${PF}/temp
+            cp -r ${WORKDIR}/temp/* ${PF}/temp
+            tarbase=`pwd`
+            sourcedir=`basename ${S}`
+        else
+            tarbase=`dirname ${WORKDIR}`
+            sourcedir=`echo ${S}|sed -e "s#${WORKDIR}/*##g"`
+        fi
+
+        tar -C $tarbase -cjf ${PF}.tar.bz2 ${PF}/$sourcedir \
+            ${PF}/temp --exclude log.do_*
+
+        # Remove the temporary sources directory
+        if [ x$sources_shared == "x1" -a -d ${PF} ]; then
+            rm -rf ${PF}
+        fi
+    fi
+
+    # Just archive whole build directory up when $S is equal to $WORKDIR
+    if [ -d ${S} -a ${S} == ${WORKDIR} ]; then
+        tarbase=`dirname ${WORKDIR}`
+        tar -C $tarbase -cjf ${PF}.tar.bz2 ${PF} --exclude log.do_*
+    fi
+}
+
+addtask do_archive after do_patch before do_configure
+
+EXPORT_FUNCTIONS do_archive
-- 
1.7.0.4





More information about the Openembedded-core mailing list