diff options
Diffstat (limited to 'scripts/sstate-cache-management.sh')
-rwxr-xr-x | scripts/sstate-cache-management.sh | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/scripts/sstate-cache-management.sh b/scripts/sstate-cache-management.sh index a4f66115e3..e55eb239f2 100755 --- a/scripts/sstate-cache-management.sh +++ b/scripts/sstate-cache-management.sh | |||
@@ -224,59 +224,60 @@ remove_duplicated () { | |||
224 | 224 | ||
225 | # Save the file list which needs to be removed | 225 | # Save the file list which needs to be removed |
226 | local remove_listdir=`mktemp -d` || exit 1 | 226 | local remove_listdir=`mktemp -d` || exit 1 |
227 | |||
228 | for suffix in $sstate_suffixes; do | 227 | for suffix in $sstate_suffixes; do |
229 | # Total number of files including .siginfo and .done files | 228 | # Total number of files including .siginfo and .done files |
230 | total_files_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix.*" $sstate_files_list | wc -l 2>/dev/null` | 229 | total_files_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tgz.*" $sstate_files_list | wc -l 2>/dev/null` |
231 | total_tgz_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix.*.tgz$" $sstate_files_list | wc -l 2>/dev/null` | 230 | total_tgz_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tgz$" $sstate_files_list | wc -l 2>/dev/null` |
232 | # Save the file list to a file, some suffix's file may not exist | 231 | # Save the file list to a file, some suffix's file may not exist |
233 | grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix.tgz$" $sstate_files_list >$list_suffix 2>/dev/null | 232 | grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tgz.*" $sstate_files_list >$list_suffix 2>/dev/null |
234 | local deleted_tgz=0 | 233 | local deleted_tgz=0 |
235 | local deleted_files=0 | 234 | local deleted_files=0 |
236 | echo -n "Figuring out the sstate:xxx_$suffix.tgz ... " | 235 | for ext in tgz tgz.siginfo tgz.done; do |
237 | # Uniq BPNs | 236 | echo "Figuring out the sstate:xxx_$suffix.$ext ... " |
238 | file_names=`for arch in $ava_archs ""; do | 237 | # Uniq BPNs |
239 | sed -ne "s%.*/sstate:\([^:]*\):[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tgz$%\1%p" $list_suffix | 238 | file_names=`for arch in $ava_archs ""; do |
240 | done | sort -u` | 239 | sed -ne "s%.*/sstate:\([^:]*\):[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.${ext}$%\1%p" $list_suffix |
241 | 240 | done | sort -u` | |
242 | fn_tmp=`mktemp` || exit 1 | 241 | |
243 | rm_list="$remove_listdir/sstate:xxx_$suffix" | 242 | fn_tmp=`mktemp` || exit 1 |
244 | for fn in $file_names; do | 243 | rm_list="$remove_listdir/sstate:xxx_$suffix" |
245 | [ -z "$verbose" ] || echo "Analyzing sstate:$fn-xxx_$suffix.tgz" | 244 | for fn in $file_names; do |
246 | for arch in $ava_archs ""; do | 245 | [ -z "$verbose" ] || echo "Analyzing sstate:$fn-xxx_$suffix.${ext}" |
247 | grep -h ".*/sstate:$fn:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tgz$" $list_suffix >$fn_tmp | 246 | for arch in $ava_archs ""; do |
248 | if [ -s $fn_tmp ] ; then | 247 | grep -h ".*/sstate:$fn:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.${ext}$" $list_suffix >$fn_tmp |
249 | [ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix:" && cat $fn_tmp | 248 | if [ -s $fn_tmp ] ; then |
250 | # Use the modification time | 249 | [ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix.${ext}:" && cat $fn_tmp |
251 | to_del=$(ls -t $(cat $fn_tmp) | sed -n '1!p') | 250 | # Use the modification time |
252 | [ $debug -gt 2 ] && echo "Considering to delete: $to_del" | 251 | to_del=$(ls -t $(cat $fn_tmp) | sed -n '1!p') |
253 | # The sstate file which is downloaded from the SSTATE_MIRROR is | 252 | [ $debug -gt 2 ] && echo "Considering to delete: $to_del" |
254 | # put in SSTATE_DIR, and there is a symlink in SSTATE_DIR/??/ to | 253 | # The sstate file which is downloaded from the SSTATE_MIRROR is |
255 | # it, so filter it out from the remove list if it should not be | 254 | # put in SSTATE_DIR, and there is a symlink in SSTATE_DIR/??/ to |
256 | # removed. | 255 | # it, so filter it out from the remove list if it should not be |
257 | to_keep=$(ls -t $(cat $fn_tmp) | sed -n '1p') | 256 | # removed. |
258 | [ $debug -gt 2 ] && echo "Considering to keep: $to_keep" | 257 | to_keep=$(ls -t $(cat $fn_tmp) | sed -n '1p') |
259 | for k in $to_keep; do | 258 | [ $debug -gt 2 ] && echo "Considering to keep: $to_keep" |
260 | if [ -L "$k" ]; then | 259 | for k in $to_keep; do |
261 | # The symlink's destination | 260 | if [ -L "$k" ]; then |
262 | k_dest="`readlink -e $k`" | 261 | # The symlink's destination |
263 | # Maybe it is the one in cache_dir | 262 | k_dest="`readlink -e $k`" |
264 | k_maybe="$cache_dir/${k##/*/}" | 263 | # Maybe it is the one in cache_dir |
265 | # Remove it from the remove list if they are the same. | 264 | k_maybe="$cache_dir/${k##/*/}" |
266 | if [ "$k_dest" = "$k_maybe" ]; then | 265 | # Remove it from the remove list if they are the same. |
267 | to_del="`echo $to_del | sed 's#'\"$k_maybe\"'##g'`" | 266 | if [ "$k_dest" = "$k_maybe" ]; then |
267 | to_del="`echo $to_del | sed 's#'\"$k_maybe\"'##g'`" | ||
268 | fi | ||
268 | fi | 269 | fi |
269 | fi | 270 | done |
270 | done | 271 | rm -f $fn_tmp |
271 | rm -f $fn_tmp | 272 | [ $debug -gt 2 ] && echo "Decided to delete: $to_del" |
272 | [ $debug -gt 2 ] && echo "Decided to delete: $to_del" | 273 | gen_rmlist $rm_list.$ext "$to_del" |
273 | gen_rmlist $rm_list "$to_del" | 274 | fi |
274 | fi | 275 | done |
275 | done | 276 | done |
276 | done | 277 | done |
277 | [ -s "$rm_list" ] && deleted_tgz=`cat $rm_list | grep ".tgz$" | wc -l` | 278 | deleted_tgz=`cat $rm_list.* 2>/dev/null | grep ".tgz$" | wc -l` |
278 | [ -s "$rm_list" ] && deleted_files=`cat $rm_list | wc -l` | 279 | deleted_files=`cat $rm_list.* 2>/dev/null | wc -l` |
279 | [ -s "$rm_list" -a $debug -gt 0 ] && cat $rm_list | 280 | [ "$deleted_files" -gt 0 -a $debug -gt 0 ] && cat $rm_list.* |
280 | echo "($deleted_tgz from $total_tgz_suffix .tgz files for $suffix suffix will be removed or $deleted_files from $total_files_suffix when counting also .siginfo and .done files)" | 281 | echo "($deleted_tgz from $total_tgz_suffix .tgz files for $suffix suffix will be removed or $deleted_files from $total_files_suffix when counting also .siginfo and .done files)" |
281 | let total_deleted=$total_deleted+$deleted_files | 282 | let total_deleted=$total_deleted+$deleted_files |
282 | done | 283 | done |