summaryrefslogtreecommitdiffstats
path: root/meta/classes/rm_work.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/rm_work.bbclass')
-rw-r--r--meta/classes/rm_work.bbclass99
1 files changed, 99 insertions, 0 deletions
diff --git a/meta/classes/rm_work.bbclass b/meta/classes/rm_work.bbclass
new file mode 100644
index 0000000..f0f6d18
--- /dev/null
+++ b/meta/classes/rm_work.bbclass
@@ -0,0 +1,99 @@
1#
2# Removes source after build
3#
4# To use it add that line to conf/local.conf:
5#
6# INHERIT += "rm_work"
7#
8# To inhibit rm_work for some recipes, specify them in RM_WORK_EXCLUDE.
9# For example, in conf/local.conf:
10#
11# RM_WORK_EXCLUDE += "icu-native icu busybox"
12#
13
14# Use the completion scheduler by default when rm_work is active
15# to try and reduce disk usage
16BB_SCHEDULER ?= "completion"
17
18RMWORK_ORIG_TASK := "${BB_DEFAULT_TASK}"
19BB_DEFAULT_TASK = "rm_work_all"
20
21do_rm_work () {
22 # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe.
23 for p in ${RM_WORK_EXCLUDE}; do
24 if [ "$p" = "${PN}" ]; then
25 bbnote "rm_work: Skipping ${PN} since it is in RM_WORK_EXCLUDE"
26 exit 0
27 fi
28 done
29
30 cd ${WORKDIR}
31 for dir in *
32 do
33 # Retain only logs and other files in temp, safely ignore
34 # failures of removing pseudo folers on NFS2/3 server.
35 if [ $dir = 'pseudo' ]; then
36 rm -rf $dir 2> /dev/null || true
37 elif [ $dir != 'temp' ]; then
38 rm -rf $dir
39 fi
40 done
41
42 # Need to add pseudo back or subsqeuent work in this workdir
43 # might fail since setscene may not rerun to recreate it
44 mkdir -p ${WORKDIR}/pseudo/
45
46 # Change normal stamps into setscene stamps as they better reflect the
47 # fact WORKDIR is now empty
48 # Also leave noexec stamps since setscene stamps don't cover them
49 cd `dirname ${STAMP}`
50 for i in `basename ${STAMP}`*
51 do
52 for j in ${SSTATETASKS}
53 do
54 case $i in
55 *do_setscene*)
56 break
57 ;;
58 *sigdata*)
59 i=dummy
60 break
61 ;;
62 *do_package_write*)
63 i=dummy
64 break
65 ;;
66 *do_build*)
67 i=dummy
68 break
69 ;;
70 # We remove do_package entirely, including any
71 # sstate version since otherwise we'd need to leave 'plaindirs' around
72 # such as 'packages' and 'packages-split' and these can be large. No end
73 # of chain tasks depend directly on do_package anymore.
74 *do_package|*do_package.*|*do_package_setscene.*)
75 rm -f $i;
76 i=dummy
77 break
78 ;;
79 *_setscene*)
80 i=dummy
81 break
82 ;;
83 *$j|*$j.*)
84 mv $i `echo $i | sed -e "s#${j}#${j}_setscene#"`
85 i=dummy
86 break
87 ;;
88 esac
89 done
90 rm -f $i
91 done
92}
93addtask rm_work after do_${RMWORK_ORIG_TASK}
94
95do_rm_work_all () {
96 :
97}
98do_rm_work_all[recrdeptask] = "do_rm_work"
99addtask rm_work_all after do_rm_work