def update(self, revision=None): if not self.exists(): self._clone() return orig_cwd = os.getcwd() os.chdir(self.local) if revision is None: if self.tag and self._head_has_tag(self.tag): os.chdir(orig_cwd) return revision = self.tag commit_id = self._get_commit_id() if revision == commit_id: os.chdir(orig_cwd) return command.run(["git", "remote", "set-url", "origin", self.remote]) command.run(["git", "fetch"], retry=self._retry) if revision: command.run(["git", "checkout", revision]) else: command.run(["git", "checkout", self._branch]) command.run(["git", "merge", "--ff-only", "origin/%s" % self._branch]) os.chdir(orig_cwd)
def update(self, revision=None): if not self.exists(): self._clone() return orig_cwd = os.getcwd() os.chdir(self.local) if revision is None: if self.tag and self._head_has_tag(self.tag): os.chdir(orig_cwd) return revision = self.tag commit_id = self._get_commit_id() if revision == commit_id: os.chdir(orig_cwd) return command.run(["git", "remote", "set-url", "origin", self.remote]) command.run(["git", "fetch"], retry=self._retry) if revision: command.run(["git", "checkout", revision]) else: command.run(["git", "checkout", self._branch]) command.run( ["git", "merge", "--ff-only", "origin/%s" % self._branch]) os.chdir(orig_cwd)
def checkout(self, revision=None): if revision is None: revision = self.tag if revision is None: revision = self._branch command.run(["git", "checkout", revision])
def _build_distutils(module): site_packages = os.path.join(config.install_dir, "lib", "python2.7", "site-packages") utils.ensure_dir(site_packages) setup = os.path.join(module.get_source_dir(), "setup.py") command.run(["python", setup, "install", "--prefix", config.install_dir])
def _autotools_dist_builder(module): source_dir = module.get_source_dir() os.chdir(source_dir) command.run(["make", "distcheck"]) makefile = parse_makefile(os.path.join(source_dir, "Makefile")) tarball = "%s-%s.tar.xz" % (module.name, makefile["VERSION"]) shutil.move(os.path.join(source_dir, tarball), os.path.join(config.get_dist_dir(), tarball)) return True
def _autotools_checker(module): result = True os.chdir(module.get_source_dir()) xvfb_proc, orig_display = xvfb.start() try: command.run(["dbus-launch", "--exit-with-session", "make", "check"]) except subprocess.CalledProcessError: result = False xvfb.stop(xvfb_proc, orig_display) return result
def build(): print("\n= Building docs =\n") clean() for module in config.load_modules(): if module.has_docs: print("* Generating %s" % module.name) os.chdir(module.get_source_dir()) output_dir = os.path.join(config.docs_dir, module.docs_dir) command.run(["docker", "-I", "-c", "default", "-o", output_dir]) return True
def _volo_checker(module): source_dir = module.get_source_dir() os.chdir(source_dir) with open("package.json") as f: package = json.load(f) if "dependencies" in package["volo"]: command.run(["volo", "-nostamp", "-f", "add"]) test_dir = os.path.join(source_dir, "test") if os.path.exists(test_dir): os.chdir(test_dir) subprocess.check_call(["karma", "start", "--single-run"]) for root, dirs, files in os.walk(module.get_source_dir()): if root == source_dir and "lib" in dirs: dirs.remove("lib") for f in files: path = os.path.join(root, f) if f.endswith(".js"): try: command.run(["jshint", path]) except subprocess.CalledProcessError: return False logging.info("Running js-beautify on %s" % path) args = ["js-beautify", "--good-stuff", path] if _diff_output(subprocess.check_output(args), path): return False elif f.endswith(".css"): less_name = f.replace(".css", ".less") if os.path.exists(os.path.join(root, less_name)): continue logging.info("Running js-beautify on %s" % path) args = [ "js-beautify", "--type", "css", "--indent-size", "2", path ] if _diff_output(subprocess.check_output(args), path): return False elif f.endswith(".html"): logging.info("Running js-beautify on %s" % path) args = [ "js-beautify", "--type", "html", "--indent-size", "2", path ] if _diff_output(subprocess.check_output(args), path): return False return True
def run(cmd): args = [cmd, "--home-dir", config.home_dir] resolution = config.get_pref("RESOLUTION") if resolution: args.extend(["--resolution", resolution]) output = config.get_pref("OUTPUT") if output: args.extend(["--output", output]) signal.signal(signal.SIGINT, signal.SIG_IGN) command.run(args)
def _volo_checker(module): source_dir = module.get_source_dir() os.chdir(source_dir) with open("package.json") as f: package = json.load(f) if "dependencies" in package["volo"]: command.run(["volo", "-nostamp", "-f", "add"]) test_dir = os.path.join(source_dir, "test") if os.path.exists(test_dir): os.chdir(test_dir) subprocess.check_call(["karma", "start", "--single-run"]) for root, dirs, files in os.walk(module.get_source_dir()): if root == source_dir and "lib" in dirs: dirs.remove("lib") for f in files: path = os.path.join(root, f) if f.endswith(".js"): try: command.run(["jshint", path]) except subprocess.CalledProcessError: return False logging.info("Running js-beautify on %s" % path) args = ["js-beautify", "--good-stuff", path] if _diff_output(subprocess.check_output(args), path): return False elif f.endswith(".css"): less_name = f.replace(".css", ".less") if os.path.exists(os.path.join(root, less_name)): continue logging.info("Running js-beautify on %s" % path) args = ["js-beautify", "--type", "css", "--indent-size", "2", path] if _diff_output(subprocess.check_output(args), path): return False elif f.endswith(".html"): logging.info("Running js-beautify on %s" % path) args = ["js-beautify", "--type", "html", "--indent-size", "2", path] if _diff_output(subprocess.check_output(args), path): return False return True
def clean(self, new_files=False): try: os.chdir(self.local) except OSError: return False options = "-fd" if new_files: options = options + "x" else: options = options + "X" command.run(["git", "clean", options]) return True
def _distutils_checker(module): result = True os.chdir(module.get_source_dir()) command.run(["python", "setup.py", "lint"]) xvfb_proc, orig_display = xvfb.start() try: command.run(["python", "setup.py", "test"]) except subprocess.CalledProcessError: result = False xvfb.stop(xvfb_proc, orig_display) return result
def _clone(self): os.chdir(self._path) command.run(["git", "clone", "--progress", self.remote, self._name], retry=self._retry) os.chdir(self.local) if config.git_user_name: command.run(["git", "config", "user.name", config.git_user_name]) if config.git_email: command.run(["git", "config", "user.email", config.git_email]) if self.tag: command.run(["git", "checkout", self.tag]) else: command.run(["git", "checkout", self._branch])
def update(self, source={}): if not self.exists(): self._clone() return os.chdir(self.local) remote = source.get("repository", self._remotes["origin"]) revision = source.get("revision", self.tag) command.run(["git", "remote", "set-url", "origin", remote]) command.run(["git", "fetch"], retry=self._retry) if revision: command.run(["git", "checkout", revision]) else: command.run(["git", "checkout", self._branch]) command.run(["git", "merge", "--ff-only", "origin/%s" % self._branch])
def run(cmd, **kwargs): args = [cmd] prefs = config.get_prefs() if "resolution" in prefs: args.extend(["--resolution", prefs["resolution"]]) if "output" in prefs: args.extend(["--output", prefs["output"]]) signal.signal(signal.SIGINT, signal.SIG_IGN) try: command.run(args, **kwargs) except subprocess.CalledProcessError: return False return True
def update(self, revision=None): if not self.exists(): self._clone() return os.chdir(self.local) if revision is None: revision = self.tag command.run(["git", "remote", "set-url", "origin", self._remotes["origin"]]) command.run(["git", "fetch"], retry=self._retry) if revision: command.run(["git", "checkout", revision]) else: command.run(["git", "checkout", self._branch]) command.run(["git", "merge", "--ff-only", "origin/%s" % self._branch])
def _build_autotools(module, log): # Workaround for aclocal 1.11 (fixed in 1.12) aclocal_path = os.path.join(config.share_dir, "aclocal") utils.ensure_dir(aclocal_path) makefile_path = os.path.join(module.get_source_dir(), module.makefile_name) if not os.path.exists(makefile_path): configure = os.path.join(module.get_source_dir(), "autogen.sh") if not os.path.exists(configure): configure = os.path.join(module.get_source_dir(), "configure") args = [configure, "--prefix", config.install_dir] if not module.no_libdir: args.extend(["--libdir", config.lib_dir]) args.extend(module.options) for option in module.options_evaluated: args.append(_eval_option(option)) command.run(args, log) jobs = multiprocessing.cpu_count() * 2 command.run(["make", "-j", "%d" % jobs], log) command.run(["make", "install"], log) _unlink_libtool_files()
def _build_npm(module, log): if os.path.exists(os.path.join(module.get_source_dir(), "Gruntfile.coffee")): command.run(["npm", "install", "grunt"]) command.run(["grunt", "build"]) command.run(["npm", "install", "-g", "--prefix", config.install_dir], log)
def build(): print("\n= Building docs =\n") clean() for module in config.load_modules(): if module.has_docs: print("* Generating %s" % module.name) os.chdir(module.get_source_dir()) output_dir = os.path.join(config.docs_dir, module.docs_dir) if module.docs_extras is None: extras = ["addHeader"] else: extras = module.docs_extras args = ["docker", "-I", "-c", "default", "-o", output_dir] args.extend(["--extras", ",".join(extras)]) command.run(args) return True
def _volo_checker(module): source_dir = module.get_source_dir() os.chdir(source_dir) with open("package.json") as f: package = json.load(f) if "dependencies" in package["volo"]: command.run(["volo", "-nostamp", "-f", "add"], retry=10) test_dir = os.path.join(source_dir, "test") if os.path.exists(test_dir): os.chdir(test_dir) command.run(["karma", "start", "--single-run", "--no-colors", "--log-level debug"]) for root, dirs, files in os.walk(module.get_source_dir()): if root == source_dir and "lib" in dirs: dirs.remove("lib") for f in files: path = os.path.join(root, f) if f.endswith(".js"): try: command.run(["jshint", path]) except subprocess.CalledProcessError: return False logging.info("Running js-beautify on %s" % path) args = ["js-beautify", "--good-stuff", path] if _diff_output(subprocess.check_output(args), path): return False elif f.endswith(".css") or f.endswith(".less"): if f.endswith(".css"): less_name = f.replace(".css", ".less") if os.path.exists(os.path.join(root, less_name)): continue elif f.endswith(".less"): with open(path) as less_file: line = less_file.readline() if line.startswith("// recess: ignore"): continue logging.info("Running recess on %s" % path) args = ["recess", "-noIDs", "false", "-noOverqualifying", "false", "--stripColors", path] output = subprocess.check_output(args) logging.info(output) if "STATUS: Perfect!" not in output: return False return True
def _build_distutils(module, log): setup = os.path.join(module.get_source_dir(), "setup.py") command.run(["python", setup, "install", "--prefix", config.install_dir], log)
def _build_grunt(module): command.run(["volo", "-nostamp", "-f", "add"], retry=10) command.run(["npm", "install"], retry=10)
def _build_npm(module): command.run(["npm", "install", "-g", "--prefix", config.install_dir])
def clean(self): result = True if not config.interactive: command.run(["git", "clean", "-fdx"]) command.run(["git", "reset", "--hard"]) return result command.run(["git", "clean", "-fdX"]) files = subprocess.check_output(["git", "ls-files", "--others"]).strip() if files: print("\n# The repository contains files which have not been " "added to the index:\n") print(files) print("\nPress d to delete them, k to keep them.\n") while True: key = utils.getch() if key == "d": command.run(["git", "clean", "-fdx"]) break elif key == "k": result = False break added = subprocess.check_output(["git", "diff", "--cached", "--name-only"]).strip() modified = subprocess.check_output(["git", "ls-files", "--modified"]).strip() deleted = subprocess.check_output(["git", "ls-files", "--deleted"]).strip() if added or modified or deleted: print("\n# The repository content has been modified.") if added: print("\nAdded files:") print(added) if modified: print("\nModified files:") print(modified) if deleted: print("\nDeleted files") print(deleted) print("\nPress r to reset the changes, k to keep them.\n") while True: key = utils.getch() if key == "r": command.run(["git", "reset", "--hard"]) break elif key == "k": result = False break return result
def _clone(self): os.chdir(self._path) command.run(["git", "clone", "--progress", self._remotes["origin"], self._name], retry=self._retry) os.chdir(self.local) for name, remote in self._remotes.items(): if name != "origin": command.run(["git", "remote", "add", name, remote]) if config.git_user_name: command.run(["git", "config", "user.name", config.git_user_name]) if config.git_email: command.run(["git", "config", "user.email", config.git_email]) if self.tag: command.run(["git", "checkout", self.tag]) else: command.run(["git", "checkout", self._branch])