Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    def checkout(self, revision=None):
        if revision is None:
            revision = self.tag
            if revision is None:
                revision = self._branch

        command.run(["git", "checkout", revision])
Exemple #4
0
    def checkout(self, revision=None):
        if revision is None:
            revision = self.tag
            if revision is None:
                revision = self._branch

        command.run(["git", "checkout", revision])
Exemple #5
0
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])
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
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)
Exemple #11
0
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
Exemple #12
0
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
Exemple #13
0
    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
Exemple #14
0
    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
Exemple #15
0
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
Exemple #16
0
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
Exemple #17
0
    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])
Exemple #18
0
    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])
Exemple #19
0
    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])
Exemple #20
0
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
Exemple #21
0
    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])
Exemple #22
0
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()
Exemple #23
0
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()
Exemple #24
0
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)
Exemple #25
0
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)
Exemple #26
0
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
Exemple #27
0
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
Exemple #28
0
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)
Exemple #29
0
def _build_grunt(module):
    command.run(["volo", "-nostamp", "-f", "add"], retry=10)
    command.run(["npm", "install"], retry=10)
Exemple #30
0
def _build_npm(module):
    command.run(["npm", "install", "-g", "--prefix", config.install_dir])
Exemple #31
0
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)
Exemple #32
0
    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
Exemple #33
0
    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])