summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sstate-cache-management.sh36
1 files changed, 23 insertions, 13 deletions
diff --git a/scripts/sstate-cache-management.sh b/scripts/sstate-cache-management.sh
index e2baf17d21..21ca47002b 100755
--- a/scripts/sstate-cache-management.sh
+++ b/scripts/sstate-cache-management.sh
@@ -181,23 +181,26 @@ remove_duplicated () {
181 # Add the qemu and native archs 181 # Add the qemu and native archs
182 # Use the "_" to substitute "-", e.g., x86-64 to x86_64 182 # Use the "_" to substitute "-", e.g., x86-64 to x86_64
183 # Sort to remove the duplicated ones 183 # Sort to remove the duplicated ones
184 all_archs=$(echo $all_archs $all_machines $(uname -m) \ 184 # Add allarch
185 all_archs=$(echo allarch $all_archs $all_machines $(uname -m) \
185 | sed -e 's/-/_/g' -e 's/ /\n/g' | sort -u) 186 | sed -e 's/-/_/g' -e 's/ /\n/g' | sort -u)
186 echo "Done" 187 echo "Done"
187 188
188 # Save all the sstate files in a file 189 # Save all the sstate files in a file
189 sstate_list=`mktemp` || exit 1 190 sstate_list=`mktemp` || exit 1
190 find $cache_dir -name 'sstate-*.tgz' >$sstate_list 191 find $cache_dir -name 'sstate:*:*:*:*:*:*:*.tgz' >$sstate_list
191 192
192 echo -n "Figuring out the suffixes in the sstate cache dir ... " 193 echo -n "Figuring out the suffixes in the sstate cache dir ... "
193 sstate_suffixes="`sed 's/.*_\([^_]*\)\.tgz$/\1/g' $sstate_list | sort -u`" 194 sstate_suffixes="`sed 's%.*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^_]*_\([^:]*\)\.tgz$%\1%g' $sstate_list | sort -u`"
194 echo "Done" 195 echo "Done"
195 echo "The following suffixes have been found in the cache dir:" 196 echo "The following suffixes have been found in the cache dir:"
196 echo $sstate_suffixes 197 echo $sstate_suffixes
197 198
198 echo -n "Figuring out the archs in the sstate cache dir ... " 199 echo -n "Figuring out the archs in the sstate cache dir ... "
200 # Using this SSTATE_PKGSPEC definition it's 6th colon separated field
201 # SSTATE_PKGSPEC = "sstate:${PN}:${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}:${PV}:${PR}:${SSTATE_PKGARCH}:${SSTATE_VERSION}:"
199 for arch in $all_archs; do 202 for arch in $all_archs; do
200 grep -q "\-$arch-" $sstate_list 203 grep -q ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tgz$" $sstate_list
201 [ $? -eq 0 ] && ava_archs="$ava_archs $arch" 204 [ $? -eq 0 ] && ava_archs="$ava_archs $arch"
202 done 205 done
203 echo "Done" 206 echo "Done"
@@ -210,21 +213,20 @@ remove_duplicated () {
210 213
211 for suffix in $sstate_suffixes; do 214 for suffix in $sstate_suffixes; do
212 # Save the file list to a file, some suffix's file may not exist 215 # Save the file list to a file, some suffix's file may not exist
213 grep "sstate-.*_$suffix.tgz" $sstate_list >$list_suffix 2>/dev/null 216 grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix.tgz" $sstate_list >$list_suffix 2>/dev/null
214 local deleted=0 217 local deleted=0
215 echo -n "Figuring out the sstate-xxx_$suffix.tgz ... " 218 echo -n "Figuring out the sstate:xxx_$suffix.tgz ... "
216 # There are at list 6 dashes (-) after arch, use this to avoid the 219 # Uniq BPNs
217 # greedy match of sed. 220 file_names=`for arch in $ava_archs ""; do
218 file_names=`for arch in $ava_archs; do 221 sed -ne "s%.*/sstate:\([^:]*\):[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tgz$%\1%p" $list_suffix
219 sed -ne 's#.*/\(sstate-.*\)-'"$arch"'-.*-.*-.*-.*-.*-.*#\1#p' $list_suffix
220 done | sort -u` 222 done | sort -u`
221 223
222 fn_tmp=`mktemp` || exit 1 224 fn_tmp=`mktemp` || exit 1
223 rm_list="$remove_listdir/sstate-xxx_$suffix" 225 rm_list="$remove_listdir/sstate:xxx_$suffix"
224 for fn in $file_names; do 226 for fn in $file_names; do
225 [ -z "$verbose" ] || echo "Analyzing $fn-xxx_$suffix.tgz" 227 [ -z "$verbose" ] || echo "Analyzing sstate:$fn-xxx_$suffix.tgz"
226 for arch in $ava_archs; do 228 for arch in $ava_archs; do
227 grep -h "/$fn-$arch-" $list_suffix >$fn_tmp 229 grep -h ".*/sstate:$fn:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tgz$" $list_suffix >$fn_tmp
228 if [ -s $fn_tmp ] ; then 230 if [ -s $fn_tmp ] ; then
229 [ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix:" && cat $fn_tmp 231 [ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix:" && cat $fn_tmp
230 # Use the modification time 232 # Use the modification time
@@ -259,6 +261,14 @@ remove_duplicated () {
259 echo "($deleted files will be removed)" 261 echo "($deleted files will be removed)"
260 let total_deleted=$total_deleted+$deleted 262 let total_deleted=$total_deleted+$deleted
261 done 263 done
264 deleted=0
265 rm_old_list=$remove_listdir/sstate-old-filenames
266 find $cache_dir -name 'sstate-*.tgz' >$rm_old_list
267 [ ! -s "$rm_old_list" ] || deleted=`cat $rm_old_list | wc -l`
268 [ -s "$rm_old_list" -a $debug -gt 0 ] && cat $rm_old_list
269 echo "($deleted files with old sstate-* filenames will be removed)"
270 let total_deleted=$total_deleted+$deleted
271
262 rm -f $list_suffix 272 rm -f $list_suffix
263 rm -f $sstate_list 273 rm -f $sstate_list
264 if [ $total_deleted -gt 0 ]; then 274 if [ $total_deleted -gt 0 ]; then