def build(self, sum): """Actually build the package.""" build_log = os.path.join(self.log_dir, "bench-build.log") prebuild_log = os.path.join(self.log_dir, "bench-prebuild.log") distcc_log = os.path.join(self.log_dir, "bench-build-distcc.log") rm_files((build_log, distcc_log)) print "** Building..." if self.project.pre_build_cmd: cmd = ("cd %s && %s > %s 2>&1" % (self.build_dir, self.project.pre_build_cmd, prebuild_log)) run_cmd(cmd) cmd = ("cd %s && \\\n%s \\\nDISTCC_LOG='%s' \\\nCC='%s' \\\nCXX='%s' \\\n%s \\\n>%s 2>&1" % (self.build_dir, self.project.build_cmd, distcc_log, self.compiler.cc, self.compiler.cxx, self.compiler.make_opts, build_log)) result, elapsed = run_cmd(cmd) return elapsed
def unpack(self): """Unpack from source tarball into build directory""" if re.search(r"\.tar\.bz2$", self.project.package_file): tar_fmt = "tar xf %s --bzip2" else: tar_fmt = "tar xfz %s" tar_cmd = tar_fmt % os.path.join(os.getcwd(), self.project.package_dir, self.project.package_file) make_dir(self.base_dir) print "** Unpacking..." run_cmd("cd %s && %s" % (self.base_dir, tar_cmd))
def configure(self, compiler): """Run configuration command for this tree, if any.""" self.compiler = compiler make_dir(self.log_dir) configure_log = os.path.join(self.log_dir, "bench-configure.log") distcc_log = os.path.join(self.log_dir, "bench-configure-distcc.log") rm_files((configure_log, distcc_log)) print "** Configuring..." run_cmd( "cd %s && \\\nDISTCC_LOG='%s' \\\nCC='%s' \\\nCXX='%s' \\\n%s \\\n>%s 2>&1" % (self.build_dir, distcc_log, self.compiler.cc, self.compiler.cxx, self.project.configure_cmd, configure_log))
def configure(self, compiler): """Run configuration command for this tree, if any.""" self.compiler = compiler make_dir(self.log_dir) configure_log = os.path.join(self.log_dir, "bench-configure.log") distcc_log = os.path.join(self.log_dir, "bench-configure-distcc.log") rm_files((configure_log, distcc_log)) print "** Configuring..." run_cmd("cd %s && \\\nDISTCC_LOG='%s' \\\nCC='%s' \\\nCXX='%s' \\\n%s \\\n>%s 2>&1" % (self.build_dir, distcc_log, self.compiler.cc, self.compiler.cxx, self.project.configure_cmd, configure_log))
def download(self): """Download package from vendor site.""" make_dir(self.package_dir) make_dir(self.download_dir) if not os.path.isfile(os.path.join(self.package_dir, self.package_file)): # XXX: snarf gets upset if the HTTP server returns "416 # Requested Range Not Satisfiable" because the file is already # totally downloaded. This is kind of a snarf bug. print "** Downloading" run_cmd("cd %s && wget --continue %s" % (self.download_dir, self.url)) run_cmd("mv %s %s" % (os.path.join(self.download_dir, self.package_file), self.package_dir))
def build(self, sum): """Actually build the package.""" build_log = os.path.join(self.log_dir, "bench-build.log") prebuild_log = os.path.join(self.log_dir, "bench-prebuild.log") distcc_log = os.path.join(self.log_dir, "bench-build-distcc.log") rm_files((build_log, distcc_log)) print "** Building..." if self.project.pre_build_cmd: cmd = ("cd %s && %s > %s 2>&1" % (self.build_dir, self.project.pre_build_cmd, prebuild_log)) run_cmd(cmd) cmd = ( "cd %s && \\\n%s \\\nDISTCC_LOG='%s' \\\nCC='%s' \\\nCXX='%s' \\\n%s \\\n>%s 2>&1" % (self.build_dir, self.project.build_cmd, distcc_log, self.compiler.cc, self.compiler.cxx, self.compiler.make_opts, build_log)) result, elapsed = run_cmd(cmd) return elapsed
def _run_cmd_with_redirect_farm(self, cmd): """Initialize shell script farm for given compiler, augment PATH, and run cmd. A shell script farm is a set of scripts for dispatching a chosen compiler using distcc. For example, the 'cc' script may contain the one line: dist /usr/mine/gcc "$@" """ farm_dir = os.path.join(self.build_dir, 'build-cc-script-farm') make_dir(farm_dir) print ("** Creating masquerading shell scripts in '%s'" % farm_dir) masquerade = os.path.join(self.build_dir, 'masquerade') prepare_shell_script_farm(self.compiler, farm_dir, masquerade) old_path = os.environ['PATH'] try: os.environ['PATH'] = farm_dir + ":" + old_path return run_cmd(cmd) finally: os.environ['PATH'] = old_path
def _run_cmd_with_redirect_farm(self, cmd): """Initialize shell script farm for given compiler, augment PATH, and run cmd. A shell script farm is a set of scripts for dispatching a chosen compiler using distcc. For example, the 'cc' script may contain the one line: dist /usr/mine/gcc "$@" """ farm_dir = os.path.join(self.build_dir, 'build-cc-script-farm') make_dir(farm_dir) print("** Creating masquerading shell scripts in '%s'" % farm_dir) masquerade = os.path.join(self.build_dir, 'masquerade') prepare_shell_script_farm(self.compiler, farm_dir, masquerade) old_path = os.environ['PATH'] try: os.environ['PATH'] = farm_dir + ":" + old_path return run_cmd(cmd) finally: os.environ['PATH'] = old_path
def scrub(self): print "** Removing build directory" run_cmd("rm -rf %s" % self.unpacked_dir)
def clean(self): clean_log = os.path.join(self.log_dir, "bench-clean.log") print "** Cleaning build directory" cmd = "cd %s && make clean >%s 2>&1" % (self.build_dir, clean_log) run_cmd(cmd)
def scrub(self): print "** Removing build directory" rm_files((self.configure_done, )) run_cmd("rm -rf %s" % self.unpacked_dir)
def md5check(self): if self.md5: print "** Checking source package integrity" run_cmd("cd %s && echo '%s' | md5sum -c /dev/stdin" % (self.package_dir, self.md5))