Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/bax.sh
1808 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1987-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# #
19
########################################################################
20
: tw + pax for backup
21
#
22
# @(#)bax (AT&T Bell Laboratories) 05/09/95
23
#
24
# ../lib/bax/init on $PATH to customize
25
#
26
27
command=bax
28
customize=../lib/${command}/init
29
30
#
31
# no stinking environment
32
#
33
34
root= arch_name= arch_keep= big_size= big_magic_keep=
35
name_skip= path_skip= reg_magic_skip= src_name= src_magic_skip=
36
37
ifs=${IFS-'
38
'}
39
IFS=:
40
path=$PATH
41
IFS=$ifs
42
for dir in $path
43
do if test -f $dir/$customize
44
then . $dir/$customize
45
break
46
fi
47
done
48
49
#
50
# default dirs
51
#
52
53
root=${root:-'/'}
54
55
#
56
# keep these architecture specific files: */${arch_name}/*/${arch_keep}
57
#
58
59
arch_name=${arch_name:-'arch'}
60
arch_keep=${arch_keep:-'bin|fun|lib'}
61
62
#
63
# files bigger than ${big_size} must have magic that matches ${big_magic_keep}
64
#
65
66
big_size=${big_size:-5000000}
67
big_magic_keep=${big_magic_keep:-'mail'}
68
69
#
70
# ${name_skip} are base names to be skipped
71
# ${path_skip} are path prefixes to be skipped
72
#
73
74
name_skip=${name_skip:-'?(*.)(old|save|tmp)?(.*)|.*-cache'}
75
path_skip=${path_skip:-'/dev|/usr/local/ast/ship'}
76
77
#
78
# regular files with magic that matches ${reg_magic_skip} are skipped
79
#
80
81
reg_magic_skip=${reg_magic_skip:-'core|cql * index|history|TeX dvi'}
82
83
#
84
# files under */${src_name}/* are skipped if magic matches ${src_magic_skip}
85
#
86
87
src_name=${src_name:-'src'}
88
src_magic_skip=${src_magic_skip:-'executable|object|(archive|shared) library'}
89
90
case $# in
91
[01]) echo "Usage: $command delta base [dir ...]" >&2
92
exit 2
93
;;
94
esac
95
delta=$1
96
shift
97
base=$2
98
shift
99
case $# in
100
0) set $root ;;
101
esac
102
dirs=
103
while :
104
do case $# in
105
0) break ;;
106
esac
107
dirs="$dirs -d $1"
108
shift
109
done
110
111
tw $dirs -mH -e "
112
113
begin: int arch_bit = 1;
114
int src_bit = 2;
115
char* m;
116
117
sort: name;
118
119
select: if (name == '${name_skip}')
120
status = SKIP;
121
else if (type == REG)
122
{
123
m = magic;
124
if (size > ${big_size} && m != '*@(${big_magic_keep})*' ||
125
m == '*@(${reg_magic_skip})*' ||
126
(parent.local & src_bit) && m == '*@(${src_magic_skip})*')
127
status = SKIP;
128
}
129
else if (type == DIR)
130
{
131
local = (parent.local & src_bit);
132
if (dev != parent.dev || path == '${path_skip}' || (parent.parent.local & arch_bit) && name != '${arch_keep}')
133
status = SKIP;
134
else if (name == '${arch_name}')
135
local |= arch_bit;
136
else if (name == '${src_name}')
137
local |= src_bit;
138
}
139
return 1;
140
" | pax -o "write ordered physical verbose file=$delta base=$base"
141
142