summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sstate-cache-management.sh39
1 files changed, 19 insertions, 20 deletions
diff --git a/scripts/sstate-cache-management.sh b/scripts/sstate-cache-management.sh
index be185bbb46..c3791d2bb4 100755
--- a/scripts/sstate-cache-management.sh
+++ b/scripts/sstate-cache-management.sh
@@ -132,13 +132,12 @@ remove_duplicated () {
132 132
133 sstate_suffixes="deploy-rpm deploy-ipk deploy-deb deploy package populate-lic populate-sysroot" 133 sstate_suffixes="deploy-rpm deploy-ipk deploy-deb deploy package populate-lic populate-sysroot"
134 134
135 cd $cache_dir || exit 1
136 # Save all the sstate files in a file 135 # Save all the sstate files in a file
137 sstate_list=`mktemp` || exit 1 136 sstate_list=`mktemp` || exit 1
138 ls sstate-*.tgz >$sstate_list 137 find $cache_dir -path '*/??/sstate-*.tgz' >$sstate_list
139 echo -n "Figuring out the archs in the sstate cache dir ... " 138 echo -n "Figuring out the archs in the sstate cache dir ... "
140 for arch in $all_archs; do 139 for arch in $all_archs; do
141 grep -q -w $arch $sstate_list 140 grep -q "\-$arch-" $sstate_list
142 [ $? -eq 0 ] && ava_archs="$ava_archs $arch" 141 [ $? -eq 0 ] && ava_archs="$ava_archs $arch"
143 done 142 done
144 echo "Done" 143 echo "Done"
@@ -151,24 +150,24 @@ remove_duplicated () {
151 150
152 for suffix in $sstate_suffixes; do 151 for suffix in $sstate_suffixes; do
153 # Save the file list to a file, some suffix's file may not exist 152 # Save the file list to a file, some suffix's file may not exist
154 ls *_$suffix.tgz >$list_suffix 2>/dev/null 153 grep "sstate-.*_$suffix.tgz" $sstate_list >$list_suffix 2>/dev/null
155 local deleted=0 154 local deleted=0
156 echo -n "Figuring out the sstate-xxx_$suffix.tgz ... " 155 echo -n "Figuring out the sstate-xxx_$suffix.tgz ... "
157 # There are at list 6 dashes (-) after arch, use this to avoid the 156 # There are at list 6 dashes (-) after arch, use this to avoid the
158 # greedy match of sed. 157 # greedy match of sed.
159 file_names=`for arch in $ava_archs; do 158 file_names=`for arch in $ava_archs; do
160 sed -ne 's/^\(sstate-.*\)-'"$arch"'-.*-.*-.*-.*-.*-.*/\1/p' $list_suffix 159 sed -ne 's#.*/../\(sstate-.*\)-'"$arch"'-.*-.*-.*-.*-.*-.*#\1#p' $list_suffix
161 done | sort -u` 160 done | sort -u`
162 161
163 fn_tmp=`mktemp` || exit 1 162 fn_tmp=`mktemp` || exit 1
164 for fn in $file_names; do 163 for fn in $file_names; do
165 [ -z "$verbose" ] || echo "Analyzing $fn-xxx_$suffix.tgz" 164 [ -z "$verbose" ] || echo "Analyzing $fn-xxx_$suffix.tgz"
166 for arch in $ava_archs; do 165 for arch in $ava_archs; do
167 grep -h "^$fn-$arch-" $list_suffix >>$fn_tmp 166 grep -h "/../$fn-$arch-" $list_suffix >>$fn_tmp
168 done 167 done
169 # Use the access time, also delete the .siginfo file 168 # Use the access time, also delete the .siginfo file
170 to_del=$(ls -u $(cat $fn_tmp) | sed -n '1!p' | sed -e 'p' -e 's/$/.siginfo/') 169 to_del=$(ls -u $(cat $fn_tmp) | sed -n '1!p' | sed -e 'p' -e 's/$/.siginfo/')
171 echo $to_del >>$remove_listdir/sstate-xxx_$suffix 170 [ "$to_del" = "" ] || echo $to_del >>$remove_listdir/sstate-xxx_$suffix
172 let deleted=$deleted+`echo $to_del | wc -w` 171 let deleted=$deleted+`echo $to_del | wc -w`
173 rm -f $fn_tmp 172 rm -f $fn_tmp
174 done 173 done
@@ -181,7 +180,10 @@ remove_duplicated () {
181 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then 180 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
182 for list in `ls $remove_listdir/`; do 181 for list in `ls $remove_listdir/`; do
183 echo -n "Removing $list.tgz (`cat $remove_listdir/$list | wc -w` files) ... " 182 echo -n "Removing $list.tgz (`cat $remove_listdir/$list | wc -w` files) ... "
184 rm -f $verbose `cat $remove_listdir/$list` 183 # Remove them one by one to avoid the argument list too long error
184 for i in `cat $remove_listdir/$list`; do
185 rm -f $verbose $i
186 done
185 echo "Done" 187 echo "Done"
186 done 188 done
187 echo "$total_deleted files have been removed!" 189 echo "$total_deleted files have been removed!"
@@ -200,7 +202,7 @@ rm_by_stamps (){
200 202
201 local cache_list=`mktemp` || exit 1 203 local cache_list=`mktemp` || exit 1
202 local keep_list=`mktemp` || exit 1 204 local keep_list=`mktemp` || exit 1
203 local mv_to_dir=`mktemp -d -p $cache_dir` || exit 1 205 local rm_list=`mktemp` || exit 1
204 local suffixes 206 local suffixes
205 local sums 207 local sums
206 local all_sums 208 local all_sums
@@ -218,7 +220,7 @@ rm_by_stamps (){
218 echo "Done" 220 echo "Done"
219 221
220 # Save all the state file list to a file 222 # Save all the state file list to a file
221 ls $cache_dir/sstate-*.tgz >$cache_list 223 find $cache_dir -path '*/??/sstate-*.tgz' | sort -u -o $cache_list
222 224
223 echo -n "Figuring out the files which will be removed ... " 225 echo -n "Figuring out the files which will be removed ... "
224 for i in $all_sums; do 226 for i in $all_sums; do
@@ -227,21 +229,18 @@ rm_by_stamps (){
227 echo "Done" 229 echo "Done"
228 230
229 if [ -s $keep_list ]; then 231 if [ -s $keep_list ]; then
230 let total_deleted=(`cat $cache_list | wc -w` - `cat $keep_list | wc -l`)*2 232 sort -u $keep_list -o $keep_list
233 comm -1 -3 $keep_list $cache_list > $rm_list
234 let total_deleted=(`cat $rm_list | wc -w`)*2
231 235
232 if [ $total_deleted -gt 0 ]; then 236 if [ $total_deleted -gt 0 ]; then
233 read_confirm 237 read_confirm
234 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then 238 if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
235 echo "Removing sstate cache files ... ($total_deleted files)" 239 echo "Removing sstate cache files ... ($total_deleted files)"
236 # Save the file which needs to be kept, remove the others, 240 # Remove them one by one to avoid the argument list too long error
237 # then move it back 241 for i in `cat $rm_list`; do
238 for i in `cat $keep_list`; do 242 rm -f $verbose $i $i.siginfo
239 mv $i $mv_to_dir
240 mv $i.siginfo $mv_to_dir || true
241 done 243 done
242 rm -f $verbose $cache_dir/sstate-*.tgz
243 rm -f $verbose $cache_dir/sstate-*.tgz.siginfo
244 mv $mv_to_dir/* $cache_dir/
245 echo "$total_deleted files have been removed" 244 echo "$total_deleted files have been removed"
246 else 245 else
247 do_nothing 246 do_nothing
@@ -255,7 +254,7 @@ rm_by_stamps (){
255 254
256 rm -f $cache_list 255 rm -f $cache_list
257 rm -f $keep_list 256 rm -f $keep_list
258 rmdir $mv_to_dir 257 rm -f $rm_list
259} 258}
260 259
261# Parse arguments 260# Parse arguments