def METHOD_NAME(self, input_file, keyid, passphrase_file, passphrase=None, armor=True):
    """Create a detached signature of a file"""
    if passphrase_file and passphrase:
        raise Exception("You should use either passphrase_file of passphrase, not both")
    cmd = self.gpg_cmd + ['--detach-sign', '--no-permission-warning', '--batch',
           '--no-tty', '--yes', '--passphrase-fd', '0', '-u', keyid]
    if self.gpg_path:
        cmd += ['--homedir', self.gpg_path]
    if armor:
        cmd += ['--armor']
    #gpg > 2.1 supports password pipes only through the loopback interface
    #gpg < 2.1 errors out if given unknown parameters
    if self.gpg_version > (2,1,):
        cmd += ['--pinentry-mode', 'loopback']
    cmd += [input_file]
    try:
        if passphrase_file:
            with open(passphrase_file) as fobj:
                passphrase = fobj.readline();
        job = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
        (_, stderr) = job.communicate(passphrase.encode("utf-8"))
        if job.returncode:
            bb.fatal("GPG exited with code %d: %s" % (job.returncode, stderr.decode("utf-8")))
    except IOError as e:
        bb.error("IO error (%s): %s" % (e.errno, e.strerror))
        raise Exception("Failed to sign '%s'" % input_file)
    except OSError as e:
        bb.error("OS error (%s): %s" % (e.errno, e.strerror))
        raise Exception("Failed to sign '%s" % input_file)