* [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR
2012-03-06 5:43 [PATCH 0/1] Yocoto 1561: clean up the workdir Kang Kai
@ 2012-03-06 5:44 ` Kang Kai
0 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-03-06 5:44 UTC (permalink / raw)
To: richard.purdie, poky
[Yocto 1561]
Add script cleanup-workdir to clean up WORKDIR. It checks every
package build directories under WORKDIR then parse the directory
name to get package name and version. If the version is not the
package prefer version then delete the directory.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
scripts/cleanup-workdir | 149 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 149 insertions(+), 0 deletions(-)
create mode 100755 scripts/cleanup-workdir
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
new file mode 100755
index 0000000..15bc99c
--- /dev/null
+++ b/scripts/cleanup-workdir
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+
+# 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
+
+import os
+import sys
+import optparse
+import re
+import logging
+
+logger = logging.getLogger("Bitbake")
+
+versions = {}
+obsolete_dirs = []
+verfile = '/tmp/bitbake-s.%d' % os.getpid()
+
+def err_quit(msg):
+ print msg
+ try:
+ os.remove(verfile)
+ except:
+ pass
+ sys.exit(1)
+
+def parse_version(verstr):
+ elems = verstr.split(':')
+ epoch = elems[0]
+ if len(epoch) == 0:
+ return elems[1]
+ else:
+ return epoch + '_' + elems[1]
+
+def parse_dir(match, pkgabsdir):
+ pkg_name = match.group(1)
+ pkg_version = match.group(2)
+ if pkg_name in versions:
+ if pkg_version != versions[pkg_name]:
+ obsolete_dirs.append(pkgabsdir)
+ return True
+ return False
+
+def main():
+ parser = optparse.OptionParser(
+ usage = """%prog [options] [BUILDDIR]
+
+Remove the obsolete packages' build directories in WORKDIR.
+If BUILDDIR is not appended, current directory is treated as build directory.""")
+
+ parser.add_option("-i", "--initenv", help = "The file oe-init-build-env which needs to be sourced before run bitbake",
+ action = "store", dest = "envfile", default = None)
+
+ options, args = parser.parse_args(sys.argv)
+
+ builddir = None
+ if len(args) > 1:
+ builddir = args[1]
+ if not builddir and os.path.exists('tmp/work'):
+ builddir = os.getcwd()
+ if not builddir:
+ err_quit("Current directory is not a valid build directory. Please input a valid build diretory.")
+
+ envfile = options.__dict__['envfile']
+ if not envfile:
+ envfile = os.path.join(builddir, "../oe-init-build-env")
+ if not os.path.exists(envfile):
+ err_quit("Can't find file oe-init-build-env.")
+
+ print 'Updating bitbake caches...'
+ cmd = "source %s . &>/dev/null && bitbake -s > %s " % (envfile, verfile)
+ ret = os.system(cmd)
+ if ret != 0:
+ print "Execute 'bitbake -s' failed. Can't get packages' versions."
+ return 1
+
+ fverfile = open(verfile, 'r')
+ alllines = fverfile.readlines()
+ fverfile.close()
+
+ alllines = alllines[5:]
+ for line in alllines:
+ line = line.strip()
+ line = re.sub('\s+', ' ', line)
+ elems = line.split(' ')
+ if len(elems) == 2:
+ version = parse_version(elems[1])
+ else:
+ version = parse_version(elems[2])
+ versions[elems[0]] = version
+
+ workdir = os.path.join(builddir, 'tmp/work')
+ for archdir in os.listdir(workdir):
+ archdir = os.path.join(workdir, archdir)
+ if not os.path.isdir(archdir):
+ pass
+
+ for pkgdir in sorted(os.listdir(archdir)):
+ pkgabsdir = os.path.join(archdir, pkgdir)
+ if not os.path.isdir(pkgabsdir):
+ pass
+
+ # parse the package directory names
+ # parse native/nativesdk packages first
+ match = re.match('(.*?-native.*?)-(.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # parse package names which ends with numbers such as 'glib-2.0'
+ match = re.match('(.*?-[\.\d]+)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # other packages
+ match = re.match('(.*?)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ for d in obsolete_dirs:
+ print "Deleleting %s" % d
+ shutil.rmtree(d, True)
+ os.remove(verfile)
+
+ if len(obsolete_dirs):
+ print '\nTotal %d items.' % len(obsolete_dirs)
+ else:
+ print '\nNo obsolete directory found under %s.' % workdir
+
+ return 0
+
+if __name__ == '__main__':
+ try:
+ ret = main()
+ except Exception:
+ ret = 2
+ import traceback
+ traceback.print_exc(3)
+ sys.exit(ret)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 0/1] V2: Yocoto 1561: clean up the workdir
@ 2012-03-06 6:36 Kang Kai
2012-03-06 6:36 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
2012-03-09 1:47 ` [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
0 siblings, 2 replies; 6+ messages in thread
From: Kang Kai @ 2012-03-06 6:36 UTC (permalink / raw)
To: richard.purdie, poky
Hi Richard,
Forget to import shutil, just add it.
V1:
This time I write it as a seperated script.
Would you like to help me review it? Thanks.
Regards,
The following changes since commit a8dc76ee69cfe1ffe846c07a510e3a562a5b1a7f:
base.bbclass: Fix PACKAGECONFIG handling when no flags are set (2012-03-05 13:04:11 -0800)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib kangkai/cleanup
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro
Kang Kai (1):
cleanup-workdir: add a script to clean up WORKDIR
scripts/cleanup-workdir | 147 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 147 insertions(+), 0 deletions(-)
create mode 100755 scripts/cleanup-workdir
--
1.7.5.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR
2012-03-06 6:36 [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
@ 2012-03-06 6:36 ` Kang Kai
2012-03-13 17:52 ` Richard Purdie
2012-03-09 1:47 ` [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
1 sibling, 1 reply; 6+ messages in thread
From: Kang Kai @ 2012-03-06 6:36 UTC (permalink / raw)
To: richard.purdie, poky
[Yocto 1561]
Add script cleanup-workdir to clean up WORKDIR. It checks every
package build directories under WORKDIR then parse the directory
name to get package name and version. If the version is not the
package prefer version then delete the directory.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
scripts/cleanup-workdir | 147 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 147 insertions(+), 0 deletions(-)
create mode 100755 scripts/cleanup-workdir
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
new file mode 100755
index 0000000..5827ff9
--- /dev/null
+++ b/scripts/cleanup-workdir
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+
+# 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
+
+import os
+import sys
+import optparse
+import re
+import shutil
+
+versions = {}
+obsolete_dirs = []
+verfile = '/tmp/bitbake-s.%d' % os.getpid()
+
+def err_quit(msg):
+ print msg
+ try:
+ os.remove(verfile)
+ except:
+ pass
+ sys.exit(1)
+
+def parse_version(verstr):
+ elems = verstr.split(':')
+ epoch = elems[0]
+ if len(epoch) == 0:
+ return elems[1]
+ else:
+ return epoch + '_' + elems[1]
+
+def parse_dir(match, pkgabsdir):
+ pkg_name = match.group(1)
+ pkg_version = match.group(2)
+ if pkg_name in versions:
+ if pkg_version != versions[pkg_name]:
+ obsolete_dirs.append(pkgabsdir)
+ return True
+ return False
+
+def main():
+ parser = optparse.OptionParser(
+ usage = """%prog [options] [BUILDDIR]
+
+Remove the obsolete packages' build directories in WORKDIR.
+If BUILDDIR is not appended, current directory is treated as build directory.""")
+
+ parser.add_option("-i", "--initenv", help = "The file oe-init-build-env which needs to be sourced before run bitbake",
+ action = "store", dest = "envfile", default = None)
+
+ options, args = parser.parse_args(sys.argv)
+
+ builddir = None
+ if len(args) > 1:
+ builddir = args[1]
+ if not builddir and os.path.exists('tmp/work'):
+ builddir = os.getcwd()
+ if not builddir:
+ err_quit("Current directory is not a valid build directory. Please input a valid build diretory.")
+
+ envfile = options.__dict__['envfile']
+ if not envfile:
+ envfile = os.path.join(builddir, "../oe-init-build-env")
+ if not os.path.exists(envfile):
+ err_quit("Can't find file oe-init-build-env.")
+
+ print 'Updating bitbake caches...'
+ cmd = "source %s . &>/dev/null && bitbake -s > %s " % (envfile, verfile)
+ ret = os.system(cmd)
+ if ret != 0:
+ print "Execute 'bitbake -s' failed. Can't get packages' versions."
+ return 1
+
+ fverfile = open(verfile, 'r')
+ alllines = fverfile.readlines()
+ fverfile.close()
+
+ alllines = alllines[5:]
+ for line in alllines:
+ line = line.strip()
+ line = re.sub('\s+', ' ', line)
+ elems = line.split(' ')
+ if len(elems) == 2:
+ version = parse_version(elems[1])
+ else:
+ version = parse_version(elems[2])
+ versions[elems[0]] = version
+
+ workdir = os.path.join(builddir, 'tmp/work')
+ for archdir in os.listdir(workdir):
+ archdir = os.path.join(workdir, archdir)
+ if not os.path.isdir(archdir):
+ pass
+
+ for pkgdir in sorted(os.listdir(archdir)):
+ pkgabsdir = os.path.join(archdir, pkgdir)
+ if not os.path.isdir(pkgabsdir):
+ pass
+
+ # parse the package directory names
+ # parse native/nativesdk packages first
+ match = re.match('(.*?-native.*?)-(.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # parse package names which ends with numbers such as 'glib-2.0'
+ match = re.match('(.*?-[\.\d]+)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # other packages
+ match = re.match('(.*?)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ for d in obsolete_dirs:
+ print "Deleleting %s" % d
+ shutil.rmtree(d, True)
+ os.remove(verfile)
+
+ if len(obsolete_dirs):
+ print '\nTotal %d items.' % len(obsolete_dirs)
+ else:
+ print '\nNo obsolete directory found under %s.' % workdir
+
+ return 0
+
+if __name__ == '__main__':
+ try:
+ ret = main()
+ except Exception:
+ ret = 2
+ import traceback
+ traceback.print_exc(3)
+ sys.exit(ret)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/1] V2: Yocoto 1561: clean up the workdir
2012-03-06 6:36 [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
2012-03-06 6:36 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
@ 2012-03-09 1:47 ` Kang Kai
1 sibling, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-03-09 1:47 UTC (permalink / raw)
To: richard.purdie; +Cc: poky
Hi Richard,
Would you please comment this patch?
Thanks.
Kai
> Hi Richard,
>
> Forget to import shutil, just add it.
>
> V1:
> This time I write it as a seperated script.
> Would you like to help me review it? Thanks.
>
> Regards,
>
> The following changes since commit a8dc76ee69cfe1ffe846c07a510e3a562a5b1a7f:
>
> base.bbclass: Fix PACKAGECONFIG handling when no flags are set (2012-03-05 13:04:11 -0800)
>
> are available in the git repository at:
> git://git.pokylinux.org/poky-contrib kangkai/cleanup
> http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro
>
> Kang Kai (1):
> cleanup-workdir: add a script to clean up WORKDIR
>
> scripts/cleanup-workdir | 147 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 147 insertions(+), 0 deletions(-)
> create mode 100755 scripts/cleanup-workdir
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR
2012-03-06 6:36 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
@ 2012-03-13 17:52 ` Richard Purdie
0 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2012-03-13 17:52 UTC (permalink / raw)
To: Kang Kai; +Cc: poky
On Tue, 2012-03-06 at 14:36 +0800, Kang Kai wrote:
> [Yocto 1561]
> Add script cleanup-workdir to clean up WORKDIR. It checks every
> package build directories under WORKDIR then parse the directory
> name to get package name and version. If the version is not the
> package prefer version then delete the directory.
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
> scripts/cleanup-workdir | 147 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 147 insertions(+), 0 deletions(-)
> create mode 100755 scripts/cleanup-workdir
>
> diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
> new file mode 100755
> index 0000000..5827ff9
> --- /dev/null
> +++ b/scripts/cleanup-workdir
> @@ -0,0 +1,147 @@
> +#!/usr/bin/env python
> +
> +# 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
> +
> +import os
> +import sys
> +import optparse
> +import re
> +import shutil
> +
> +versions = {}
> +obsolete_dirs = []
> +verfile = '/tmp/bitbake-s.%d' % os.getpid()
> +
> +def err_quit(msg):
> + print msg
> + try:
> + os.remove(verfile)
> + except:
> + pass
> + sys.exit(1)
> +
> +def parse_version(verstr):
> + elems = verstr.split(':')
> + epoch = elems[0]
> + if len(epoch) == 0:
> + return elems[1]
> + else:
> + return epoch + '_' + elems[1]
> +
> +def parse_dir(match, pkgabsdir):
> + pkg_name = match.group(1)
> + pkg_version = match.group(2)
> + if pkg_name in versions:
> + if pkg_version != versions[pkg_name]:
> + obsolete_dirs.append(pkgabsdir)
> + return True
> + return False
> +
> +def main():
> + parser = optparse.OptionParser(
> + usage = """%prog [options] [BUILDDIR]
> +
> +Remove the obsolete packages' build directories in WORKDIR.
> +If BUILDDIR is not appended, current directory is treated as build directory.""")
> +
> + parser.add_option("-i", "--initenv", help = "The file oe-init-build-env which needs to be sourced before run bitbake",
> + action = "store", dest = "envfile", default = None)
> +
> + options, args = parser.parse_args(sys.argv)
> +
> + builddir = None
> + if len(args) > 1:
> + builddir = args[1]
> + if not builddir and os.path.exists('tmp/work'):
> + builddir = os.getcwd()
> + if not builddir:
> + err_quit("Current directory is not a valid build directory. Please input a valid build diretory.")
> +
> + envfile = options.__dict__['envfile']
> + if not envfile:
> + envfile = os.path.join(builddir, "../oe-init-build-env")
> + if not os.path.exists(envfile):
> + err_quit("Can't find file oe-init-build-env.")
> +
> + print 'Updating bitbake caches...'
> + cmd = "source %s . &>/dev/null && bitbake -s > %s " % (envfile, verfile)
> + ret = os.system(cmd)
> + if ret != 0:
> + print "Execute 'bitbake -s' failed. Can't get packages' versions."
> + return 1
> +
> + fverfile = open(verfile, 'r')
> + alllines = fverfile.readlines()
> + fverfile.close()
> +
> + alllines = alllines[5:]
> + for line in alllines:
> + line = line.strip()
> + line = re.sub('\s+', ' ', line)
> + elems = line.split(' ')
> + if len(elems) == 2:
> + version = parse_version(elems[1])
> + else:
> + version = parse_version(elems[2])
> + versions[elems[0]] = version
> +
> + workdir = os.path.join(builddir, 'tmp/work')
This looks reasonable to me but we should ask bitbake what WORKDIR is
rather than hardcode this here.
Otherwise it looks like a reasonable place to start with this.
Cheers,
Richard
> + for archdir in os.listdir(workdir):
> + archdir = os.path.join(workdir, archdir)
> + if not os.path.isdir(archdir):
> + pass
> +
> + for pkgdir in sorted(os.listdir(archdir)):
> + pkgabsdir = os.path.join(archdir, pkgdir)
> + if not os.path.isdir(pkgabsdir):
> + pass
> +
> + # parse the package directory names
> + # parse native/nativesdk packages first
> + match = re.match('(.*?-native.*?)-(.*)', pkgdir)
> + if match and parse_dir(match, pkgabsdir):
> + continue
> +
> + # parse package names which ends with numbers such as 'glib-2.0'
> + match = re.match('(.*?-[\.\d]+)-(\d.*)', pkgdir)
> + if match and parse_dir(match, pkgabsdir):
> + continue
> +
> + # other packages
> + match = re.match('(.*?)-(\d.*)', pkgdir)
> + if match and parse_dir(match, pkgabsdir):
> + continue
> +
> + for d in obsolete_dirs:
> + print "Deleleting %s" % d
> + shutil.rmtree(d, True)
> + os.remove(verfile)
> +
> + if len(obsolete_dirs):
> + print '\nTotal %d items.' % len(obsolete_dirs)
> + else:
> + print '\nNo obsolete directory found under %s.' % workdir
> +
> + return 0
> +
> +if __name__ == '__main__':
> + try:
> + ret = main()
> + except Exception:
> + ret = 2
> + import traceback
> + traceback.print_exc(3)
> + sys.exit(ret)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR
2012-03-16 7:57 [PATCH 0/1] V3: " Kang Kai
@ 2012-03-16 7:57 ` Kang Kai
0 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-03-16 7:57 UTC (permalink / raw)
To: richard.purdie, poky
[Yocto 1561]
Add script cleanup-workdir to clean up WORKDIR. It checks every
package build directories under WORKDIR then parse the directory
name to get package name and version. If the version is not the
package prefer version then delete the directory.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
scripts/cleanup-workdir | 150 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 150 insertions(+), 0 deletions(-)
create mode 100755 scripts/cleanup-workdir
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
new file mode 100755
index 0000000..b77e8c6
--- /dev/null
+++ b/scripts/cleanup-workdir
@@ -0,0 +1,150 @@
+#!/usr/bin/env python
+
+# 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
+
+import os
+import sys
+import optparse
+import re
+import commands
+import shutil
+
+versions = {}
+obsolete_dirs = []
+parser = None
+
+def err_quit(msg):
+ print msg
+ parser.print_usage()
+ sys.exit(1)
+
+def parse_version(verstr):
+ elems = verstr.split(':')
+ epoch = elems[0]
+ if len(epoch) == 0:
+ return elems[1]
+ else:
+ return epoch + '_' + elems[1]
+
+def parse_dir(match, pkgabsdir):
+ pkg_name = match.group(1)
+ pkg_version = match.group(2)
+ if pkg_name in versions:
+ if pkg_version != versions[pkg_name]:
+ obsolete_dirs.append(pkgabsdir)
+ return True
+ return False
+
+def main():
+ global parser
+ parser = optparse.OptionParser(
+ usage = """%prog
+
+Remove the obsolete packages' build directories in WORKDIR.
+This script must be ran under BUILDDIR after source file \"oe-init-build-env\".""")
+
+ options, args = parser.parse_args(sys.argv)
+
+ builddir = commands.getoutput('echo $BUILDDIR')
+ if len(builddir) == 0:
+ err_quit("Please source file \"oe-init-build-env\" first.\n")
+
+ if os.getcwd() != builddir:
+ err_quit("Please run %s under: %s\n" % (os.path.basename(args[0]), builddir))
+
+ print 'Updating bitbake caches...'
+ cmd = "bitbake -s"
+ (ret, output) = commands.getstatusoutput(cmd)
+ if ret != 0:
+ print "Execute 'bitbake -s' failed. Can't get packages' versions."
+ return 1
+
+ output = output.split('\n')
+ index = 0
+ while len(output[index]) > 0:
+ index += 1
+ alllines = output[index+1:]
+
+ for line in alllines:
+ # empty again means end of the versions output
+ if len(line) == 0:
+ break
+ line = line.strip()
+ line = re.sub('\s+', ' ', line)
+ elems = line.split(' ')
+ if len(elems) == 2:
+ version = parse_version(elems[1])
+ else:
+ version = parse_version(elems[2])
+ versions[elems[0]] = version
+
+ cmd = "bitbake -e | grep ^TMPDIR"
+ (ret, output) = commands.getstatusoutput(cmd)
+ if ret != 0:
+ print "Execute 'bitbke -e' failed. Can't get TMPDIR."
+ return 1
+
+ tmpdir = output.split('"')[1]
+ workdir = os.path.join(tmpdir, 'work')
+ if not os.path.exists(workdir):
+ print "WORKDIR %s does NOT exist. Quit." % workdir
+ return 1
+
+ for archdir in os.listdir(workdir):
+ archdir = os.path.join(workdir, archdir)
+ if not os.path.isdir(archdir):
+ pass
+
+ for pkgdir in sorted(os.listdir(archdir)):
+ pkgabsdir = os.path.join(archdir, pkgdir)
+ if not os.path.isdir(pkgabsdir):
+ pass
+
+ # parse the package directory names
+ # parse native/nativesdk packages first
+ match = re.match('(.*?-native.*?)-(.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # parse package names which ends with numbers such as 'glib-2.0'
+ match = re.match('(.*?-[\.\d]+)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ # other packages
+ match = re.match('(.*?)-(\d.*)', pkgdir)
+ if match and parse_dir(match, pkgabsdir):
+ continue
+
+ for d in obsolete_dirs:
+ print "Deleleting %s" % d
+ shutil.rmtree(d, True)
+
+ if len(obsolete_dirs):
+ print '\nTotal %d items.' % len(obsolete_dirs)
+ else:
+ print '\nNo obsolete directory found under %s.' % workdir
+
+ return 0
+
+if __name__ == '__main__':
+ try:
+ ret = main()
+ except Exception:
+ ret = 2
+ import traceback
+ traceback.print_exc(3)
+ sys.exit(ret)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-16 7:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 6:36 [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
2012-03-06 6:36 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
2012-03-13 17:52 ` Richard Purdie
2012-03-09 1:47 ` [PATCH 0/1] V2: Yocoto 1561: clean up the workdir Kang Kai
-- strict thread matches above, loose matches on Subject: below --
2012-03-16 7:57 [PATCH 0/1] V3: " Kang Kai
2012-03-16 7:57 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
2012-03-06 5:43 [PATCH 0/1] Yocoto 1561: clean up the workdir Kang Kai
2012-03-06 5:44 ` [PATCH 1/1] cleanup-workdir: add a script to clean up WORKDIR Kang Kai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.