Avoid catch-22 with README.main not being distributed but having the
[gnupg.git] / tools / gpg-zip.in
blobd27b1f962109c8a129be432b4153ae2a933963e7
1 #!/bin/sh
3 # gpg-archive - gpg-ized tar using the same format as PGP's PGP Zip.
4 # Copyright (C) 2005 Free Software Foundation, Inc.
6 # This file is part of GnuPG.
8 # GnuPG is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # GnuPG is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20 # Despite the name, PGP Zip format is actually an OpenPGP-wrapped tar
21 # file. To be compatible with PGP itself, this must be a USTAR format
22 # tar file. Unclear on whether there is a distinction here between
23 # the GNU or POSIX variant of USTAR.
25 VERSION=@VERSION@
26 TAR=@TAR@
27 GPG=gpg
29 usage="\
30 Usage: gpg-zip [--help] [--version] [--encrypt] [--decrypt] [--symmetric]
31 [--list-archive] [--output FILE] [--gpg GPG] [--gpg-args ARGS]
32 [--tar TAR] [--tar-args ARGS] filename1 [filename2, ...]
33 directory1 [directory2, ...]
35 Encrypt or sign files into an archive."
37 while test $# -gt 0 ; do
38 case $1 in
39 -h | --help | --h*)
40 echo "$usage"
41 exit 0
43 --list-archive)
44 list=yes
45 create=no
46 unpack=no
47 shift
49 --encrypt | -e)
50 gpg_args="$gpg_args --encrypt"
51 list=no
52 create=yes
53 unpack=no
54 shift
56 --decrypt | -d)
57 gpg_args="$gpg_args --decrypt"
58 list=no
59 create=no
60 unpack=yes
61 shift
63 --symmetric | -c)
64 gpg_args="$gpg_args --symmetric"
65 list=no
66 create=yes
67 unpack=no
68 shift
70 --sign | -s)
71 gpg_args="$gpg_args --sign"
72 list=no
73 create=yes
74 unpack=no
75 shift
77 --recipient | -r)
78 gpg_args="$gpg_args --recipient $2"
79 shift
80 shift
82 --local-user | -u)
83 gpg_args="$gpg_args --local-user $2"
84 shift
85 shift
87 --output | -o)
88 gpg_args="$gpg_args --output $2"
89 shift
90 shift
92 --version)
93 echo "gpg-zip (GnuPG) $VERSION"
94 exit 0
96 --gpg)
97 GPG=$1
98 shift
100 --gpg-args)
101 gpg_args="$gpg_args $2"
102 shift
103 shift
105 --tar)
106 TAR=$1
107 shift
109 --tar-args)
110 tar_args="$tar_args $2"
111 shift
112 shift
115 shift
116 break
119 echo "$usage" 1>&2
120 exit 1
123 break
125 esac
126 done
128 if test x$create = xyes ; then
129 # echo "$TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args" 1>&2
130 $TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args
131 elif test x$list = xyes ; then
132 # echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -tf -" 1>&2
133 cat "$1" | $GPG $gpg_args | $TAR $tar_args -tf -
134 elif test x$unpack = xyes ; then
135 # echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -xvf -" 1>&2
136 cat "$1" | $GPG $gpg_args | $TAR $tar_args -xvf -
137 else
138 echo "$usage" 1>&2
139 exit 1