summaryrefslogtreecommitdiffstats
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:24:57 +0100
commit3360a4f1b3b4b73e01fc4a05ce4b83ffa010a744 (patch)
treee585ca874fcdc21eb3182a3ecbba9e2211a0ef3e /scripts/cleanup-workdir
parent21d84d2fe3ac4a73f6477bd87ef459969d0d8850 (diff)
downloadast2050-yocto-poky-3360a4f1b3b4b73e01fc4a05ce4b83ffa010a744.zip
ast2050-yocto-poky-3360a4f1b3b4b73e01fc4a05ce4b83ffa010a744.tar.gz
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. (From OE-Core rev: a16727ebc341e0a0ce59a5200dc774cf672593ee) Signed-off-by: Kang Kai <kai.kang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 1e9c56d..156a259 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))
OpenPOWER on IntegriCloud