def patch(self): """ Try to apply patches returned by shared.get_patches_list. """ patches_list = shared.get_patches_list(self.ver) for patch_path in patches_list: patch = open(patch_path, 'r') try: exit_code = call(["patch"], stdout=self.logfile, stderr=self.logfile, stdin=patch) if exit_code is not 0: raise BuildError("patching has failed") except OSError: raise shared.MissingToolError("patch is missing") finally: patch.close()
def install(ver, build_args): """ This calls the correct functions in the correct order to install Node. It also handles exceptions. """ if shared.version_exists(ver): sys.stderr.write("Error: %s is already installed\n" % ver) sys.exit(1) elif not shared.valid_version_string(ver): sys.stderr.write("Error: %s doesn't look like a valid version\n" % ver) sys.exit(2) try: nodesrc = install_helper.NodeSourceInstaller(ver, shared.get_version_dir(ver), build_args) sys.stdout.write("Downloading...\n") nodesrc.download() sys.stdout.write("Extracting...\n") nodesrc.extract() sys.stdout.write("Patching...\n") if len(shared.get_patches_list(ver)) == 0: sys.stdout.write("No patches found.\n") else: nodesrc.patch() sys.stdout.write("Configuring...\n") nodesrc.configure() sys.stdout.write("Building...\n") nodesrc.make() sys.stdout.write("Installing...\n") nodesrc.make_install() except StandardError: err = sys.exc_info()[1] sys.stderr.write("Error: %s\n" % str(err)) sys.exit(2) finally: sys.stdout.write("Cleaning up...\n") try: nodesrc.cleanup() except StandardError: pass
def install(ver, build_args): """ This calls the correct functions in the correct order to install Node. It also handles exceptions. """ if shared.version_exists(ver): sys.stderr.write("Error: %s is already installed\n" % ver) sys.exit(1) elif not shared.valid_version_string(ver): sys.stderr.write("Error: %s doesn't look like a valid version\n" % ver) sys.exit(2) try: nodesrc = install_helper.NodeSourceInstaller( ver, shared.get_version_dir(ver), build_args) sys.stdout.write("Downloading...\n") nodesrc.download() sys.stdout.write("Extracting...\n") nodesrc.extract() sys.stdout.write("Patching...\n") if len(shared.get_patches_list(ver)) == 0: sys.stdout.write("No patches found.\n") else: nodesrc.patch() sys.stdout.write("Configuring...\n") nodesrc.configure() sys.stdout.write("Building...\n") nodesrc.make() sys.stdout.write("Installing...\n") nodesrc.make_install() except StandardError: err = sys.exc_info()[1] sys.stderr.write("Error: %s\n" % str(err)) sys.exit(2) finally: sys.stdout.write("Cleaning up...\n") try: nodesrc.cleanup() except StandardError: pass