#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

version=0.15.11

LIBDIR='/usr/lib/manjaro-tools'

[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh

import ${LIBDIR}/util.sh

load_vars "$HOME/.makepkg.conf"
load_vars /etc/makepkg.conf

if [ ! -e "$1" ]; then
    error "%s does not exist!" "$1"
    exit 1
fi

msg2 "Signing [%s] with key %s" "${1##*/}" "${GPGKEY}..."
[[ -e "$1".sig ]] && rm "$1".sig
gpg --detach-sign --use-agent -u "${GPGKEY}" "$1"
