def extract_into_obj(inv, co_name, label, pkg_file): tmp = Label(utils.LabelType.Checkout, co_name, domain=label.domain) co_dir = inv.checkout_path(tmp) obj_dir = inv.package_obj_path(label) dpkg_cmd = ["dpkg-deb", "-X", os.path.join(co_dir, pkg_file), os.path.join(obj_dir, "obj")] utils.run0(dpkg_cmd) # Now install any include or lib files .. installed_into = os.path.join(obj_dir, "obj") inc_dir = os.path.join(obj_dir, "include") lib_dir = os.path.join(obj_dir, "lib") lib_dir = os.path.join(obj_dir, "share") utils.ensure_dir(inc_dir) utils.ensure_dir(lib_dir) # Copy everything in usr/include .. for i in (("include", "include"), ("lib", "lib"), ("usr/include", "include"), ("usr/lib", "lib"), ("usr/share", "share")): (src,dst) = i src_path = os.path.join(installed_into, src) dst_path= os.path.join(obj_dir, dst) if (os.path.exists(src_path) and os.path.isdir(src_path)): utils.copy_without(src_path, dst_path, without = None, object_exactly = True)
def extract_into_obj(inv, co_name, label, pkg_file): tmp = Label(utils.LabelType.Checkout, co_name, domain=label.domain) co_dir = inv.checkout_path(tmp) obj_dir = inv.package_obj_path(label) dpkg_cmd = [ "dpkg-deb", "-X", os.path.join(co_dir, pkg_file), os.path.join(obj_dir, "obj") ] utils.run0(dpkg_cmd) # Now install any include or lib files .. installed_into = os.path.join(obj_dir, "obj") inc_dir = os.path.join(obj_dir, "include") lib_dir = os.path.join(obj_dir, "lib") lib_dir = os.path.join(obj_dir, "share") utils.ensure_dir(inc_dir) utils.ensure_dir(lib_dir) # Copy everything in usr/include .. for i in (("include", "include"), ("lib", "lib"), ("usr/include", "include"), ("usr/lib", "lib"), ("usr/share", "share")): (src, dst) = i src_path = os.path.join(installed_into, src) dst_path = os.path.join(obj_dir, dst) if (os.path.exists(src_path) and os.path.isdir(src_path)): utils.copy_without(src_path, dst_path, without=None, object_exactly=True)
def deploy(self, builder, label): deploy_dir = builder.deploy_path(label) # First off, delete the target directory utils.recursively_remove(deploy_dir) utils.ensure_dir(deploy_dir) for role, domain in self.roles: if domain: print "> %s: Deploying role %s in domain %s .. "%(label.name, role, domain) else: print "> %s: Deploying role %s .. "%(label.name, role) install_dir = builder.role_install_path(role, domain = domain) utils.recursively_copy(install_dir, deploy_dir, object_exactly=True) # This is somewhat tricky as it potentially requires privilege elevation. # Privilege elevation is done by hooking back into ourselves via a # build command to a label we registered earlier. # # Note that you cannot split instruction application - once the first # privilege-requiring instruction is executed, all further instructions # may require privilege even if they didn't before (e.g. a chmod after # chown) # First off, do we need to at all? need_root_for = set() for role, domain in self.roles: lbl = depend.Label(utils.LabelType.Package, "*", role, "*", domain=domain) install_dir = builder.role_install_path(role, domain = label.domain) instr_list = builder.load_instructions(lbl) for (lbl, fn, instr_file) in instr_list: # Obey this instruction? for instr in instr_file: iname = instr.outer_elem_name() if iname in self.app_dict: if self.app_dict[iname].needs_privilege(builder, instr, role, install_dir): need_root_for.add(iname) # Deliberately do not break - we want to check everything for # validity before acquiring privilege. else: raise utils.GiveUp("File deployments don't know about " + "instruction %s"%iname + " found in label %s (filename %s)"%(lbl, fn)) print "Rerunning muddle to apply instructions .. " permissions_label = depend.Label(utils.LabelType.Deployment, label.name, None, # XXX label.role, utils.LabelTag.InstructionsApplied, domain = label.domain) if need_root_for: print "I need root to do %s - sorry! - running sudo .."%(', '.join(sorted(need_root_for))) utils.run0("sudo %s buildlabel '%s'"%(builder.muddle_binary, permissions_label)) else: utils.run0("%s buildlabel '%s'"%(builder.muddle_binary, permissions_label))
def ensure_dirs(self, builder, label): inv = builder # TODO: Does the following check one dir and then make another??? tmp = Label(utils.LabelType.Checkout, self.co_name, domain=label.domain) if not os.path.exists(inv.checkout_path(tmp)): raise utils.GiveUp("Path for checkout %s does not exist."%self.co_name) utils.ensure_dir(os.path.join(inv.package_obj_path(label), "obj"))
def ensure_dirs(self, builder, label): inv = builder tmp = Label(utils.LabelType.Checkout, self.co_name, domain=label.domain) if not os.path.exists(inv.checkout_path(tmp)): raise utils.GiveUp("Path for checkout %s does not exist."%self.co_name) utils.ensure_dir(inv.package_install_path(label)) utils.ensure_dir(inv.package_obj_path(label))
def build_label(self, builder, label): """ Install is the only one we care about .. """ if (label.tag == utils.LabelTag.Installed): tmp = Label(utils.LabelType.Package, self.name, self.role, domain=label.domain) inst_dir = builder.package_install_path(tmp) tgt_dir = os.path.join(inst_dir, "bin") src_file = builder.resource_file_name("initscript.sh") utils.ensure_dir(tgt_dir) tgt_file = os.path.join(tgt_dir, self.script_name) print "> Writing %s .. "%(tgt_file) subst.subst_file(src_file, tgt_file, None, os.environ) os.chmod(tgt_file, 0755) # Write the setvars script env = get_effective_env(builder, self.name, self.role, domain = label.domain) effective_env = env.copy() env_store.add_install_dir_env(effective_env, "MUDDLE_TARGET_LOCATION") for d in self.deployments: # Merge in the relevant deployment environments. lbl = depend.Label(utils.LabelType.Deployment, d, None, utils.LabelTag.Deployed, domain = label.domain) effective_env.merge(builder.get_environment_for( lbl)) if (self.write_setvars_sh): setenv_file_name = os.path.join(tgt_dir, "setvars") sv_script = effective_env.get_setvars_script(builder, self.script_name, env_store.EnvLanguage.Sh) out_f = open(setenv_file_name, "w") out_f.write(sv_script) out_f.close() if (self.write_setvars_py): # Now the python version .. setenv_file_name = os.path.join(tgt_dir, "setvars.py") sv_script = effective_env.get_setvars_script(builder, self.script_name, env_store.EnvLanguage.Python) out_f = open(setenv_file_name, "w") out_f.write(sv_script) out_f.close() else: pass
def ensure_dirs(self, builder, label): inv = builder # TODO: Does the following check one dir and then make another??? tmp = Label(utils.LabelType.Checkout, self.co_name, domain=label.domain) if not os.path.exists(inv.checkout_path(tmp)): raise utils.GiveUp("Path for checkout %s does not exist." % self.co_name) utils.ensure_dir(os.path.join(inv.package_obj_path(label), "obj"))
def ensure_dirs(self, builder, label): inv = builder tmp = Label(utils.LabelType.Checkout, self.co_name, domain=label.domain) if not os.path.exists(inv.checkout_path(tmp)): raise utils.GiveUp("Path for checkout %s does not exist." % self.co_name) utils.ensure_dir(inv.package_install_path(label)) utils.ensure_dir(inv.package_obj_path(label))
def ensure_dirs(self, builder, label): """ Make sure all the relevant directories exist. """ co_label = Label(utils.LabelType.Checkout, self.co, domain=label.domain) if not os.path.exists(builder.db.get_checkout_path(co_label)): raise utils.GiveUp("Missing source directory\n" " %s depends on %s\n" " Directory %s does not exist"%(label, co_label, builder.db.get_checkout_path(co_label))) co_label = Label(utils.LabelType.Package, self.name, self.role, domain=label.domain) utils.ensure_dir(builder.package_obj_path(co_label)) utils.ensure_dir(builder.package_install_path(co_label))
def build_label(self, builder, label): """ Actually do the copies .. """ utils.ensure_dir(builder.deploy_path(label)) if (label.tag == utils.LabelTag.Deployed): self.apply_instructions(builder, label, True, builder.deploy_path(label)) self.deploy(builder, label, builder.deploy_path(label)) self.sort_out_and_run_instructions(builder, label) elif (label.tag == utils.LabelTag.InstructionsApplied): self.apply_instructions(builder, label, False, builder.deploy_path(label)) else: raise GiveUp("Attempt to build a deployment with an unexpected tag" " in label %s"%(label))
def apply(self, builder, instr, role, path): dp = filespec.FSFileSpecDataProvider(path) in_dir = os.path.dirname(instr.file_name) file_name = os.path.basename(instr.file_name) utils.ensure_dir(in_dir) if instr.type == "char": rtype = "c" else: rtype = "b" magic_file = "@%s,%s,%d,%d" % (file_name, rtype, int( instr.major), int(instr.minor)) f = open(os.path.join(in_dir, magic_file), 'w') f.close() return True
def deploy(self, builder, label): deploy_dir = builder.deploy_path(label) utils.recursively_remove(deploy_dir) utils.ensure_dir(deploy_dir) for role in self.dependent_roles: print "> %s: Deploying role %s .."%(label.name, role) install_dir = builder.role_install_path(role, domain = label.domain) # We do want an exact copy here - this is a copy from the install # set to the role deployment and therefore may include symlinks # hardwired to MUDDLE_TARGET_INSTALL. If it were a copy to the install # directory, we'd want an inexact copy. # - rrw 2009-11-09 utils.recursively_copy(install_dir, deploy_dir, object_exactly = True)
def apply(self, builder, instr, role, path): dp = filespec.FSFileSpecDataProvider(path) in_dir = os.path.dirname(instr.file_name) file_name = os.path.basename(instr.file_name) utils.ensure_dir(in_dir) if instr.type == "char": rtype = "c" else: rtype = "b" magic_file = "@%s,%s,%d,%d"%(file_name, rtype, int(instr.major), int(instr.minor)) f = open(os.path.join(in_dir, magic_file), 'w') f.close() return True
def deploy(self, builder, label): deploy_dir = builder.deploy_path(label) utils.recursively_remove(deploy_dir) utils.ensure_dir(deploy_dir) for role in self.dependent_roles: print "> %s: Deploying role %s .." % (label.name, role) install_dir = builder.role_install_path(role, domain=label.domain) # We do want an exact copy here - this is a copy from the install # set to the role deployment and therefore may include symlinks # hardwired to MUDDLE_TARGET_INSTALL. If it were a copy to the install # directory, we'd want an inexact copy. # - rrw 2009-11-09 utils.recursively_copy(install_dir, deploy_dir, object_exactly=True)
def build_label(self, builder, label): """ Actually do the copies .. """ utils.ensure_dir(builder.deploy_path(label)) if (label.tag == utils.LabelTag.Deployed): self.apply_instructions(builder, label, True, builder.deploy_path(label)) self.deploy(builder, label, builder.deploy_path(label)) self.sort_out_and_run_instructions(builder, label) elif (label.tag == utils.LabelTag.InstructionsApplied): self.apply_instructions(builder, label, False, builder.deploy_path(label)) else: raise GiveUp("Attempt to build a deployment with an unexpected tag" " in label %s" % (label))
def do_genromfs(self, builder, label, my_tmp): """ genromfs everything up into a RomFS image. """ if self.target_name is None: tgt = "rom.romfs" else: tgt = self.target_name utils.ensure_dir(builder.deploy_path(label)) final_tgt = os.path.join(builder.deploy_path(label), tgt) cmd = "%s -f \"%s\"" % (self.genromfs, final_tgt) if (self.volume_label is not None): cmd = cmd + " -V \"%s\"" % self.volume_label if (self.alignment is not None): cmd = cmd + " -a %d" % (int(self.alignment)) cmd = cmd + " -d \"%s\"" % (my_tmp) utils.run0(cmd)
def do_genromfs(self, builder, label, my_tmp): """ genromfs everything up into a RomFS image. """ if self.target_name is None: tgt = "rom.romfs" else: tgt = self.target_name utils.ensure_dir(builder.deploy_path(label)) final_tgt = os.path.join(builder.deploy_path(label), tgt) cmd = "%s -f \"%s\""%(self.genromfs, final_tgt) if (self.volume_label is not None): cmd = cmd + " -V \"%s\""%self.volume_label if (self.alignment is not None): cmd = cmd + " -a %d"%(int(self.alignment)) cmd = cmd + " -d \"%s\""%(my_tmp) utils.run0(cmd)
def do_mksquashfs(self, builder, label, my_tmp): """ mksquashfs everything up into a SquashFS image. """ if (self.target_name is None): tgt = "rom.squashfs" else: tgt = self.target_name utils.ensure_dir(builder.deploy_path(label)) final_tgt = os.path.join(builder.deploy_path(label), tgt) # mksquashfs will, by default, append rather than replacing, so.. try: os.remove(final_tgt) except OSError as e: if e.errno != errno.ENOENT: # Only re-raise if it wasn't file missing raise cmd = "%s \"%s\" \"%s\" -noappend -all-root -info -comp xz"%(self.mksquashfs, my_tmp, final_tgt) utils.run0(cmd)
def ensure_dirs(self, builder, label): """ Make sure all the relevant directories exist. """ co_label = Label(utils.LabelType.Checkout, self.co, domain=label.domain) if not os.path.exists(builder.db.get_checkout_path(co_label)): raise utils.GiveUp( "Missing source directory\n" " %s depends on %s\n" " Directory %s does not exist" % (label, co_label, builder.db.get_checkout_path(co_label))) co_label = Label(utils.LabelType.Package, self.name, self.role, domain=label.domain) utils.ensure_dir(builder.package_obj_path(co_label)) utils.ensure_dir(builder.package_install_path(co_label))
def do_mksquashfs(self, builder, label, my_tmp): """ mksquashfs everything up into a SquashFS image. """ if (self.target_name is None): tgt = "rom.squashfs" else: tgt = self.target_name utils.ensure_dir(builder.deploy_path(label)) final_tgt = os.path.join(builder.deploy_path(label), tgt) # mksquashfs will, by default, append rather than replacing, so.. try: os.remove(final_tgt) except OSError as e: if e.errno != errno.ENOENT: # Only re-raise if it wasn't file missing raise cmd = "%s \"%s\" \"%s\" -noappend -all-root -info -comp xz" % ( self.mksquashfs, my_tmp, final_tgt) utils.run0(cmd)
def write_version_file(self, builder): """ Write the version file """ utils.ensure_dir(self.dir_name(builder)) print "dir %s ensured."%(self.dir_name(builder)) f = open(self.file_name(builder), 'w') f.write("<?xml version=\"1.0\" ?>\n") f.write("\n") f.write("<version>\n") self.write_elem(f, "name", self.swname) self.write_elem(f, "version", self.version) self.write_elem(f, "build", self.build) if (self.withDate): self.write_elem(f, "built-at", utils.iso_time()) self.write_elem(f, "built-time", utils.unix_time()) if (self.withUser): self.write_elem(f, "built-by", utils.current_user()) if (self.withMachine): self.write_elem(f, "built-on", utils.current_machine_name()) f.write("</version>\n") f.close()
def write_version_file(self, builder): """ Write the version file """ utils.ensure_dir(self.dir_name(builder)) print "dir %s ensured." % (self.dir_name(builder)) f = open(self.file_name(builder), 'w') f.write("<?xml version=\"1.0\" ?>\n") f.write("\n") f.write("<version>\n") self.write_elem(f, "name", self.swname) self.write_elem(f, "version", self.version) self.write_elem(f, "build", self.build) if (self.withDate): self.write_elem(f, "built-at", utils.iso_time()) self.write_elem(f, "built-time", utils.unix_time()) if (self.withUser): self.write_elem(f, "built-by", utils.current_user()) if (self.withMachine): self.write_elem(f, "built-on", utils.current_machine_name()) f.write("</version>\n") f.close()
def build_label(self,builder, label): """ Actually cpio everything up, following instructions appropriately. """ if label.type not in (LabelType.Deployment, LabelType.Package): raise GiveUp("Attempt to build a CPIO deployment with a label" " of type %s"%(label.type)) if label.type == LabelType.Deployment and label.tag != LabelTag.Deployed: raise GiveUp("Attempt to build a CPIO deployment with a" " deployment label of type %s"%(label.tag)) elif label.type == LabelType.Package and label.tag != LabelTag.PostInstalled: raise GiveUp("Attempt to build a CPIO deployment with a" " package label of type %s"%(label.tag)) # Collect all the relevant files .. if label.type == LabelType.Deployment: deploy_dir = builder.deploy_path(label) else: # XXX Would it be better to use package_obj_path(label) ??? deploy_dir = builder.package_install_path(label) deploy_file = os.path.join(deploy_dir, self.target_file) utils.ensure_dir(os.path.dirname(deploy_file)) the_hierarchy = cpiofile.Hierarchy({ }, { }) for l ,bt in self.target_base: if type( bt ) == types.TupleType: real_source_path = os.path.join(builder.role_install_path(l.role, l.domain), bt[0]) # This is bt[1] - the actual destination. base is computed differently # (bt[2]) for applying instructions. base = bt[1] else: base = bt real_source_path = os.path.join(builder.role_install_path(l.role, l.domain)) print "Collecting %s for deployment to %s .. "%(l,base) if (len(base) > 0 and base[0] != '/'): base = "/%s"%(base) m = cpiofile.hierarchy_from_fs(real_source_path, base) the_hierarchy.merge(m) # Normalise the hierarchy .. the_hierarchy.normalise() print "Filesystem hierarchy is:\n%s"%the_hierarchy.as_str(builder.db.root_path) if self.prune_function: self.prune_function(the_hierarchy) app_dict = _get_instruction_dict() # Apply instructions. We actually need an intermediate list here, # because you might have the same role with several different # sources and possibly different bases. to_apply = {} for src, bt in self.target_base: if type(bt) == types.TupleType: base = bt[2] else: base = bt to_apply[ (src, base) ] = (src, bt) # Now they are unique .. for src, bt in to_apply.values(): if type(bt) == types.TupleType: base = bt[2] else: base = bt print "base = %s"%(base) lbl = depend.Label(LabelType.Package, "*", src.role, "*", domain = src.domain) print "Scanning instructions for role %s, domain %s .. "%(src.role, src.domain) instr_list = builder.load_instructions(lbl) for lbl, fn, instrs in instr_list: print "CPIO deployment: Applying instructions for role %s, label %s .. "%(src.role, lbl) for instr in instrs: iname = instr.outer_elem_name() #print 'Instruction:', iname if iname in app_dict: print 'Instruction:', str(instr) app_dict[iname].apply(builder, instr, lbl.role, base, the_hierarchy) else: print 'Instruction:', iname raise GiveUp("CPIO deployments don't know about " "the instruction %s (lbl %s, file %s)"%(iname, lbl, fn)) # .. and write the file. print "> Writing %s .. "%deploy_file the_hierarchy.render(deploy_file, True) if (self.compression_method is not None): if (self.compression_method == "gzip"): utils.run0(["gzip", "-f", deploy_file]) elif (self.compression_method == "bzip2"): utils.run0(["bzip2", "-f", deploy_file]) else: raise GiveUp("Invalid compression method %s"%self.compression_method + "specified for cpio deployment. Pick gzip or bzip2.")
def check_out(self): utils.ensure_dir(self.checkout_path) os.chdir(self.checkout_path) utils.run0("wget %s --output-document=%s" % (self.url, self.filename))
def check_out(self): utils.ensure_dir(self.checkout_path) os.chdir(self.checkout_path) utils.run0("wget %s --output-document=%s"%(self.url,self.filename))
def build_label(self, builder, label): our_dir = builder.package_obj_path(label) dirlist = [] tag = label.tag if (tag == utils.LabelTag.Built or tag == utils.LabelTag.Installed): for (l, s) in self.components: tmp = Label(utils.LabelType.Package, l.name, l.role, domain=label.domain) root_dir = builder.package_install_path(tmp) dirlist.append((root_dir, s)) print "dirlist:" for (x, y) in dirlist: print "%s=%s \n" % (x, y) if (tag == utils.LabelTag.PreConfig): pass elif (tag == utils.LabelTag.Configured): pass elif (tag == utils.LabelTag.Built): # OK. Building. This is ghastly .. utils.recursively_remove(our_dir) utils.ensure_dir(our_dir) # Now we need to copy all the subdirs in .. for (root, sub) in dirlist: utils.ensure_dir(utils.rel_join(our_dir, sub)) # Only bother to copy kernel modules. names = utils.find_by_predicate(utils.rel_join(root, sub), predicate_is_kernel_module) utils.copy_name_list_with_dirs(names, utils.rel_join(root, sub), utils.rel_join(our_dir, sub)) # .. and run depmod. depmod = "depmod" if (self.custom_depmod is not None): depmod = self.custom_depmod # Because depmod is brain-dead, we need to give it explicit versions. names = os.listdir(utils.rel_join(our_dir, "lib/modules")) our_re = re.compile(r'\d+\.\d+\..*') for n in names: if (our_re.match(n) is not None): print "Found kernel version %s in %s .. " % (n, our_dir) utils.run0("%s -b %s %s" % (depmod, our_dir, n)) elif (tag == utils.LabelTag.Installed): # Now we find all the modules.* files in our_dir and copy them over # to our install directory names = utils.find_by_predicate(our_dir, predicate_is_module_db) tgt_dir = builder.package_install_path(label) utils.copy_name_list_with_dirs(names, our_dir, tgt_dir) for n in names: new_n = utils.replace_root_name(our_dir, tgt_dir, n) print "Installed: %s" % (new_n) elif (tag == utils.LabelTag.Clean): utils.recursively_remove(our_dir) elif (tag == utils.LabelTag.DistClean): utils.recursively_remove(our_dir)
def deploy(self, builder, label): deploy_dir = builder.deploy_path(label) # First off, delete the target directory utils.recursively_remove(deploy_dir) utils.ensure_dir(deploy_dir) for role, domain in self.roles: if domain: print "> %s: Deploying role %s in domain %s .. " % ( label.name, role, domain) else: print "> %s: Deploying role %s .. " % (label.name, role) install_dir = builder.role_install_path(role, domain=domain) utils.recursively_copy(install_dir, deploy_dir, object_exactly=True) # This is somewhat tricky as it potentially requires privilege elevation. # Privilege elevation is done by hooking back into ourselves via a # build command to a label we registered earlier. # # Note that you cannot split instruction application - once the first # privilege-requiring instruction is executed, all further instructions # may require privilege even if they didn't before (e.g. a chmod after # chown) # First off, do we need to at all? need_root_for = set() for role, domain in self.roles: lbl = depend.Label(utils.LabelType.Package, "*", role, "*", domain=domain) install_dir = builder.role_install_path(role, domain=label.domain) instr_list = builder.load_instructions(lbl) for (lbl, fn, instr_file) in instr_list: # Obey this instruction? for instr in instr_file: iname = instr.outer_elem_name() if iname in self.app_dict: if self.app_dict[iname].needs_privilege( builder, instr, role, install_dir): need_root_for.add(iname) # Deliberately do not break - we want to check everything for # validity before acquiring privilege. else: raise utils.GiveUp( "File deployments don't know about " + "instruction %s" % iname + " found in label %s (filename %s)" % (lbl, fn)) print "Rerunning muddle to apply instructions .. " permissions_label = depend.Label( utils.LabelType.Deployment, label.name, None, # XXX label.role, utils.LabelTag.InstructionsApplied, domain=label.domain) if need_root_for: print "I need root to do %s - sorry! - running sudo .." % ( ', '.join(sorted(need_root_for))) utils.run0("sudo %s buildlabel '%s'" % (builder.muddle_binary, permissions_label)) else: utils.run0("%s buildlabel '%s'" % (builder.muddle_binary, permissions_label))
def build_label(self, builder, label): our_dir = builder.package_obj_path(label) dirlist = [ ] tag = label.tag if (tag == utils.LabelTag.Built or tag == utils.LabelTag.Installed): for (l,s) in self.components: tmp = Label(utils.LabelType.Package, l.name, l.role, domain=label.domain) root_dir = builder.package_install_path(tmp) dirlist.append( (root_dir, s) ) print "dirlist:" for (x,y) in dirlist: print "%s=%s \n"%(x,y) if (tag == utils.LabelTag.PreConfig): pass elif (tag == utils.LabelTag.Configured): pass elif (tag == utils.LabelTag.Built): # OK. Building. This is ghastly .. utils.recursively_remove(our_dir) utils.ensure_dir(our_dir) # Now we need to copy all the subdirs in .. for (root, sub) in dirlist: utils.ensure_dir(utils.rel_join(our_dir, sub)) # Only bother to copy kernel modules. names = utils.find_by_predicate(utils.rel_join(root, sub), predicate_is_kernel_module) utils.copy_name_list_with_dirs(names, utils.rel_join(root,sub), utils.rel_join(our_dir, sub)) # .. and run depmod. depmod = "depmod" if (self.custom_depmod is not None): depmod = self.custom_depmod # Because depmod is brain-dead, we need to give it explicit versions. names = os.listdir(utils.rel_join(our_dir, "lib/modules")) our_re = re.compile(r'\d+\.\d+\..*') for n in names: if (our_re.match(n) is not None): print "Found kernel version %s in %s .. "%(n, our_dir) utils.run0("%s -b %s %s"%(depmod, our_dir, n)) elif (tag == utils.LabelTag.Installed): # Now we find all the modules.* files in our_dir and copy them over # to our install directory names = utils.find_by_predicate(our_dir, predicate_is_module_db) tgt_dir = builder.package_install_path(label) utils.copy_name_list_with_dirs(names, our_dir, tgt_dir) for n in names: new_n = utils.replace_root_name(our_dir, tgt_dir, n) print "Installed: %s"%(new_n) elif (tag == utils.LabelTag.Clean): utils.recursively_remove(our_dir) elif (tag == utils.LabelTag.DistClean): utils.recursively_remove(our_dir)