2 # Copyright 1994 David C. Niemi.
3 # Copyright 1997,2001,2002 Alain Knaff.
4 # This file is part of mtools.
6 # Mtools is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Mtools is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Mtools. If not, see <http://www.gnu.org/licenses/>.
19 # tgz [destination [source...] ]
21 # Make a gzip'd tar archive $1 (or stdout) out of specified files
22 # (or, if not specified, from everything in the current directory)
24 # Requires gzip in the user's path.
26 # Requires gnu tar (or something close) in the user's path
27 # due to use of --exclude, --totals and -S.
29 # 1994/02/19 DCN Created
30 # 1994/12/01 DCN Cleanup and major improvements
32 # Copyright (C) 1994 David C. Niemi (niemi@tuxers.net)
33 # The author requires that any copies or derived works include this
34 # copyright notice; no other restrictions are placed on its use.
41 { echo "Error: $0: ${@-}." >&2
48 tar cvf - . | gzip -9v
60 "" | . | .. | */ | */. | */.. )
61 echo "Usage: $0: [destination [source...] ]" >&2
64 *.t?z | *.?z | *.z | *.Z | *.tz | *.tz? )
67 dest=${dest}.tgz ## Add on .tgz as default suffix
70 if [ -h "$dest" ]; then
71 Error "Destination file \"$dest\" already exists as a symbolic link"
72 elif [ -f "$dest" ]; then
73 Error "Destination \"$dest\" already exists as a file"
74 elif [ -d "$dest" ]; then
75 Error "Destination \"$dest\" already exists as a directory"
77 if [ -z "$dest" -o "X$dest" = 'X-' ]; then
78 echo "Writing gzipp'd tar archive to standard output." >&2
79 tar cvfS - -- $src | gzip -9v
81 echo "Writing gzip'd tar archive to \"$dest\"." >&2
82 tar -cvS --totals --exclude "$dest" -f - -- $src | gzip -9v > "$dest"