forked from cvpcs/android_external_lsof
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Inventory
executable file
·204 lines (177 loc) · 4.03 KB
/
Inventory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/sh
#
# Inventory -- take an inventory of the lsof distribution's 00MANIFEST
# Establish trap and stty handling.
ISIG=":"
trap '$ISIG; exit 1' 1 2 3 15
stty -a 2>&1 | grep isig > /dev/null
if test $? -eq 0
then
stty -a 2>&1 | egrep -e -isig > /dev/null
if test $? -eq 0
then
ISIG="stty -isig"
stty isig
fi
fi
# Establish echo type -- Berkeley or SYSV.
j=`echo -n ""`
if test "X$j" = "X-n "
then
EC="\c"
EO=""
else
EC=""
EO="-n"
fi
# Display the introduction and basic explanation.
cat << .CAT_MARK
This configuration step (the Inventory script) takes inventory of
the lsof distribution. The script runs for a minute or two while
it checks that all the subdirectories, information files, scripts,
header files and source files that should be present really are.
It's not absolutely necessary that you take inventory, but it's a
good idea to do it right after the lsof distribution has been
unpacked. Once the inventory has been taken, this script creates
the file ./.ck00MAN as a signal that the inventory step has been
done.
You can call the Inventory script directly at any time to take
inventory. You can inhibit the inventory step permanently by
creating the file ./.neverInv, and you can tell the Configure script
to skip the inventory and customization steps with the -n option.
.CAT_MARK
END=0
while test $END = 0
do
echo ""
echo $EO "Do you want to take inventory (y|n) [y]? $EC"
read ANS EXCESS
if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
then
exit 0
fi
if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
then
END=1
else
echo ""
echo "Please answer y or n."
fi
done
# The current directory is assumed to be the lsof distribution home.
D=`pwd`
# If .ck00MAN exists, the manifest has already been checked.
# See if the caller wants to check it again.
CK=$D/.ck00MAN
if test -r $CK
then
cat << .CAT_MARK
======================================================================
The lsof distribution inventory in 00MANIFEST has already been checked.
.CAT_MARK
END=0
while test $END = 0
do
echo ""
echo $EO "Do you want to check the inventory again (y|n) [n]? $EC"
read ANS EXCESS
if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
then
exit 0
else
if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
then
END=1
else
echo ""
echo "Please answer y or n."
fi
fi
done
fi
echo ""
# See if manifest exists. Exit if it does not.
if test ! -r 00MANIFEST
then
echo "FATAL: 00MANIFEST file not found or not readable; Inventory exits."
echo ""
exit 1
fi
# Start the inventory.
S=""
echo "Conducting an inventory of the lsof distribution; this will take a while."
echo ""
echo $EO "Examining ${D}:$EC"
ERR=0
OK=1
for i in `cat 00MANIFEST | sed 's/\*$//'`
do
if test "X$i" != "X"
then
j=`expr $i : '\(.*\)/$'`
if test "X$j" != "X" -a "X$j" != "X0"
then
# Check a subdirectory reference.
if test ! -d ${D}/${S}/$j
then
if test $OK = 1
then
echo ""
fi
echo " Subdirectory ${S}/$j is missing. ++++"
ERR=1
OK=0
fi
else
s=`expr $i : '\(.*\):$'`
if test "X$s" != "X" -a "X$s" != "X0"
then
# Process a subdirectory change.
if test $OK -eq 1
then
echo " OK"
fi
OK=1
S=$s
echo $EO "Examining $S:$EC"
if test ! -d ${D}/$S
then
echo " ERROR"
echo " Subdirectory $S is missing. ++++"
ERR=1
OK=0
fi
else
# Process a file reference.
if test ! -r ${D}/${S}/$i
then
if test $OK -eq 1
then
echo " ERROR"
fi
echo " File ${S}/$i is missing. ++++"
ERR=1
OK=0
fi
fi
fi
fi
done
if test $OK -eq 1
then
echo " OK"
fi
echo ""
if test $ERR -ne 0
then
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ +"
echo "+ SOME FILES OR DIRECTORIES MAY BE MISSING! +"
echo "+ +"
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
else
echo "This lsof distribution seems to be complete."
fi
echo ""
echo "" >> $CK
exit $ERR