Lines Matching +full:sstate +full:- +full:cache

5 # SPDX-License-Identifier: GPL-2.0-only
18 Welcome to sstate cache management utilities.
19 sstate-cache-management.sh <OPTION>
22 -h, --help
25 --cache-dir=<sstate cache dir>
26 Specify sstate cache directory, will use the environment
29 --extra-archs=<arch1>,<arch2>...<archn>
35 --extra-layer=<layer1>,<layer2>...<layern>
37 it will search the meta and meta-* layers in the top dir by
38 default, and will search meta, meta-*, <layer1>, <layer2>,
41 This is useless for --stamps-dir or when --extra-archs is used.
43 -d, --remove-duplicated
44 Remove the duplicated sstate cache files of one package, only
45 the newest one will be kept. The duplicated sstate cache files
46 of one package must have the same arch, which means sstate cache
49 Conflicts with --stamps-dir.
51 --stamps-dir=<dir1>,<dir2>...<dirn>
52 Specify the build directory's stamps directories, the sstate
53 cache file which IS USED by these build diretories will be KEPT,
54 other sstate cache files in cache-dir will be removed. Use ","
56 --stamps-dir=build1/tmp/stamps,build2/tmp/stamps
58 Conflicts with --remove-duplicated.
60 -L, --follow-symlink
63 -y, --yes
65 and run non-interactively.
67 -v, --verbose
70 -D, --debug
76 if [ $# -lt 1 ]; then
97 [ "$confirm" = "Y" -o "$confirm" = "y" -o "$confirm" = "n" \
98 -o "$confirm" = "N" ] && break
117 # $1: output file, others: sstate cache file (.tar.zst)
125 if [ -e $i.siginfo ]; then
129 if [ -L "$i" ]; then
131 dest="`readlink -e $i`"
132 if [ -n "$dest" ]; then
135 if [ -f "$dest.siginfo" ]; then
145 if [ -f $cache_dir/$d ]; then
153 # Remove the duplicated cache files for the pkg, keep the newest one
168 if [ -z "$extra_archs" ] ; then
171 oe_core_dir=$(dirname $(dirname $(readlink -e $0)))
173 …tunedirs="`find $topdir/meta* ${oe_core_dir}/meta* $layers -path '*/meta*/conf/machine/include' 2>…
174 [ -n "$tunedirs" ] || echo_error "Can't find the tune directory"
175 …r/meta* ${oe_core_dir}/meta* $layers -path '*/meta*/conf/machine/*' -name '*.conf' 2>/dev/null | s…
176 all_archs=`grep -r -h "^AVAILTUNES .*=" $tunedirs | sed -e 's/.*=//' -e 's/\"//g'`
179 …# Use the "_" to substitute "-", e.g., x86-64 to x86_64, but not for extra_archs which can be some…
182 builder_arch=$(uname -m)
184 | sed -e 's/-/_/g' -e 's/ /\n/g' | sort -u) $extra_archs"
187 # Total number of files including sstate-, .siginfo and .done files
188 total_files=`find $cache_dir -name 'sstate*' | wc -l`
189 # Save all the sstate files in a file
191 find $cache_dir -iname 'sstate:*:*:*:*:*:*:*.tar.zst*' >$sstate_files_list
193 echo "Figuring out the suffixes in the sstate cache dir ... "
194 …te_suffixes="`sed 's%.*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^_]*_\([^:]*\)\.tar\.zst.*%\1%…
196 echo "The following suffixes have been found in the cache dir:"
199 echo "Figuring out the archs in the sstate cache dir ... "
201 …# SSTATE_PKGSPEC = "sstate:${PN}:${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}:${PV}:${PR}:${SST…
203 grep -q ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.tar\.zst$" $sstate_files_list
204 [ $? -eq 0 ] && ava_archs="$ava_archs $arch"
205 # ${builder_arch}_$arch used by toolchain sstate
206 …grep -q ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:${builder_arch}_$arch:[^:]*:[^:]*\.tar\.zst$" $sstate_f…
207 [ $? -eq 0 ] && ava_archs="$ava_archs ${builder_arch}_$arch"
210 echo "The following archs have been found in the cache dir:"
215 local remove_listdir=`mktemp -d` || exit 1
218 …pulate_lic, because removing duplicates doesn't work correctly for them (use --stamps-dir instead)"
222 …otal_files_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tar\.zst.*"…
223 …tal_archive_suffix=`grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tar\.zst$"…
225 …grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:_]*_$suffix\.tar\.zst.*" $sstate_files_list…
229 echo "Figuring out the sstate:xxx_$suffix.$ext ... "
232 … sed -ne "s%.*/sstate:\([^:]*\):[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.${ext}$%\1%p" $list_suffix
233 done | sort -u`
236 rm_list="$remove_listdir/sstate:xxx_$suffix"
238 [ -z "$verbose" ] || echo "Analyzing sstate:$fn-xxx_$suffix.${ext}"
240 … grep -h ".*/sstate:$fn:[^:]*:[^:]*:[^:]*:$arch:[^:]*:[^:]*\.${ext}$" $list_suffix >$fn_tmp
241 if [ -s $fn_tmp ] ; then
242 …[ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix.${ext}:" && cat $fn_t…
244 to_del=$(ls -t $(cat $fn_tmp) | sed -n '1!p')
245 [ $debug -gt 2 ] && echo "Considering to delete: $to_del"
246 # The sstate file which is downloaded from the SSTATE_MIRROR is
250 to_keep=$(ls -t $(cat $fn_tmp) | sed -n '1p')
251 [ $debug -gt 2 ] && echo "Considering to keep: $to_keep"
253 if [ -L "$k" ]; then
255 k_dest="`readlink -e $k`"
264 rm -f $fn_tmp
265 [ $debug -gt 2 ] && echo "Decided to delete: $to_del"
271 deleted_archives=`cat $rm_list.* 2>/dev/null | grep "\.tar\.zst$" | wc -l`
272 deleted_files=`cat $rm_list.* 2>/dev/null | wc -l`
273 [ "$deleted_files" -gt 0 -a $debug -gt 0 ] && cat $rm_list.*
278 rm_old_list=$remove_listdir/sstate-old-filenames
279 find $cache_dir -name 'sstate-*.tar.zst' >$rm_old_list
280 [ -s "$rm_old_list" ] && deleted_archives=`cat $rm_old_list | grep "\.tar\.zst$" | wc -l`
281 [ -s "$rm_old_list" ] && deleted_files=`cat $rm_old_list | wc -l`
282 [ -s "$rm_old_list" -a $debug -gt 0 ] && cat $rm_old_list
283 …echo "($deleted_archives or .tar.zst files with old sstate-* filenames will be removed or $deleted…
286 rm -f $list_suffix
287 rm -f $sstate_files_list
288 if [ $total_deleted -gt 0 ]; then
290 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
292 echo "Removing $list.tar.zst archive (`cat $remove_listdir/$list | wc -w` files) ... "
295 rm -f $verbose $i
306 [ -d $remove_listdir ] && rm -fr $remove_listdir
309 # Remove the sstate file by stamps dir, the file not used by the stamps dir
319 # Total number of files including sstate-, .siginfo and .done files
320 total_files=`find $cache_dir -type f -name 'sstate*' | wc -l`
322 find $cache_dir -type f -name 'sstate*' | sort -u -o $cache_list
324 echo "Figuring out the suffixes in the sstate cache dir ... "
325 …sstate_suffixes="`sed 's%.*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^_]*_\([^:]*\)\.tar\.zst.*…
327 echo "The following suffixes have been found in the cache dir:"
335 sums=`find $stamps -maxdepth 3 -name "*.do_$i.*" \
336 -o -name "*.do_${i}_setscene.*" | \
337 sed -ne 's#.*_setscene\.##p' -e 's#.*\.sigdata\.##p' | \
338 sed -e 's#\..*##' | sort -u`
345 grep ".*/sstate:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:${i}_.*" $cache_list >>$keep_list
349 if [ -s $keep_list ]; then
350 sort -u $keep_list -o $keep_list
351 to_del=`comm -1 -3 $keep_list $cache_list`
353 let total_deleted=`cat $rm_list | sort -u | wc -w`
354 if [ $total_deleted -gt 0 ]; then
355 [ $debug -gt 0 ] && cat $rm_list | sort -u
357 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
358 echo "Removing sstate cache files ... ($total_deleted files)"
360 for i in `cat $rm_list | sort -u`; do
361 rm -f $verbose $i
371 echo_error "All files in cache dir will be removed! Abort!"
374 rm -f $cache_list
375 rm -f $keep_list
376 rm -f $rm_list
380 while [ -n "$1" ]; do
382 --cache-dir=*)
383 cache_dir=`echo $1 | sed -e 's#^--cache-dir=##' | xargs readlink -e`
384 [ -d "$cache_dir" ] || echo_error "Invalid argument to --cache-dir"
387 --remove-duplicated|-d)
391 --yes|-y)
395 --follow-symlink|-L)
399 --extra-archs=*)
400 extra_archs=`echo $1 | sed -e 's#^--extra-archs=##' -e 's#,# #g'`
401 [ -n "$extra_archs" ] || echo_error "Invalid extra arch parameter"
404 --extra-layer=*)
405 extra_layers=`echo $1 | sed -e 's#^--extra-layer=##' -e 's#,# #g'`
406 [ -n "$extra_layers" ] || echo_error "Invalid extra layer parameter"
408 l=`readlink -e $i`
409 if [ -d "$l" ]; then
417 --stamps-dir=*)
418 stamps=`echo $1 | sed -e 's#^--stamps-dir=##' -e 's#,# #g'`
419 [ -n "$stamps" ] || echo_error "Invalid stamps dir $i"
421 [ -d "$i" ] || echo_error "Invalid stamps dir $i"
425 --verbose|-v)
426 verbose="-v"
429 --debug|-D)
434 --help|-h)
440 echo_error "Try 'sstate-cache-management.sh -h' for more information."
445 # sstate cache directory, use environment variable SSTATE_CACHE_DIR
447 [ -n "$cache_dir" ] || cache_dir=$SSTATE_CACHE_DIR
448 [ -n "$cache_dir" ] || echo_error "No cache dir found!"
449 [ -d "$cache_dir" ] || echo_error "Invalid cache directory \"$cache_dir\""
451 [ -n "$rm_duplicated" -a -n "$stamps" ] && \
452 echo_error "Can not use both --remove-duplicated and --stamps-dir"
455 [ -n "$stamps" ] && rm_by_stamps
456 [ -z "$rm_duplicated" -a -z "$stamps" ] && \