def set_portage_overlay(self): StageBase.set_portage_overlay(self) if "portage_overlay" in self.settings: log.warning( 'Using an overlay for earlier stages could cause build issues.\n' "If you break it, you buy it. Don't complain to us about it.\n" "Don't say we did not warn you.")
def empty(self): if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("empty"): log.notice('Resume point detected, skipping empty operation...') else: if "netboot2/empty" in self.settings: if isinstance(self.settings['netboot2/empty'], str): self.settings["netboot2/empty"] = self.settings[ "netboot2/empty"].split() for x in self.settings["netboot2/empty"]: myemp = self.settings["chroot_path"] + self.settings[ "merge_path"] + x if not os.path.isdir(myemp): log.warning( 'not a directory or does not exist, skipping "empty" operation: %s', x) continue log.info('Emptying directory %s', x) # stat the dir, delete the dir, recreate the dir and set # the proper perms and ownership mystat = os.stat(myemp) shutil.rmtree(myemp) ensure_dirs(myemp, mode=0o755) os.chown(myemp, mystat[ST_UID], mystat[ST_GID]) os.chmod(myemp, mystat[ST_MODE]) self.resume.enable("empty")
def empty(self): if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("empty"): log.notice('Resume point detected, skipping empty operation...') else: if "netboot2/empty" in self.settings: if isinstance(self.settings['netboot2/empty'], str): self.settings["netboot2/empty"]=self.settings["netboot2/empty"].split() for x in self.settings["netboot2/empty"]: myemp=self.settings["chroot_path"] + self.settings["merge_path"] + x if not os.path.isdir(myemp): log.warning('not a directory or does not exist, skipping "empty" operation: %s', x) continue log.info('Emptying directory %s', x) # stat the dir, delete the dir, recreate the dir and set # the proper perms and ownership clear_dir(myemp) self.resume.enable("empty")
def move_path(src, dest): '''Move a source target to a new destination :param src: source path to move :param dest: destination path to move it to :returns: boolean ''' log.debug('Start move_path(%s, %s)', src, dest) if os.path.isdir(src) and not os.path.islink(src): if os.path.exists(dest): log.warning('Removing existing target destination: %s', dest) if not clear_dir(dest, remove=True): return False log.debug('Moving source...') try: shutil.move(src, dest) except Exception: log.error('move_path failed', exc_info=True) return False return True return False
def empty(self): if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("empty"): log.notice('Resume point detected, skipping empty operation...') else: if "netboot2/empty" in self.settings: if isinstance(self.settings['netboot2/empty'], str): self.settings["netboot2/empty"]=self.settings["netboot2/empty"].split() for x in self.settings["netboot2/empty"]: myemp=self.settings["chroot_path"] + self.settings["merge_path"] + x if not os.path.isdir(myemp): log.warning('not a directory or does not exist, skipping "empty" operation: %s', x) continue log.info('Emptying directory %s', x) # stat the dir, delete the dir, recreate the dir and set # the proper perms and ownership mystat=os.stat(myemp) shutil.rmtree(myemp) ensure_dirs(myemp, mode=0o755) os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) os.chmod(myemp,mystat[ST_MODE]) self.resume.enable("empty")
def parse(self): values = {} cur_array = [] trailing_comment=re.compile(r'\s*#.*$') #white_space=re.compile('\s+') for x, myline in enumerate(self.lines): myline = myline.strip() # Force the line to be clean # Remove Comments ( anything following # ) myline = trailing_comment.sub("", myline) # Skip any blank lines if not myline: continue if self.key_value_separator in myline: # Split on the first occurence of the separator creating two strings in the array mobjs mobjs = myline.split(self.key_value_separator, 1) mobjs[1] = mobjs[1].strip().strip('"') # # Check that this key doesn't exist already in the spec # if mobjs[0] in values: # raise Exception("You have a duplicate key (" + mobjs[0] + ") in your spec. Please fix it") # Start a new array using the first element of mobjs cur_array = [mobjs[0]] if mobjs[1]: # do any variable substitiution embeded in it with # the values already obtained mobjs[1] = mobjs[1] % values if self.multiple_values: # split on white space creating additional array elements # subarray = white_space.split(mobjs[1]) subarray = mobjs[1].split() cur_array += subarray else: cur_array += [mobjs[1]] # Else add on to the last key we were working on else: if self.multiple_values: # mobjs = white_space.split(myline) # cur_array += mobjs cur_array += myline.split() else: raise CatalystError("Syntax error: %s" % x, print_traceback=True) # XXX: Do we really still need this "single value is a string" behavior? if len(cur_array) == 2: values[cur_array[0]] = cur_array[1] else: values[cur_array[0]] = cur_array[1:] if not self.empty_values: # Make sure the list of keys is static since we modify inside the loop. for x in list(values.keys()): # Delete empty key pairs if not values[x]: log.warning('No value set for key "%s"; deleting', x) del values[x] self.values = values
def parse(self): values = {} cur_array = [] trailing_comment=re.compile(r'\s*#.*$') #white_space=re.compile('\s+') for x, myline in enumerate(self.lines): myline = myline.strip() # Force the line to be clean # Remove Comments ( anything following # ) myline = trailing_comment.sub("", myline) # Skip any blank lines if not myline: continue if self.key_value_separator in myline: # Split on the first occurence of the separator creating two strings in the array mobjs mobjs = myline.split(self.key_value_separator, 1) mobjs[1] = mobjs[1].strip().strip('"') # # Check that this key doesn't exist already in the spec # if mobjs[0] in values: # raise Exception("You have a duplicate key (" + mobjs[0] + ") in your spec. Please fix it") # Start a new array using the first element of mobjs cur_array = [mobjs[0]] if mobjs[1]: # do any variable substitiution embeded in it with # the values already obtained mobjs[1] = mobjs[1] % values if self.multiple_values: # split on white space creating additional array elements # subarray = white_space.split(mobjs[1]) subarray = mobjs[1].split() cur_array += subarray else: cur_array += [mobjs[1]] # Else add on to the last key we were working on else: if self.multiple_values: # mobjs = white_space.split(myline) # cur_array += mobjs cur_array += myline.split() else: raise CatalystError("Syntax error: %s" % x, print_traceback=True) # XXX: Do we really still need this "single value is a string" behavior? if len(cur_array) == 2: values[cur_array[0]] = cur_array[1] else: values[cur_array[0]] = cur_array[1:] if not self.empty_values: # Make sure the list of keys is static since we modify inside the loop. for x in list(values.keys()): # Delete empty key pairs if not values[x]: log.warning('No value set for key "%s"; deleting', x) del values[x] if self.eval_none: # Make sure the list of keys is static since we modify inside the loop. for x in list(values.keys()): # reset None values if isinstance(values[x], str) and values[x].lower() in ['none']: log.info('None value found for key "%s"; reseting', x) values[x] = None self.values = values