def _verify_be(): is_changed = False def _update_sourcedir(): be.sourcedir = os.environ.get('TOASTER_DIR') return True if len(be.sourcedir) == 0: print "\n -- Validation: The layers checkout directory must be set." is_changed = _update_sourcedir() if not be.sourcedir.startswith("/"): print "\n -- Validation: The layers checkout directory must be set to an absolute path." is_changed = _update_sourcedir() if is_changed: if be.betype == BuildEnvironment.TYPE_LOCAL: be.needs_import = True return True def _update_builddir(): be.builddir = os.environ.get('TOASTER_DIR') + "/build" return True if len(be.builddir) == 0: print "\n -- Validation: The build directory must be set." is_changed = _update_builddir() if not be.builddir.startswith("/"): print "\n -- Validation: The build directory must to be set to an absolute path." is_changed = _update_builddir() if is_changed: print "\nBuild configuration saved" be.save() return True if be.needs_import: try: config_file = os.environ.get('TOASTER_CONF') print "\nImporting file: %s" % config_file from loadconf import Command as LoadConfigCommand LoadConfigCommand()._import_layer_config(config_file) # we run lsupdates after config update print "\nLayer configuration imported. Updating information from the layer sources, please wait.\nYou can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates" from django.core.management import call_command call_command("lsupdates") # we don't look for any other config files return is_changed except Exception as e: print "Failure while trying to import the toaster config file %s: %s" %\ (config_file, e) traceback.print_exc(e) return is_changed
def _verify_be(): is_changed = False print("Verifying the Build Environment type %s id %d." % (be.get_betype_display(), be.pk)) if len(be.sourcedir) == 0: suggesteddir = self._get_suggested_sourcedir(be) be.sourcedir = raw_input(" -- Layer sources checkout directory may not be empty [guessed \"%s\"]:" % suggesteddir) if len(be.sourcedir) == 0 and len(suggesteddir) > 0: be.sourcedir = suggesteddir is_changed = True if not be.sourcedir.startswith("/"): be.sourcedir = raw_input(" -- Layer sources checkout directory must be an absolute path:") is_changed = True if len(be.builddir) == 0: suggesteddir = self._get_suggested_builddir(be) be.builddir = raw_input(" -- Build directory may not be empty [guessed \"%s\"]:" % suggesteddir) if len(be.builddir) == 0 and len(suggesteddir) > 0: be.builddir = suggesteddir is_changed = True if not be.builddir.startswith("/"): be.builddir = raw_input(" -- Build directory must be an absolute path:") is_changed = True if is_changed: print "Build configuration saved" be.save() if is_changed and be.betype == BuildEnvironment.TYPE_LOCAL: for dirname in self._recursive_list_directories(be.sourcedir,2): if os.path.exists(os.path.join(dirname, ".templateconf")): import subprocess conffilepath, error = subprocess.Popen('bash -c ". '+os.path.join(dirname, ".templateconf")+'; echo \"\$TEMPLATECONF\""', shell=True, stdout=subprocess.PIPE).communicate() conffilepath = os.path.join(conffilepath.strip(), "toasterconf.json") candidatefilepath = os.path.join(dirname, conffilepath) if os.path.exists(candidatefilepath): i = raw_input(" -- Do you want to import basic layer configuration from \"%s\" ? (y/N):" % candidatefilepath) if len(i) and i.upper()[0] == 'Y': from loadconf import Command as LoadConfigCommand LoadConfigCommand()._import_layer_config(candidatefilepath) # we run lsupdates after config update print "Layer configuration imported. Updating information from the layer source, please wait." from django.core.management import call_command call_command("lsupdates") # we don't look for any other config files return is_changed return is_changed
def _verify_be(): is_changed = False print( "Verifying the Build Environment. If the local Build Environment is not properly configured, you will be asked to configure it." ) def _update_sourcedir(): suggesteddir = self._get_suggested_sourcedir(be) if len(suggesteddir) > 0: be.sourcedir = raw_input( "Toaster needs to know in which directory it should check out the layers that will be needed for your builds.\n Toaster suggests \"%s\". If you select this directory, a layer like \"meta-intel\" will end up in \"%s/meta-intel\".\n Press Enter to select \"%s\" or type the full path to a different directory (must be a parent of current checkout directory): " % (suggesteddir, suggesteddir, suggesteddir)) else: be.sourcedir = raw_input( "Toaster needs to know in which directory it should check out the layers that will be needed for your builds. Type the full path to the directory (for example: \"%s\": " % os.environ.get('HOME', '/tmp/')) if len(be.sourcedir) == 0 and len(suggesteddir) > 0: be.sourcedir = suggesteddir return True if len(be.sourcedir) == 0: print "\n -- Validation: The checkout directory must be set." is_changed = _update_sourcedir() if not be.sourcedir.startswith("/"): print "\n -- Validation: The checkout directory must be set to an absolute path." is_changed = _update_sourcedir() if not be.sourcedir in DN(__file__): print "\n -- Validation: The checkout directory must be a parent of the current checkout." is_changed = _update_sourcedir() if is_changed: if be.betype == BuildEnvironment.TYPE_LOCAL: be.needs_import = True return True def _update_builddir(): suggesteddir = self._get_suggested_builddir(be) if len(suggesteddir) > 0: be.builddir = raw_input( "Toaster needs to know where your build directory is located.\n The build directory is where all the artifacts created by your builds will be stored. Toaster suggests \"%s\".\n Press Enter to select \"%s\" or type the full path to a different directory: " % (suggesteddir, suggesteddir)) else: be.builddir = raw_input( "Toaster needs to know where is your build directory.\n The build directory is where all the artifacts created by your builds will be stored. Type the full path to the directory (for example: \" %s/build\")" % os.environ.get('HOME', '/tmp/')) if len(be.builddir) == 0 and len(suggesteddir) > 0: be.builddir = suggesteddir return True if len(be.builddir) == 0: print "\n -- Validation: The build directory must be set." is_changed = _update_builddir() if not be.builddir.startswith("/"): print "\n -- Validation: The build directory must to be set to an absolute path." is_changed = _update_builddir() if is_changed: print "Build configuration saved" be.save() return True if be.needs_import: print "\nToaster can use a SINGLE predefined configuration file to set up default project settings and layer information sources.\n" # find configuration files config_files = [] for dirname in self._recursive_list_directories( be.sourcedir, 2): if os.path.exists( os.path.join(dirname, ".templateconf")): import subprocess proc = subprocess.Popen( 'bash -c ". ' + os.path.join(dirname, ".templateconf") + '; echo \"\$TEMPLATECONF\""', shell=True, stdout=subprocess.PIPE) conffilepath, stderroroutput = proc.communicate() proc.wait() if proc.returncode != 0: raise Exception( "Failed to source TEMPLATECONF: %s" % stderroroutput) conffilepath = os.path.join( conffilepath.strip(), "toasterconf.json") candidatefilepath = os.path.join( dirname, conffilepath) if "toaster_cloned" in candidatefilepath: continue if os.path.exists(candidatefilepath): config_files.append(candidatefilepath) if len(config_files) > 0: print " Toaster will list now the configuration files that it found. Select the number to use the desired configuration file." for cf in config_files: print " [%d] - %s" % (config_files.index(cf) + 1, cf) print "\n [0] - Exit without importing any file" try: i = raw_input("\n Enter your option: ") if len(i) and (int(i) - 1 >= 0 and int(i) - 1 < len(config_files)): print "Importing file: %s" % config_files[ int(i) - 1] from loadconf import Command as LoadConfigCommand LoadConfigCommand()._import_layer_config( config_files[int(i) - 1]) # we run lsupdates after config update print "Layer configuration imported. Updating information from the layer sources, please wait.\n You can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates" from django.core.management import call_command call_command("lsupdates") # we don't look for any other config files return is_changed except Exception as e: print "Failure while trying to import the toaster config file: %s" % e traceback.print_exc(e) else: print "\n Toaster could not find a configuration file. You need to configure Toaster manually using the web interface, or create a configuration file and use\n bitbake/lib/toaster/managepy.py loadconf [filename]\n command to load it. You can use https://wiki.yoctoproject.org/wiki/File:Toasterconf.json.txt.patch as a starting point." return is_changed