diff --git a/layerindex/update.py b/layerindex/update.py index b7d1ec9..8df34d9 100755 --- a/layerindex/update.py +++ b/layerindex/update.py @@ -16,6 +16,8 @@ import subprocess from datetime import datetime import fnmatch import re +import tempfile +import shutil from distutils.version import LooseVersion def logger_create(): @@ -268,6 +270,12 @@ def main(): out = runcmd("git clean -f -x", core_repodir) os.environ['BBPATH'] = str("%s:%s" % (os.path.realpath('.'), core_layerdir)) + # Change into a temporary directory so we don't write the cache and other files to the current dir + if not os.path.exists(settings.TEMP_BASE_DIR): + os.makedirs(settings.TEMP_BASE_DIR) + tempdir = tempfile.mkdtemp(dir=settings.TEMP_BASE_DIR) + os.chdir(tempdir) + sys.path.extend([bitbakepath + '/lib']) import bb.tinfoil import bb.cooker @@ -478,6 +486,7 @@ def main(): finally: transaction.leave_transaction_management() + shutil.rmtree(tempdir) sys.exit(0) diff --git a/settings.py b/settings.py index 2343885..298cde6 100644 --- a/settings.py +++ b/settings.py @@ -176,6 +176,9 @@ LOGIN_REDIRECT_URL = '/layerindex' # Full path to directory where layers should be fetched into by the update script LAYER_FETCH_DIR = "" +# Base temporary directory in which to create a directory in which to run BitBake +TEMP_BASE_DIR = "/tmp" + # Fetch URL of the BitBake repository for the update script BITBAKE_REPO_URL = "git://git.openembedded.org/bitbake"