#!/bin/sh

if [ "$TEXTDOMAIN" != "ja" ]; then
  TEXTDOMAINDIR=. TEXTDOMAIN=ja exec "$0" "$@"
fi

if [ `id -u` -ne 0 ]; then
  zenity --error --text=$"This command must be run as root"
  exit 1
fi

if [ $# -ne 1 ]; then
  zenity --error --text="usage: $0 file"
  exit 2
fi

OPTIONS="--non-interactive --hide-main-window"
SIGNEDFILE=$1

if [ ! -s "$SIGNEDFILE" ]; then
  zenity --error --text=$"File not found."
  exit 3
fi

gpg -q --homedir=/usr/lib/rpm/gnupg --verify $SIGNEDFILE >/dev/null 2>&1

if [ $? -ne 0 ]; then
  zenity --error --text=$"The input file is not signed by an available key."
  exit 4
fi

gpg -q --homedir=/usr/lib/rpm/gnupg -d $SIGNEDFILE 2>/dev/null | synaptic $OPTIONS --set-selections

