示例#1
0
文件: arches.py 项目: tianon/debile
def arch_matches(arch, alias):
    """
    Check if given arch `arch` matches the other arch `alias`. This is most
    useful for the complex any-* rules.
    """

    if arch == alias or alias == "any":
        return True

    if alias == 'linux-any':
        # This is a generalization for Debian. Please update if this is
        # wrong for other places. A hit to shell out is *COSTLY*; like; orders
        # of magnatude more costly.
        return not '-' in arch

    if alias == 'kfreebsd-any':
        return 'kfreebsd-' in arch

    if alias == 'hurd-any':
        return 'hurd-' in arch

    if not "-" in arch and not "-" in alias:
        return False

    # This is a f*****g disaster for perf. Do what we can to not get here.
    out, err, ret = run_command([
        "/usr/bin/dpkg-architecture",
        "-a%s" % (arch),
        "-i%s" % (alias)
    ])
    return ret == 0
示例#2
0
 def _exec(self, *args):
     cmd = [
         "reprepro",
         "-Vb",
         self.root,
     ] + list(args)
     out, err, ret = run_command(cmd)
     if ret != 0:
         raise RepoException(ret)
     return (out, err, ret)
示例#3
0
    def validate_signature(self, check_signature=True):
        """
        Validate the GPG signature of a .changes file.

        Throws a :class:`dput.exceptions.ChangesFileException` if there's
        an issue with the GPG signature. Returns the GPG key ID.
        """
        gpg_path = "gpg"

        (gpg_output, gpg_output_stderr, exit_status) = run_command([
            gpg_path, "--status-fd", "1", "--verify",
            "--batch", self.get_changes_file()
        ])

        if exit_status == -1:
            raise ChangesFileException(
                "Unknown problem while verifying signature")

        # contains verbose human readable GPG information
        if self.is_python3:
            gpg_output_stderr = str(gpg_output_stderr, encoding='utf8')

        if self.is_python3:
            gpg_output = gpg_output.decode(encoding='UTF-8')

        if gpg_output.count('[GNUPG:] GOODSIG'):
            pass
        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise ChangesFileException("Bad signature")
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise ChangesFileException("Error verifying signature")
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise ChangesFileException("No signature on")
        else:
            raise ChangesFileException(
                "Unknown problem while verifying signature"
            )

        key = None
        for line in gpg_output.split("\n"):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key
示例#4
0
    def validate_signature(self, check_signature=True):
        """
        Validate the GPG signature of a .changes file.

        Throws a :class:`dput.exceptions.ChangesFileException` if there's
        an issue with the GPG signature. Returns the GPG key ID.
        """
        gpg_path = "gpg"

        (gpg_output, gpg_output_stderr, exit_status) = run_command([
            gpg_path, "--status-fd", "1", "--verify", "--batch",
            self.get_changes_file()
        ])

        if exit_status == -1:
            raise ChangesFileException(
                "Unknown problem while verifying signature")

        # contains verbose human readable GPG information
        if self.is_python3:
            gpg_output_stderr = str(gpg_output_stderr, encoding='utf8')

        if self.is_python3:
            gpg_output = gpg_output.decode(encoding='UTF-8')

        if gpg_output.count('[GNUPG:] GOODSIG'):
            pass
        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise ChangesFileException("Bad signature")
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise ChangesFileException("Error verifying signature")
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise ChangesFileException("No signature on")
        else:
            raise ChangesFileException(
                "Unknown problem while verifying signature")

        key = None
        for line in gpg_output.split("\n"):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key
示例#5
0
文件: bget.py 项目: lfaraone/debile
def dget(path):
    out, err, ret = run_command(["dget", "-u", path])
    if ret != 0:
        print ret, err
        raise Exception("DAMNIT; dget f****d us")
示例#6
0
 def _exec(self, *args):
     cmd = ["reprepro", "-Vb", self.root,] + list(args)
     out, err, ret = run_command(cmd)
     if ret != 0:
         raise RepoException(ret)
     return (out, err, ret)
示例#7
0
def dget(path):
    out, err, ret = run_command(["dget", "-u", path])
    if ret != 0:
        print ret, err
        raise Exception("DAMNIT; dget f****d us")