#!/bin/sh
set -e

GPG_HOME=/etc/debdelta/gnupg

check1it () {
 (
  cd ${GPG_HOME}
  test -f sha1_hashes.txt && sha1sum -c --quiet sha1_hashes.txt
 )
}

if [ "$1" = purge ] ; then
  if  [ -r /var/lib/debdelta ] ; then
    rm -r /var/lib/debdelta
  fi

  if check1it ; then
    (
      cd ${GPG_HOME}
      rm -f pubring.gpg  secring.gpg  trustdb.gpg
      if test -f pubring.gpg~ ; then
          rm -f pubring.gpg~
      fi
      rm -f sha1_hashes.txt
    )
    rmdir ${GPG_HOME} || true
  fi

fi
