def create_pkg_file(self): """Create and pkg file for use with the FreeBSD pkg tool. Create a package from the result of the package's InstallStep. """ install_dir = self.get_install_location() if not os.path.exists(install_dir): log('Skiping pkg creation. Install dir not found: %s' % install_dir) return # Strip all elf or pexe files in the install directory (except .o files # since we don't want to strip, for example, crt1.o) if not self.config.debug and self.config.toolchain != 'emscripten': strip = util.get_strip(self.config) for root, _, files in os.walk(install_dir): for filename in files: fullname = os.path.join(root, filename) if (os.path.isfile(fullname) and util.is_elf_file(fullname) and os.path.splitext(fullname)[1] != '.o'): log('stripping: %s %s' % (strip, fullname)) subprocess.check_call([strip, fullname]) abi = 'pkg_' + self.config.toolchain if self.config.arch != self.config.toolchain: abi += "_" + util.arch_to_pkgarch[self.config.arch] abi_dir = os.path.join(paths.PUBLISH_ROOT, abi) pkg_file = os.path.join(abi_dir, '%s-%s.tbz' % (self.NAME, self.VERSION)) util.makedirs(abi_dir) deps = self.DEPENDS if self.config.toolchain != 'glibc': deps = [] bsd_pkg.create_pkg_file(self.NAME, self.VERSION, self.config.arch, self.get_install_location(), pkg_file, deps)
def filter_out_executables(filenames, root): """Filter out ELF binaries in the bin directory. We don't want NaCl exectuables installed in the toolchain's bin directory since we add this to the PATH during the build process, and NaCl executables can't be run on the host system (not without sel_ldr anyway). """ rtn = [] for name in filenames: full_name = os.path.join(root, name) if os.path.split(name)[0] == 'bin': if not os.path.splitext(name)[1] and util.is_elf_file(full_name): continue rtn.append(name) return rtn
def install_file(filename, old_root, new_root): """Install a single file by moving it into a new location. Args: filename: Relative name of file to install. old_root: The current location of the file. new_root: The new desired root for the file. """ oldname = os.path.join(old_root, filename) util.log_verbose('install: %s' % filename) newname = os.path.join(new_root, filename) dirname = os.path.dirname(newname) if not os.path.isdir(dirname): util.makedirs(dirname) os.rename(oldname, newname) # When install binaries ELF files into the toolchain direcoties, remove # the X bit so that they do not found when searching the PATH. if util.is_elf_file(newname) or util.is_pexe_file(newname): mode = os.stat(newname).st_mode mode = mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) os.chmod(newname, mode)