# Path: elbepack/egpg.py
# def unsign_file(fname):
#     # check for .gpg extension and create an output filename without it
#     if len(fname) <= 4 or fname[len(fname) - 4:] != '.gpg':
#         print("The input file needs a .gpg extension")
#         return None
# 
#     outfilename = fname[:len(fname) - 4]
# 
#     ctx = core.Context()
#     ctx.set_engine_info(PROTOCOL_OpenPGP,
#                         None,
#                         '/var/cache/elbe/gnupg')
#     ctx.set_armor(False)
# 
#     overall_status = OverallStatus()
# 
#     try:
#         infile  = core.Data(file=fname)
#         outfile = core.Data(file=outfilename)
#     except (GPGMEError, ValueError) as E:
#         print("Error: Opening file %s or %s - %s" %
#               (fname, outfilename, E))
#     else:
#         # obtain signature and write unsigned file
#         ctx.op_verify(infile, None, outfile)
#         vres = ctx.op_verify_result()
# 
#         for signature in vres.signatures:
#             status = check_signature(ctx, signature)
#             overall_status.add(status)
# 
#         if overall_status.to_exitcode():
#             return None
# 
#         return outfilename
# 
#     return None


from elbepack.egpg import unsign_file
# ELBE - Debian Based Embedded Rootfilesystem Builder
# Copyright (c) 2014 Stefan Gast <stefan.gast@linutronix.de>
# Copyright (c) 2014, 2017 Manuel Traut <manut@linutronix.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later



def run_command(argv):
    if len(argv) != 1:
        print("Wrong number of arguments.")
        print("Please pass the name of the file to unsign.")
        return


# Path: elbepack/egpg.py
# def unsign_file(fname):
#     # check for .gpg extension and create an output filename without it
#     if len(fname) <= 4 or fname[len(fname) - 4:] != '.gpg':
#         print("The input file needs a .gpg extension")
#         return None
# 
#     outfilename = fname[:len(fname) - 4]
# 
#     ctx = core.Context()
#     ctx.set_engine_info(PROTOCOL_OpenPGP,
#                         None,
#                         '/var/cache/elbe/gnupg')
#     ctx.set_armor(False)
# 
#     overall_status = OverallStatus()
# 
#     try:
#         infile  = core.Data(file=fname)
#         outfile = core.Data(file=outfilename)
#     except (GPGMEError, ValueError) as E:
#         print("Error: Opening file %s or %s - %s" %
#               (fname, outfilename, E))
#     else:
#         # obtain signature and write unsigned file
#         ctx.op_verify(infile, None, outfile)
#         vres = ctx.op_verify_result()
# 
#         for signature in vres.signatures:
#             status = check_signature(ctx, signature)
#             overall_status.add(status)
# 
#         if overall_status.to_exitcode():
#             return None
# 
#         return outfilename
# 
#     return None


# Path: elbepack/commands/remove_sign.py
from elbepack.egpg import unsign_file

# ELBE - Debian Based Embedded Rootfilesystem Builder
# Copyright (c) 2014 Stefan Gast <stefan.gast@linutronix.de>
# Copyright (c) 2014, 2017 Manuel Traut <manut@linutronix.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later



def run_command(argv):
    if len(argv) != 1:
        print("Wrong number of arguments.")
        print("Please pass the name of the file to unsign.")
        return


    fname = unsign_file(argv[0])