]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | #! /bin/sh |
2 | # | |
3 | # Written by Martin Sperl | |
4 | # (sperl@dsn.ast.univie.ac.at) | |
5 | # | |
6 | ||
7 | ||
8 | if test $# -lt 3 ; then | |
9 | cat <<EOF | |
10 | Usage: `basename $0` <basedir> <SOURCE-FILES> <DESTINATION-FILS> | |
11 | copies all files from the source-tar-files to the common | |
12 | destination-tar-file with basedir as a common base directory. | |
13 | EOF | |
14 | exit 0 | |
15 | fi | |
16 | ||
17 | BaseDir="$1" | |
18 | shift | |
19 | ||
20 | Sourcefiles="$1" | |
21 | ||
22 | while test "$#" != 2 ; do | |
23 | shift | |
24 | Sourcefiles="$Sourcefiles $1" | |
25 | done | |
26 | ||
27 | shift | |
28 | Final=$1 | |
29 | ||
30 | Destination=/tmp/join$$.tar | |
31 | ||
32 | touch $Destination | |
33 | ||
34 | curdir=`pwd` | |
35 | ||
36 | mkdir tmp$$ | |
37 | mkdir tmp$$/$BaseDir | |
38 | ||
39 | #uncompress all files | |
40 | cd tmp$$/$BaseDir | |
41 | for each in $Sourcefiles ; do | |
42 | ( \ | |
43 | if test `basename $each gz` != `basename $each` ; then \ | |
44 | gzip -dc ../../$each;\ | |
45 | else \ | |
46 | cat ../../$each;\ | |
47 | fi; \ | |
48 | ) | tar xf - | |
49 | done | |
50 | cd .. | |
51 | #now tar everything | |
52 | tar -cf $Destination * | |
53 | ||
54 | cd .. | |
55 | ||
56 | rm -fr tmp$$ | |
57 | ||
58 | # goto old directory | |
59 | cd $curdir | |
60 | ||
61 | if test `basename $Final gz` != `basename $Final` ; then | |
62 | gzip -c $Destination > $Final | |
63 | else | |
64 | cat $Destination > $Final | |
65 | fi | |
66 | ||
67 | rm -f $Destination |