コード例 #1
0
ファイル: signtool.py プロジェクト: mozilla-releng/signtool
def sign(options, args):
    token = open(options.tokenfile, 'rb').read()

    for fmt in options.formats:
        urls = options.format_urls[fmt][:]
        random.shuffle(urls)

        if fmt in ("macapp", ):
            fmt = "dmg"

        log.debug("doing %s signing", fmt)
        log.debug("possible hosts are %s" % urls)
        files = []
        # We sign all of the files individually.
        files = findfiles(args, options.includes, options.excludes)

        for f in files:
            log.debug("%s", f)
            log.debug("checking %s for signature...", f)
            if fmt.startswith('sha2signcode') and is_authenticode_signed(f):
                log.info("Skipping %s because it looks like it's already signed", f)
                continue
            if options.output_dir:
                dest = os.path.join(options.output_dir, os.path.basename(f))
            elif options.output_file:
                dest = options.output_file
            else:
                dest = None

            if not remote_signfile(options, urls, f, fmt, token, dest):
                log.error("Failed to sign %s with %s", f, fmt)
                sys.exit(1)
コード例 #2
0
def sign(options, args):
    token = open(options.tokenfile, 'rb').read()

    for fmt in options.formats:
        urls = options.format_urls[fmt][:]
        random.shuffle(urls)

        if fmt in ("macapp", ):
            fmt = "dmg"

        log.debug("doing %s signing", fmt)
        log.debug("possible hosts are %s" % urls)
        files = []
        # We sign all of the files individually.
        files = findfiles(args, options.includes, options.excludes)

        for f in files:
            log.debug("%s", f)
            log.debug("checking %s for signature...", f)
            if fmt in ('sha2signcode', 'signcode', 'osslsigncode') and is_authenticode_signed(f):
                log.info("Skipping %s because it looks like it's already signed", f)
                continue
            if options.output_dir:
                dest = os.path.join(options.output_dir, os.path.basename(f))
            else:
                dest = None

            if not remote_signfile(options, urls, f, fmt, token, dest):
                log.error("Failed to sign %s with %s", f, fmt)
                sys.exit(1)
def test_find_files(tmpdir):
    tmp = tmpdir.strpath
    os.makedirs(os.path.join(tmp, "d1"))
    with open(os.path.join(tmp, "foo"), 'w') as fh:
        fh.write("hello")
    with open(os.path.join(tmp, "d1", "bar"), 'w') as fh:
        fh.write("world")
    assert paths.findfiles(tmp) == [os.path.join(tmp, "foo"), os.path.join(tmp, "d1", "bar")]
    assert paths.finddirs(tmp) == [os.path.join(tmp, "d1")]
コード例 #4
0
ファイル: archives.py プロジェクト: escapewindow/signtool
def packmar(marfile, srcdir):
    """Create marfile from the contents of srcdir"""
    nullfd = open(os.devnull, "w")
    files = [f[len(srcdir) + 1:] for f in findfiles(srcdir)]
    marfile = cygpath(os.path.abspath(marfile))
    try:
        check_call(
            [MAR, '-c', marfile] + files, cwd=srcdir, preexec_fn=_noumask)
    except Exception:
        log.exception("Error packing mar file %s from %s", marfile, srcdir)
        raise
    nullfd.close()
コード例 #5
0
def packmar(marfile, srcdir):
    """Create marfile from the contents of srcdir"""
    nullfd = open(os.devnull, "w")
    files = [f[len(srcdir) + 1:] for f in findfiles(srcdir)]
    marfile = cygpath(os.path.abspath(marfile))
    try:
        check_call([MAR, '-c', marfile] + files,
                   cwd=srcdir,
                   preexec_fn=_noumask)
    except Exception:
        log.exception("Error packing mar file %s from %s", marfile, srcdir)
        raise
    nullfd.close()
def test_find_files2(tmpdir):
    tmp = tmpdir.strpath
    orig_dir = os.getcwd()
    tarball = os.path.abspath(os.path.join(os.path.dirname(__file__), "data", "dirtree.tgz"))
    try:
        os.chdir(tmp)
        subprocess.check_call(["tar", "xf", tarball])
        files = paths.findfiles(['dir1', 'dir2', 'no_dir'], includes=('*.*', ), excludes=('*.tar.*', ))
        assert sorted(files) == sorted([
            "no_dir",
            os.path.join("dir1", "file1.exe"),
            os.path.join("dir1", "dir1_a", "dir1_a_1", "file1_a_1.dmg"),
            os.path.join("dir1", "dir1_a", "dir1_a_1", "file1_a_1.jpg"),
        ])
    finally:
        os.chdir(orig_dir)