5 # We don't use a secret keyring, of course, but gpg panics and 
   6 # implodes if there isn't one available 
   8 GPG_CMD
="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg" 
   9 GPG
="$GPG_CMD --keyring /etc/apt/trusted.gpg" 
  13 #MASTER_KEYRING=/usr/share/keyrings/debian-master-keyring.gpg 
  14 ARCHIVE_KEYRING
=/usr
/share
/keyrings
/debian
-archive-keyring.gpg
 
  15 REMOVED_KEYS
=/usr
/share
/keyrings
/debian
-archive-removed-keys.gpg
 
  17 add_keys_with_verify_against_master_keyring
() { 
  18         # when adding new keys, make sure that the archive-master-keyring 
  20         #   all keys that are exported and have the name 
  21         #   "Ubuntu Archive Automatic Signing Key" must have a valid signature 
  22         #   from a key in the ubuntu-master-keyring 
  23         add_keys
=`$GPG_CMD --keyring $ARCHIVE_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5` 
  24         master_keys
=`$GPG_CMD --keyring $MASTER_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5` 
  25         for add_key 
in $add_keys; do 
  26             for master_key 
in $master_keys; do 
  27                 if $GPG --list-sigs --with-colons $add_key | grep ^sig 
| cut 
-d: -f5 | grep -q $master_key; then 
  28                     $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export $add_key | $GPG --import 
  35     if [ ! -f $ARCHIVE_KEYRING ]; then 
  36         echo >&2 "ERROR: Can't find the archive-keyring" 
  37         echo >&2 "Is the debian-archive-keyring package installed?" 
  41     # add new keys, if no MASTER_KEYRING is used, use the traditional 
  43     if [ -z "$MASTER_KEYRING" ]; then 
  44         $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import 
  46         add_keys_with_verify_against_master_keyring
 
  49     # remove no-longer supported/used keys 
  50     keys
=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5` 
  52         if $GPG --list-keys --with-colons | grep ^pub 
| cut 
-d: -f5 | grep -q $key; then 
  53             $GPG --quiet --batch --delete-key --yes ${key} 
  60     echo "Usage: apt-key [command] [arguments]" 
  62     echo "Manage apt's list of trusted keys" 
  64     echo "  apt-key add <file>          - add the key contained in <file> ('-' for stdin)" 
  65     echo "  apt-key del <keyid>         - remove the key <keyid>" 
  66     echo "  apt-key export <keyid>      - output the key <keyid>" 
  67     echo "  apt-key exportall           - output all trusted keys" 
  68     echo "  apt-key update              - update keys using the keyring package" 
  69     echo "  apt-key list                - list keys" 
  74 if [ -z "$command" ]; then 
  80 if [ "$command" != "help" ] && ! which gpg 
>/dev
/null 
2>&1; then 
  81     echo >&2 "Warning: gnupg does not seem to be installed." 
  82     echo >&2 "Warning: apt-key requires gnupg for most operations." 
  88         $GPG --quiet --batch --import "$1" 
  92         $GPG --quiet --batch --delete-key --yes "$1" 
  99         $GPG --batch --list-keys 
 102         $GPG --batch --fingerprint 
 105         $GPG --armor --export "$1" 
 108         $GPG --armor --export 
 111         echo "Executing: $GPG $*"