コード例 #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
ファイル: reprepro.py プロジェクト: schevalier/debile
 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
ファイル: changes.py プロジェクト: LeoCavaille/debile
    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
ファイル: changes.py プロジェクト: schevalier/debile
    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
ファイル: reprepro.py プロジェクト: LeoCavaille/debile
 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")