Fix typo in license headers
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / pax / bax.sh
1 : $XConsortium: bax.sh /main/2 1996/05/10 16:42:46 drk $
2 : tw + pax for backup
3 #
4 # @(#)bax (AT&T Bell Laboratories) 05/09/95
5 #
6 # ../lib/bax/init on $PATH to customize
7 #
8
9 command=bax
10 customize=../lib/${command}/init
11
12 #
13 # no stinking environment
14 #
15
16 root= arch_name= arch_keep= big_size= big_magic_keep=
17 name_skip= path_skip= reg_magic_skip= src_name= src_magic_skip=
18
19 ifs=$IFS
20 IFS=:
21 path=$PATH
22 IFS=$ifs
23 for dir in $path
24 do      if      test -f $dir/$customize
25         then    . $dir/$customize
26                 break
27         fi
28 done
29
30 #
31 # default dirs
32 #
33
34 root=${root:-'/'}
35
36 #
37 # keep these architecture specific files: */${arch_name}/*/${arch_keep}
38 #
39
40 arch_name=${arch_name:-'arch'}
41 arch_keep=${arch_keep:-'bin|fun|lib'}
42
43 #
44 # files bigger than ${big_size} must have magic that matches ${big_magic_keep}
45 #
46
47 big_size=${big_size:-5000000}
48 big_magic_keep=${big_magic_keep:-'mail'}
49
50 #
51 # ${name_skip} are base names to be skipped
52 # ${path_skip} are path prefixes to be skipped
53 #
54
55 name_skip=${name_skip:-'?(*.)(old|save|tmp)?(.*)|.*-cache'}
56 path_skip=${path_skip:-'/dev|/usr/local/ast/ship'}
57
58 #
59 # regular files with magic that matches ${reg_magic_skip} are skipped
60 #
61
62 reg_magic_skip=${reg_magic_skip:-'core|cql * index|history|TeX dvi'}
63
64 #
65 # files under */${src_name}/* are skipped if magic matches ${src_magic_skip}
66 #
67
68 src_name=${src_name:-'src'}
69 src_magic_skip=${src_magic_skip:-'executable|object|(archive|shared) library'}
70
71 case $# in
72 [01])   echo "Usage: $command delta base [dir ...]" >&2
73         exit 2
74         ;;
75 esac
76 delta=$1
77 shift
78 base=$2
79 shift
80 case $# in
81 0)      set $root ;;
82 esac
83 dirs=
84 while   :
85 do      case $# in
86         0)      break ;;
87         esac
88         dirs="$dirs -d $1"
89         shift
90 done
91
92 tw $dirs -mH -e "
93
94 begin:  int     arch_bit = 1;
95         int     src_bit = 2;
96         char*   m;
97
98 sort:   name;
99
100 select: if (name == '${name_skip}')
101                 status = SKIP;
102         else if (type == REG)
103         {
104                 m = magic;
105                 if (size > ${big_size} && m != '*@(${big_magic_keep})*' ||
106                     m == '*@(${reg_magic_skip})*' ||
107                     (parent.local & src_bit) && m == '*@(${src_magic_skip})*')
108                         status = SKIP;
109         }
110         else if (type == DIR)
111         {
112                 local = (parent.local & src_bit);
113                 if (dev != parent.dev || path == '${path_skip}' || (parent.parent.local & arch_bit) && name != '${arch_keep}')
114                         status = SKIP;
115                 else if (name == '${arch_name}')
116                         local |= arch_bit;
117                 else if (name == '${src_name}')
118                         local |= src_bit;
119         }
120         return 1;
121 " | pax -o "write ordered physical verbose file=$delta base=$base"