summaryrefslogtreecommitdiff
path: root/scripts/cleanup-workdir
diff options
context:
space:
mode:
authorKang Kai <kai.kang@windriver.com>2012-06-15 11:06:54 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-18 13:16:37 +0100
commita16727ebc341e0a0ce59a5200dc774cf672593ee (patch)
treefbcdeb81c7a663237caa3c46e4c49c56bb0759a7 /scripts/cleanup-workdir
parent33f18965bbeeec47f694f2aa165e5e07eadb7ab7 (diff)
downloadopenembedded-core-a16727ebc341e0a0ce59a5200dc774cf672593ee.tar.gz
openembedded-core-a16727ebc341e0a0ce59a5200dc774cf672593ee.tar.bz2
openembedded-core-a16727ebc341e0a0ce59a5200dc774cf672593ee.zip
cleanup-workdir: only deal dirs related to current arch
Some users may build for different archs under same workdir, so they don't want to clean the dirs not related to current arch. Run command 'bitbake -e' with selected packages to get the dirs related to current arch then clean them. Update the way to get the WORKDIR by parsing the IMAGE_ROOTFS by the way. Signed-off-by: Kang Kai <kai.kang@windriver.com>
Diffstat (limited to 'scripts/cleanup-workdir')
-rwxr-xr-xscripts/cleanup-workdir54
1 files changed, 49 insertions, 5 deletions
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
index 1e9c56dcf6..156a2597c1 100755
--- a/scripts/cleanup-workdir
+++ b/scripts/cleanup-workdir
@@ -47,6 +47,19 @@ def run_command(cmd):
sys.exit(1)
return output
+def get_cur_arch_dirs(workdir, arch_dirs):
+ pattern = workdir + '/(.*?)/'
+
+ # select thest 5 packages to get the dirs of current arch
+ pkgs = ['hicolor-icon-theme', 'base-files', 'acl-native', 'binutils-crosssdk', 'autoconf-nativesdk']
+
+ for pkg in pkgs:
+ cmd = "bitbake -e " + pkg + " | grep ^IMAGE_ROOTFS="
+ output = run_command(cmd)
+ output = output.split('"')[1]
+ m = re.match(pattern, output)
+ arch_dirs.append(m.group(1))
+
def main():
global parser
parser = optparse.OptionParser(
@@ -87,21 +100,52 @@ This script must be ran under BUILDDIR after source file \"oe-init-build-env\"."
version = parse_version(elems[2])
pkg_cur_dirs.append(elems[0] + '-' + version)
- cmd = "bitbake -e | grep ^TMPDIR"
+ cmd = "bitbake -e"
output = run_command(cmd)
- tmpdir = output.split('"')[1]
- workdir = os.path.join(tmpdir, 'work')
- if not os.path.exists(workdir):
- print "WORKDIR %s does NOT exist. Quit." % workdir
+ tmpdir = None
+ image_rootfs = None
+ output = output.split('\n')
+ for line in output:
+ if tmpdir and image_rootfs:
+ break
+
+ if not tmpdir:
+ m = re.match('TMPDIR="(.*)"', line)
+ if m:
+ tmpdir = m.group(1)
+
+ if not image_rootfs:
+ m = re.match('IMAGE_ROOTFS="(.*)"', line)
+ if m:
+ image_rootfs = m.group(1)
+
+ # won't fail just in case
+ if not tmpdir or not image_rootfs:
+ print "Can't get TMPDIR or IMAGE_ROOTFS."
+ return 1
+
+ pattern = tmpdir + '/(.*?)/(.*?)/'
+ m = re.match(pattern, image_rootfs)
+ if not m:
+ print "Can't get WORKDIR."
return 1
+ workdir = os.path.join(tmpdir, m.group(1))
+
+ # we only deal the dirs of current arch, total numbers of dirs are 6
+ cur_arch_dirs = [m.group(2)]
+ get_cur_arch_dirs(workdir, cur_arch_dirs)
+
for workroot, dirs, files in os.walk(workdir):
# For the files, they should NOT exist in WORKDIR. Romve them.
for f in files:
obsolete_dirs.append(os.path.join(workroot, f))
for d in dirs:
+ if d not in cur_arch_dirs:
+ continue
+
for pkgroot, pkgdirs, filenames in os.walk(os.path.join(workroot, d)):
for f in filenames:
obsolete_dirs.append(os.path.join(pkgroot, f))