summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2014-01-29 22:03:39 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-02 11:30:33 +0000
commita8a7e7b28935d87eaba56281ba46a2aa2270f700 (patch)
treeb7758429d6b2ced45c2cd4cb16091ca99e19811f
parent731a7455efb46824a79b57b5e350b9e27e43131b (diff)
downloadpoky-a8a7e7b28935d87eaba56281ba46a2aa2270f700.tar.gz
sstate-cache-management.sh: Fix remove_duplicated() to work after SSTATE_SWSPEC change
* format of filenames for sstate archives was changed in: commit 6f823a23c5f1d0ffa0a27db1c1bc1907de788505 Author: Richard Purdie <richard.purdie@linuxfoundation.org> Date: Fri Dec 20 12:06:02 2013 +0000 Subject: sstate: Convert to use ':' as a filename sperator and use SSTATE_SWSPEC globally * remove_duplicated() wasn't able to find available architectures and duplicate files since this change * add extra step to remove old sstate archives starting with sstate- (instead of sstate:) (From OE-Core rev: ddb26341611c3dff41ea92a73d93ec01ae2865de) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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