コード例 #1
0
def script_get_book():
    dd = el.default_directory()
    d1 = el.locate_dominating_file(dd, "Cookbook.py")
    d2 = el.locate_dominating_file(dd, "cook/Cookbook.py")
    if d1 and (not d2 or len(d1) > len(d2) - 5):
        return (d1, el.file_name_directory(d1))
    elif d2:
        return (d2, el.file_name_directory(el.file_name_directory(d2)))
    else:
        raise RuntimeError("No Cookbook.py or cook/Cookbook.py found")
コード例 #2
0
def compile_and_run(recipe, source_file):
    class_file = re.sub("java$", "class", source_file)
    assert el.file_exists_p(source_file)
    source = el.file_name_nondirectory(source_file)
    path = el.file_name_directory(source_file)
    name = el.file_name_sans_extension(source)
    res = []
    if (not el.file_exists_p(class_file) or
            el.file_newer_than_file_p(source_file, class_file)):
        res += [lf("javac {source_file}")]
    res += [lf("java -cp {path} {name}")]
    return res
コード例 #3
0
def git_clone(url, target_dir, commit=None):
    target_dir = el.expand_file_name(target_dir)
    if el.file_exists_p(target_dir):
        print(lf("{target_dir}: OK"))
    else:
        gdir = el.expand_file_name(target_dir)
        pdir = el.file_name_directory(gdir)
        if not el.file_exists_p(pdir):
            el.make_directory(pdir)
        (_, gdir) = el.parse_fname(gdir)
        sc("git clone --recursive {url} {gdir}")
        if commit:
            sc("cd {gdir} && git reset --hard {commit}")
コード例 #4
0
def modules(full=False, match=False):
    cook_dir = el.file_name_directory(recipes.__file__)
    cook_modules = el.directory_files(cook_dir, full, match)
    user_dir = el.expand_file_name("~/.cook.d")
    if el.file_exists_p(user_dir):
        df = el.directory_files(user_dir, full, match)
        user_modules = [
            f for f in df if os.path.isfile(el.expand_file_name(f, user_dir))
            and os.path.splitext(f)[1] == ".py"
        ]
    else:
        user_modules = []
    cook_modules += user_modules
    return list(filter(lambda s: not re.search("__", s), cook_modules))
コード例 #5
0
def install_root_cert(certfile, certname=None):
    """Install root certificate to certificate trust store of applications using NSS"""
    install_package("libnss3-tools")
    name_crt = el.file_name_nondirectory(certfile) if certname is None else certname
    # Firefox and Chromium
    if not el.file_exists_p("/tmp/cert9.db.done"):
        dbs = el.sc_l("find ~/ -name cert9.db 2>/dev/null || true")
        for db in dbs:
            certdir = el.file_name_directory(db)
            el.scb("certutil -A -n '{name_crt}' -t 'TCu,Cu,Tu' -i {certfile} -d sql:{certdir}")
        el.barf("/tmp/cert9.db.done", "")
    # curl
    cp_cmd = cp_host if el.HOST else cp
    fname_crt = lf("/usr/local/share/ca-certificates/{name_crt}")
    cp_cmd(certfile, fname_crt)
    chmod(fname_crt, "644")
    name_pem = el.file_name_sans_extension(name_crt) + ".pem"
    fname_pem = lf("/etc/ssl/certs/{name_pem}")
    make(fname_pem, sudo("update-ca-certificates"))
    # wget
    install_package("ca-certificates")
    patch("/etc/wgetrc", ["+ca_directory=/etc/ssl/certs"])
コード例 #6
0
def reinstall(recipe, user_input=True):
    dd = el.default_directory()
    git1 = el.locate_dominating_file(dd, ".git")
    git2 = el.file_name_directory(git1)
    pip = get_pip()
    return ["cd " + git2, lf("{pip} install --upgrade .")]