예제 #1
0
파일: build.py 프로젝트: Mestway/Queries
def run_osc_commit(name, tmppath, commit_msg):
    repopath = Path("home:gatoatigrado1/%s" % (name))
    skip = False
    if Path("home:gatoatigrado1").exists():
        with ExecuteIn(Path("home:gatoatigrado1")):
            skip = list(SubProc(["osc", "status"]).exec_lines()) == []
    if not skip:
        try:
            SubProc(["osc", "co", "home:gatoatigrado1", name]).start_wait()
        except OSError:
            print("\n\n\nosc not found in path; install with 'sudo zypper -n in osc'", file=sys.stderr)
    else:
        print("skipping already checked out source.")
    [v.copy(repopath.subpath(v.basename())) for v in tmppath.files()]
    with ExecuteIn(repopath):
        SubProc(["osc", "add"] + [v for v in Path(".").listdir() if v != ".osc"]).start_wait()
        SubProc(["osc", "commit"] + (["-m", commit_msg]
            if commit_msg else [])).start_wait()
예제 #2
0
def run_osc_commit(name, tmppath, commit_msg):
    repopath = Path("home:gatoatigrado1/%s" % (name))
    skip = False
    if Path("home:gatoatigrado1").exists():
        with ExecuteIn(Path("home:gatoatigrado1")):
            skip = list(SubProc(["osc", "status"]).exec_lines()) == []
    if not skip:
        try:
            SubProc(["osc", "co", "home:gatoatigrado1", name]).start_wait()
        except OSError:
            print(
                "\n\n\nosc not found in path; install with 'sudo zypper -n in osc'",
                file=sys.stderr)
    else:
        print("skipping already checked out source.")
    [v.copy(repopath.subpath(v.basename())) for v in tmppath.files()]
    with ExecuteIn(repopath):
        SubProc(["osc", "add"] +
                [v for v in Path(".").listdir() if v != ".osc"]).start_wait()
        SubProc(["osc", "commit"] +
                (["-m", commit_msg] if commit_msg else [])).start_wait()
예제 #3
0
def main(name, version, proj_path, conf_path, no_inc_release, tmpdir,
         run_local_install, osc_commit, commit_msg, upload_to_cobol,
         additional_path):

    proj_path, conf_path, tmpdir = Path(proj_path), Path(conf_path), Path(
        tmpdir)
    assert proj_path.subpath(
        ".hg").isdir(), "please run in base directory (with .hg)"
    check_modified()

    version = get_sketch_version(proj_path) if version is None else version
    # NOTE -- need to use gz instead of lzma for Debian compatibility
    sourcefile = "%s_%s.orig.tar.gz" % (name, version)
    release_number_v = get_release_version(conf_path, no_inc_release)

    tmppath = tmpdir.subpath("%s-%s" % (name, version))
    if tmppath.exists():
        print("temporary directory exists; delete it? ", end="")
        sys.stdout.flush()
        if "y" in raw_input():
            tmppath.rmtree()
    tmppath.makedirs()

    srcpath = tmppath.subpath("%s-%s" % (name, version))
    proj_path.copytree(srcpath)

    pathmap = {
        "debian.control": srcpath.subpath("debian/control"),
        "debian.rules": srcpath.subpath("debian/rules"),
        "debian.changelog": srcpath.subpath("debian/changelog")
    }

    with ExecuteIn(srcpath):
        assert (Path(".") != proj_path)
        SubProc(["zsh", "-c", r"rm -rf $(hg stat -uin) .hg*"]).start_wait()

    files = [conf_path.subpath("%s.spec.jinja2" % (name))]
    nondsc_files = [v for v in files if not "dsc" in v]
    dsc_files = [v for v in files if "dsc" in v]
    with ExecuteIn(conf_path):
        run_jinja2(nondsc_files, tmppath, name, version, sourcefile,
                   release_number_v, pathmap)

    if additional_path:
        additional_path = Path(additional_path)
        final_path = srcpath.subpath(additional_path.basename())
        final_path.rmtree()
        additional_path.copytree(final_path)

    with ExecuteIn(tmppath):
        SubProc(["tar", "cfa", sourcefile, srcpath.basename()]).start_wait()
        srcpath.rmtree()

    with ExecuteIn(conf_path):
        run_jinja2(dsc_files, tmppath, name, version, sourcefile,
                   release_number_v, pathmap)

    with ExecuteIn(tmppath):
        if run_local_install:
            SubProc(["build"]).start_wait()
        if osc_commit:
            run_osc_commit(name, tmppath, commit_msg)

    if upload_to_cobol:
        with ExecuteIn(tmpdir):
            if osc_commit:
                repopath.parent().rmtree()
            tar_name = sourcefile.replace("lzma", "tar")
            SubProc(["tar", "cfa", tar_name, tmppath.basename()]).start_wait()
            SubProc([
                "scp", tar_name, "[email protected]:public_html/temp"
            ])
예제 #4
0
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain a
# copy of the License at http://www.apache.org/licenses/LICENSE-2.0 .
from __future__ import division, print_function
from collections import namedtuple

try:
    from gatoatigrado_lib import (ExecuteIn, Path, SubProc, dict, get_singleton,
        list, memoize_file, pprint, process_jinja2, set, sort)
except:
    raise ImportError("please install gatoatigrado's utility library from "
            "bitbucket.org/gatoatigrado/gatoatigrado_lib")

modpath = Path(__file__).parent()
includepath = modpath.subpath("includes")

def main():
    from jinja2 import Environment, FileSystemLoader
    import jinja2.ext
    mvnfile = Path("pom.xml")
    assert mvnfile.exists(), "please run in project root (with ./pom.xml)"
    version = "1.6.4"

    paths = list(modpath.walk_files(["jinja2"]))
    dirs = frozenset(v.parent() for v in paths).union((includepath,))
    env = Environment(loader=FileSystemLoader(list(dirs)),
        trim_blocks=True, extensions=[jinja2.ext.do])
    env.globals.update({"version": version})

    for fname in Path("scripts").walk_files(["jinja2"]):
예제 #5
0
파일: build.py 프로젝트: Mestway/Queries
def main(name, version, proj_path, conf_path, no_inc_release, tmpdir, run_local_install,
        osc_commit, commit_msg, upload_to_cobol, additional_path):

    proj_path, conf_path, tmpdir = Path(proj_path), Path(conf_path), Path(tmpdir)
    assert proj_path.subpath(".hg").isdir(), "please run in base directory (with .hg)"
    check_modified()

    version = get_sketch_version(proj_path) if version is None else version
    # NOTE -- need to use gz instead of lzma for Debian compatibility
    sourcefile = "%s_%s.orig.tar.gz" % (name, version)
    release_number_v = get_release_version(conf_path, no_inc_release)

    tmppath = tmpdir.subpath("%s-%s" % (name, version))
    if tmppath.exists():
        print("temporary directory exists; delete it? ", end="")
        sys.stdout.flush()
        if "y" in raw_input():
            tmppath.rmtree()
    tmppath.makedirs()

    srcpath = tmppath.subpath("%s-%s" % (name, version))
    proj_path.copytree(srcpath)

    pathmap = { "debian.control": srcpath.subpath("debian/control"),
        "debian.rules": srcpath.subpath("debian/rules"),
        "debian.changelog": srcpath.subpath("debian/changelog") }

    with ExecuteIn(srcpath):
        assert (Path(".") != proj_path)
        SubProc(["zsh", "-c", r"rm -rf $(hg stat -uin) .hg*"]).start_wait()

    files = [conf_path.subpath("%s.spec.jinja2" % (name))]
    nondsc_files = [v for v in files if not "dsc" in v]
    dsc_files = [v for v in files if "dsc" in v]
    with ExecuteIn(conf_path):
        run_jinja2(nondsc_files, tmppath, name, version,
            sourcefile, release_number_v, pathmap)

    if additional_path:
        additional_path = Path(additional_path)
        final_path = srcpath.subpath(additional_path.basename())
        final_path.rmtree()
        additional_path.copytree(final_path)

    with ExecuteIn(tmppath):
        SubProc(["tar", "cfa", sourcefile, srcpath.basename()]).start_wait()
        srcpath.rmtree()

    with ExecuteIn(conf_path):
        run_jinja2(dsc_files, tmppath, name, version,
            sourcefile, release_number_v, pathmap)

    with ExecuteIn(tmppath):
        if run_local_install:
            SubProc(["build"]).start_wait()
        if osc_commit:
            run_osc_commit(name, tmppath, commit_msg)

    if upload_to_cobol:
        with ExecuteIn(tmpdir):
            if osc_commit:
                repopath.parent().rmtree()
            tar_name = sourcefile.replace("lzma", "tar")
            SubProc(["tar", "cfa", tar_name, tmppath.basename()]).start_wait()
            SubProc(["scp", tar_name, "[email protected]:public_html/temp"])
예제 #6
0
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain a
# copy of the License at http://www.apache.org/licenses/LICENSE-2.0 .
from __future__ import division, print_function
from collections import namedtuple

try:
    from gatoatigrado_lib import (ExecuteIn, Path, SubProc, dict,
                                  get_singleton, list, memoize_file, pprint,
                                  process_jinja2, set, sort)
except:
    raise ImportError("please install gatoatigrado's utility library from "
                      "bitbucket.org/gatoatigrado/gatoatigrado_lib")

modpath = Path(__file__).parent()
includepath = modpath.subpath("includes")


def main():
    from jinja2 import Environment, FileSystemLoader
    import jinja2.ext
    mvnfile = Path("pom.xml")
    assert mvnfile.exists(), "please run in project root (with ./pom.xml)"
    version = "1.6.4"

    paths = list(modpath.walk_files(["jinja2"]))
    dirs = frozenset(v.parent() for v in paths).union((includepath, ))
    env = Environment(loader=FileSystemLoader(list(dirs)),
                      trim_blocks=True,
                      extensions=[jinja2.ext.do])
    env.globals.update({"version": version})