2012-02-22 12:38:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright (c) 2012 Wind River Systems, Inc.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
# Global vars
|
|
|
|
cache_dir=
|
|
|
|
confirm=
|
2012-08-20 08:29:46 +00:00
|
|
|
fsym=
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
total_deleted=0
|
|
|
|
verbose=
|
2012-09-03 15:05:07 +00:00
|
|
|
debug=0
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
|
2012-02-22 12:38:30 +00:00
|
|
|
usage () {
|
|
|
|
cat << EOF
|
|
|
|
Welcome to sstate cache management utilities.
|
|
|
|
sstate-cache-management.sh <OPTION>
|
|
|
|
|
|
|
|
Options:
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
-h, --help
|
2012-02-22 12:38:30 +00:00
|
|
|
Display this help and exit.
|
|
|
|
|
|
|
|
--cache-dir=<sstate cache dir>
|
|
|
|
Specify sstate cache directory, will use the environment
|
|
|
|
variable SSTATE_CACHE_DIR if it is not specified.
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
--extra-layer=<layer1>,<layer2>...<layern>
|
|
|
|
Specify the layer which will be used for searching the archs,
|
|
|
|
it will search the meta and meta-* layers in the top dir by
|
|
|
|
default, and will search meta, meta-*, <layer1>, <layer2>,
|
|
|
|
...<layern> when specified. Use "," as the separator.
|
|
|
|
|
|
|
|
This is useless for --stamps-dir.
|
|
|
|
|
|
|
|
-d, --remove-duplicated
|
2012-02-22 12:38:30 +00:00
|
|
|
Remove the duplicated sstate cache files of one package, only
|
2013-02-26 07:57:15 +00:00
|
|
|
the newest one will be kept. The duplicated sstate cache files
|
|
|
|
of one package must have the same arch, which means sstate cache
|
|
|
|
files with multiple archs are not considered duplicate.
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
|
|
|
|
Conflicts with --stamps-dir.
|
|
|
|
|
|
|
|
--stamps-dir=<dir1>,<dir2>...<dirn>
|
|
|
|
Specify the build directory's stamps directories, the sstate
|
|
|
|
cache file which IS USED by these build diretories will be KEPT,
|
|
|
|
other sstate cache files in cache-dir will be removed. Use ","
|
|
|
|
as the separator. For example:
|
|
|
|
--stamps-dir=build1/tmp/stamps,build2/tmp/stamps
|
|
|
|
|
|
|
|
Conflicts with --remove-duplicated.
|
|
|
|
|
2012-08-20 08:29:46 +00:00
|
|
|
-L, --follow-symlink
|
|
|
|
Rmove both the symbol link and the destination file, default: no.
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
-y, --yes
|
|
|
|
Automatic yes to prompts; assume "yes" as answer to all prompts
|
|
|
|
and run non-interactively.
|
|
|
|
|
|
|
|
-v, --verbose
|
|
|
|
explain what is being done
|
2012-02-22 12:38:30 +00:00
|
|
|
|
2013-02-26 07:57:17 +00:00
|
|
|
-D, --debug
|
2012-09-03 15:05:07 +00:00
|
|
|
show debug info, repeat for more debug info
|
|
|
|
|
2012-02-22 12:38:30 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
# Echo no files to remove
|
|
|
|
no_files () {
|
|
|
|
echo No files to remove
|
|
|
|
}
|
|
|
|
|
|
|
|
# Echo nothing to do
|
|
|
|
do_nothing () {
|
|
|
|
echo Nothing to do
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read the input "y"
|
|
|
|
read_confirm () {
|
|
|
|
echo -n "$total_deleted files will be removed! "
|
|
|
|
if [ "$confirm" != "y" ]; then
|
|
|
|
echo -n "Do you want to continue (y/n)? "
|
|
|
|
while read confirm; do
|
|
|
|
[ "$confirm" = "Y" -o "$confirm" = "y" -o "$confirm" = "n" \
|
|
|
|
-o "$confirm" = "N" ] && break
|
|
|
|
echo -n "Invalid input \"$confirm\", please input 'y' or 'n': "
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-02-22 12:38:30 +00:00
|
|
|
# Print error information and exit.
|
|
|
|
echo_error () {
|
|
|
|
echo "ERROR: $1" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2012-08-20 08:29:46 +00:00
|
|
|
# Generate the remove list:
|
|
|
|
#
|
|
|
|
# * Add .done/.siginfo to the remove list
|
|
|
|
# * Add destination of symlink to the remove list
|
|
|
|
#
|
|
|
|
# $1: output file, others: sstate cache file (.tgz)
|
|
|
|
gen_rmlist (){
|
|
|
|
local rmlist_file="$1"
|
|
|
|
shift
|
|
|
|
local files="$@"
|
|
|
|
for i in $files; do
|
|
|
|
echo $i >> $rmlist_file
|
|
|
|
# Add the ".siginfo"
|
|
|
|
if [ -e $i.siginfo ]; then
|
|
|
|
echo $i.siginfo >> $rmlist_file
|
|
|
|
fi
|
|
|
|
# Add the destination of symlink
|
|
|
|
if [ -L "$i" ]; then
|
|
|
|
if [ "$fsym" = "y" ]; then
|
|
|
|
dest="`readlink -e $i`"
|
|
|
|
if [ -n "$dest" ]; then
|
|
|
|
echo $dest >> $rmlist_file
|
|
|
|
# Remove the .siginfo when .tgz is removed
|
|
|
|
if [ -f "$dest.siginfo" ]; then
|
|
|
|
echo $dest.siginfo >> $rmlist_file
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# Add the ".tgz.done" and ".siginfo.done" (may exist in the future)
|
|
|
|
base_fn="${i##/*/}"
|
|
|
|
t_fn="$base_fn.done"
|
|
|
|
s_fn="$base_fn.siginfo.done"
|
|
|
|
for d in $t_fn $s_fn; do
|
|
|
|
if [ -f $cache_dir/$d ]; then
|
|
|
|
echo $cache_dir/$d >> $rmlist_file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-02-22 12:38:30 +00:00
|
|
|
# Remove the duplicated cache files for the pkg, keep the newest one
|
|
|
|
remove_duplicated () {
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
|
|
|
|
local topdir
|
2012-09-02 11:13:20 +00:00
|
|
|
local oe_core_dir
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
local tunedirs
|
|
|
|
local all_archs
|
2012-09-02 11:13:21 +00:00
|
|
|
local all_machines
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
local ava_archs
|
|
|
|
local arch
|
|
|
|
local file_names
|
|
|
|
local sstate_list
|
|
|
|
local fn_tmp
|
|
|
|
local list_suffix=`mktemp` || exit 1
|
|
|
|
|
|
|
|
# Find out the archs in all the layers
|
|
|
|
echo -n "Figuring out the archs in the layers ... "
|
2012-09-02 11:13:20 +00:00
|
|
|
oe_core_dir=$(dirname $(dirname $(readlink -e $0)))
|
|
|
|
topdir=$(dirname $oe_core_dir)
|
2012-10-09 09:30:16 +00:00
|
|
|
tunedirs="`find $topdir/meta* ${oe_core_dir}/meta* $layers -path '*/meta*/conf/machine/include' 2>/dev/null`"
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ -n "$tunedirs" ] || echo_error "Can't find the tune directory"
|
2012-09-27 07:36:13 +00:00
|
|
|
all_machines="`find $topdir/meta* ${oe_core_dir}/meta* $layers -path '*/meta*/conf/machine/*' -name '*.conf' 2>/dev/null | sed -e 's/.*\///' -e 's/.conf$//'`"
|
2012-09-02 11:13:19 +00:00
|
|
|
all_archs=`grep -r -h "^AVAILTUNES .*=" $tunedirs | sed -e 's/.*=//' -e 's/\"//g'`
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
# Add the qemu and native archs
|
|
|
|
# Use the "_" to substitute "-", e.g., x86-64 to x86_64
|
|
|
|
# Sort to remove the duplicated ones
|
2012-09-02 11:13:21 +00:00
|
|
|
all_archs=$(echo $all_archs $all_machines $(uname -m) \
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
| sed -e 's/-/_/g' -e 's/ /\n/g' | sort -u)
|
|
|
|
echo "Done"
|
|
|
|
|
|
|
|
# Save all the sstate files in a file
|
|
|
|
sstate_list=`mktemp` || exit 1
|
2012-08-20 08:29:46 +00:00
|
|
|
find $cache_dir -name 'sstate-*.tgz' >$sstate_list
|
2013-02-26 07:57:16 +00:00
|
|
|
|
|
|
|
echo -n "Figuring out the suffixes in the sstate cache dir ... "
|
|
|
|
sstate_suffixes="`sed 's/.*_\([^_]*\)\.tgz$/\1/g' $sstate_list | sort -u`"
|
|
|
|
echo "Done"
|
|
|
|
echo "The following suffixes have been found in the cache dir:"
|
|
|
|
echo $sstate_suffixes
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
echo -n "Figuring out the archs in the sstate cache dir ... "
|
|
|
|
for arch in $all_archs; do
|
2012-08-14 14:01:33 +00:00
|
|
|
grep -q "\-$arch-" $sstate_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ $? -eq 0 ] && ava_archs="$ava_archs $arch"
|
|
|
|
done
|
|
|
|
echo "Done"
|
|
|
|
echo "The following archs have been found in the cache dir:"
|
|
|
|
echo $ava_archs
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Save the file list which needs to be removed
|
|
|
|
local remove_listdir=`mktemp -d` || exit 1
|
|
|
|
|
|
|
|
for suffix in $sstate_suffixes; do
|
|
|
|
# Save the file list to a file, some suffix's file may not exist
|
2012-08-14 14:01:33 +00:00
|
|
|
grep "sstate-.*_$suffix.tgz" $sstate_list >$list_suffix 2>/dev/null
|
2012-02-22 12:38:30 +00:00
|
|
|
local deleted=0
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
echo -n "Figuring out the sstate-xxx_$suffix.tgz ... "
|
|
|
|
# There are at list 6 dashes (-) after arch, use this to avoid the
|
|
|
|
# greedy match of sed.
|
2012-02-22 12:38:30 +00:00
|
|
|
file_names=`for arch in $ava_archs; do
|
2012-08-20 08:29:46 +00:00
|
|
|
sed -ne 's#.*/\(sstate-.*\)-'"$arch"'-.*-.*-.*-.*-.*-.*#\1#p' $list_suffix
|
2012-02-22 12:38:30 +00:00
|
|
|
done | sort -u`
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
fn_tmp=`mktemp` || exit 1
|
2012-08-20 08:29:46 +00:00
|
|
|
rm_list="$remove_listdir/sstate-xxx_$suffix"
|
2012-02-22 12:38:30 +00:00
|
|
|
for fn in $file_names; do
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ -z "$verbose" ] || echo "Analyzing $fn-xxx_$suffix.tgz"
|
2012-02-22 12:38:30 +00:00
|
|
|
for arch in $ava_archs; do
|
2012-09-03 15:05:08 +00:00
|
|
|
grep -h "/$fn-$arch-" $list_suffix >$fn_tmp
|
|
|
|
if [ -s $fn_tmp ] ; then
|
|
|
|
[ $debug -gt 1 ] && echo "Available files for $fn-$arch- with suffix $suffix:" && cat $fn_tmp
|
|
|
|
# Use the modification time
|
|
|
|
to_del=$(ls -t $(cat $fn_tmp) | sed -n '1!p')
|
|
|
|
[ $debug -gt 2 ] && echo "Considering to delete: $to_del"
|
|
|
|
# The sstate file which is downloaded from the SSTATE_MIRROR is
|
|
|
|
# put in SSTATE_DIR, and there is a symlink in SSTATE_DIR/??/ to
|
|
|
|
# it, so filter it out from the remove list if it should not be
|
|
|
|
# removed.
|
|
|
|
to_keep=$(ls -t $(cat $fn_tmp) | sed -n '1p')
|
|
|
|
[ $debug -gt 2 ] && echo "Considering to keep: $to_keep"
|
|
|
|
for k in $to_keep; do
|
|
|
|
if [ -L "$k" ]; then
|
|
|
|
# The symlink's destination
|
|
|
|
k_dest="`readlink -e $k`"
|
|
|
|
# Maybe it is the one in cache_dir
|
|
|
|
k_maybe="$cache_dir/${k##/*/}"
|
|
|
|
# Remove it from the remove list if they are the same.
|
|
|
|
if [ "$k_dest" = "$k_maybe" ]; then
|
|
|
|
to_del="`echo $to_del | sed 's#'\"$k_maybe\"'##g'`"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm -f $fn_tmp
|
|
|
|
[ $debug -gt 2 ] && echo "Decided to delete: $to_del"
|
|
|
|
gen_rmlist $rm_list "$to_del"
|
2012-08-29 09:24:59 +00:00
|
|
|
fi
|
|
|
|
done
|
2012-02-22 12:38:30 +00:00
|
|
|
done
|
2012-08-20 08:29:46 +00:00
|
|
|
[ ! -s "$rm_list" ] || deleted=`cat $rm_list | wc -l`
|
2012-09-03 15:05:07 +00:00
|
|
|
[ -s "$rm_list" -a $debug -gt 0 ] && cat $rm_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
echo "($deleted files will be removed)"
|
2012-02-22 12:38:30 +00:00
|
|
|
let total_deleted=$total_deleted+$deleted
|
|
|
|
done
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
rm -f $list_suffix
|
2012-08-29 09:24:59 +00:00
|
|
|
rm -f $sstate_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
if [ $total_deleted -gt 0 ]; then
|
|
|
|
read_confirm
|
|
|
|
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
|
|
|
|
for list in `ls $remove_listdir/`; do
|
|
|
|
echo -n "Removing $list.tgz (`cat $remove_listdir/$list | wc -w` files) ... "
|
2012-08-14 14:01:33 +00:00
|
|
|
# Remove them one by one to avoid the argument list too long error
|
|
|
|
for i in `cat $remove_listdir/$list`; do
|
|
|
|
rm -f $verbose $i
|
|
|
|
done
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
echo "Done"
|
|
|
|
done
|
|
|
|
echo "$total_deleted files have been removed!"
|
|
|
|
else
|
|
|
|
do_nothing
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
no_files
|
|
|
|
fi
|
|
|
|
[ -d $remove_listdir ] && rm -fr $remove_listdir
|
|
|
|
}
|
|
|
|
|
|
|
|
# Remove the sstate file by stamps dir, the file not used by the stamps dir
|
|
|
|
# will be removed.
|
|
|
|
rm_by_stamps (){
|
|
|
|
|
|
|
|
local cache_list=`mktemp` || exit 1
|
|
|
|
local keep_list=`mktemp` || exit 1
|
2012-08-14 14:01:33 +00:00
|
|
|
local rm_list=`mktemp` || exit 1
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
local suffixes
|
|
|
|
local sums
|
|
|
|
local all_sums
|
|
|
|
|
|
|
|
suffixes="populate_sysroot populate_lic package_write_ipk \
|
|
|
|
package_write_rpm package_write_deb package deploy"
|
|
|
|
|
|
|
|
# Figure out all the md5sums in the stamps dir.
|
|
|
|
echo -n "Figuring out all the md5sums in stamps dir ... "
|
|
|
|
for i in $suffixes; do
|
2012-08-20 08:29:46 +00:00
|
|
|
# There is no "\.sigdata" but "_setcene" when it is mirrored
|
|
|
|
# from the SSTATE_MIRRORS, use them to figure out the sum.
|
2012-11-23 20:20:48 +00:00
|
|
|
sums=`find $stamps -maxdepth 3 -name "*.do_$i.*" \
|
2012-08-20 08:29:46 +00:00
|
|
|
-o -name "*.do_${i}_setscene.*" | \
|
|
|
|
sed -ne 's#.*_setscene\.##p' -e 's#.*\.sigdata\.##p' | \
|
|
|
|
sed -e 's#\..*##' | sort -u`
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
all_sums="$all_sums $sums"
|
|
|
|
done
|
|
|
|
echo "Done"
|
|
|
|
|
|
|
|
# Save all the state file list to a file
|
2012-08-20 08:29:46 +00:00
|
|
|
find $cache_dir -name 'sstate-*.tgz' | sort -u -o $cache_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
|
|
|
|
echo -n "Figuring out the files which will be removed ... "
|
|
|
|
for i in $all_sums; do
|
2012-09-02 11:13:18 +00:00
|
|
|
grep ".*-${i}_.*" $cache_list >>$keep_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
done
|
|
|
|
echo "Done"
|
|
|
|
|
|
|
|
if [ -s $keep_list ]; then
|
2012-08-14 14:01:33 +00:00
|
|
|
sort -u $keep_list -o $keep_list
|
2012-08-20 08:29:46 +00:00
|
|
|
to_del=`comm -1 -3 $keep_list $cache_list`
|
|
|
|
gen_rmlist $rm_list "$to_del"
|
|
|
|
let total_deleted=(`cat $rm_list | wc -w`)
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
if [ $total_deleted -gt 0 ]; then
|
2012-09-03 15:05:07 +00:00
|
|
|
[ $debug -gt 0 ] && cat $rm_list
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
read_confirm
|
|
|
|
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
|
|
|
|
echo "Removing sstate cache files ... ($total_deleted files)"
|
2012-08-14 14:01:33 +00:00
|
|
|
# Remove them one by one to avoid the argument list too long error
|
|
|
|
for i in `cat $rm_list`; do
|
2012-08-20 08:29:46 +00:00
|
|
|
rm -f $verbose $i
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
done
|
|
|
|
echo "$total_deleted files have been removed"
|
|
|
|
else
|
|
|
|
do_nothing
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
no_files
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo_error "All files in cache dir will be removed! Abort!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $cache_list
|
|
|
|
rm -f $keep_list
|
2012-08-14 14:01:33 +00:00
|
|
|
rm -f $rm_list
|
2012-02-22 12:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
while [ -n "$1" ]; do
|
|
|
|
case $1 in
|
|
|
|
--cache-dir=*)
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
cache_dir=`echo $1 | sed -e 's#^--cache-dir=##' | xargs readlink -e`
|
2012-02-22 12:38:30 +00:00
|
|
|
[ -d "$cache_dir" ] || echo_error "Invalid argument to --cache-dir"
|
|
|
|
shift
|
|
|
|
;;
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
--remove-duplicated|-d)
|
|
|
|
rm_duplicated="y"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--yes|-y)
|
|
|
|
confirm="y"
|
|
|
|
shift
|
|
|
|
;;
|
2012-08-20 08:29:46 +00:00
|
|
|
--follow-symlink|-L)
|
|
|
|
fsym="y"
|
|
|
|
shift
|
|
|
|
;;
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
--extra-layer=*)
|
|
|
|
extra_layers=`echo $1 | sed -e 's#^--extra-layer=##' -e 's#,# #g'`
|
|
|
|
[ -n "$extra_layers" ] || echo_error "Invalid extra layer $i"
|
|
|
|
for i in $extra_layers; do
|
|
|
|
l=`readlink -e $i`
|
|
|
|
if [ -d "$l" ]; then
|
|
|
|
layers="$layers $l"
|
|
|
|
else
|
|
|
|
echo_error "Can't find layer $i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--stamps-dir=*)
|
|
|
|
stamps=`echo $1 | sed -e 's#^--stamps-dir=##' -e 's#,# #g'`
|
|
|
|
[ -n "$stamps" ] || echo_error "Invalid stamps dir $i"
|
|
|
|
for i in $stamps; do
|
|
|
|
[ -d "$i" ] || echo_error "Invalid stamps dir $i"
|
|
|
|
done
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--verbose|-v)
|
|
|
|
verbose="-v"
|
2012-02-22 12:38:30 +00:00
|
|
|
shift
|
|
|
|
;;
|
2013-02-26 07:57:17 +00:00
|
|
|
--debug|-D)
|
2012-09-03 15:05:07 +00:00
|
|
|
debug=`expr $debug + 1`
|
|
|
|
echo "Debug level $debug"
|
|
|
|
shift
|
|
|
|
;;
|
2012-02-22 12:38:30 +00:00
|
|
|
--help|-h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
echo "Invalid arguments $*"
|
|
|
|
echo_error "Try 'sstate-cache-management.sh -h' for more information."
|
2012-02-22 12:38:30 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# sstate cache directory, use environment variable SSTATE_CACHE_DIR
|
|
|
|
# if it was not specified, otherwise, error.
|
|
|
|
[ -n "$cache_dir" ] || cache_dir=$SSTATE_CACHE_DIR
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ -n "$cache_dir" ] || echo_error "No cache dir found!"
|
2012-02-22 12:38:30 +00:00
|
|
|
[ -d "$cache_dir" ] || echo_error "Invalid cache directory \"$cache_dir\""
|
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ -n "$rm_duplicated" -a -n "$stamps" ] && \
|
|
|
|
echo_error "Can not use both --remove-duplicated and --stamps-dir"
|
2012-02-22 12:38:30 +00:00
|
|
|
|
sstate-cache-management.sh: fixes and enhancement
Fix a few problems and enhance its functions, it shoud be more useful
than before.
* Search in meta and meta-* for archs, and grep AVAILTUNES for archs,
(only search meta, and grep DEFAULTTUNE before), add the host arch.
and also can search in extra layers with --extra-layer.
* Reduce the analyzing time when remove duplicated files. It would cost
more than 10 minutes to analyze 11,000 files before, now only needs
about 50 seconds.
* Check the access time rather than create time.
* Need the user's confirm before really remove the file, or use --yes to
assume yes.
* Add --stamps-dir to keep sstate files which are used by the build
directory, and remove others this can make the sstate cache dir clean,
it is faster and should be useful than the --remove-duplicated.
* Add --verbose to explain what is being done.
* Add "-d" which is short for --remove-duplicated
[YOCTO #2198]
(From OE-Core rev: 769a000428e4b2462a4e6d8f179b5816b8ec2417)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-30 06:44:31 +00:00
|
|
|
[ "$rm_duplicated" = "y" ] && remove_duplicated
|
|
|
|
[ -n "$stamps" ] && rm_by_stamps
|
|
|
|
[ -z "$rm_duplicated" -a -z "$stamps" ] && \
|
|
|
|
echo "What do you want to do?"
|
2013-04-05 07:22:58 +00:00
|
|
|
exit 0
|