Line 0
Link Here
|
|
|
1 |
--- util/rarian-sk-update.in.orig 2008-09-01 14:40:21.000000000 -0400 |
2 |
+++ util/rarian-sk-update.in 2014-02-18 14:54:52.000000000 -0500 |
3 |
@@ -1,4 +1,4 @@ |
4 |
-#!@BASH@ |
5 |
+#!/bin/sh |
6 |
|
7 |
# This script is designed to replace scrollkeeper-update |
8 |
# It iterates through all the directories specified using -o <dir_list> |
9 |
@@ -25,7 +25,7 @@ |
10 |
datadir=@datadir@ |
11 |
output_dir=${datadir}/help |
12 |
package_version=@PACKAGE_VERSION@ |
13 |
-real_convert[0]=$convert_dir |
14 |
+real_convert=$convert_dir |
15 |
skip_omf_translate=@ENABLE_OMF_READ@ |
16 |
|
17 |
# Print the version info for this file |
18 |
@@ -97,7 +97,7 @@ |
19 |
for f in $1/*.omf; do |
20 |
bname=$(basename $f) |
21 |
bname=${bname%-*.omf} |
22 |
- if [[ $bname != $old_basename ]] |
23 |
+ if [ $bname != $old_basename ] |
24 |
then |
25 |
old_basename=$bname |
26 |
filename=$bname.document |
27 |
@@ -115,39 +115,22 @@ |
28 |
echo -e `stat -c %Y $1`':@:'$1':@:'$fname_list >> $tmpdir/rarian-updates |
29 |
} |
30 |
|
31 |
-# Split up the omf dirs specified on the command line |
32 |
-# I've never seen this used in practice, but |
33 |
-# better safe than sorry |
34 |
-split_omf_dirs () |
35 |
-{ |
36 |
- let counter=0 |
37 |
- while [ $convert_dir ] |
38 |
- do |
39 |
- entry=`echo $convert_dir | cut -d ':' -f 1` |
40 |
- convert_dir=${convert_dir#$entry} |
41 |
- convert_dir=${convert_dir#:} |
42 |
- real_convert[$counter]=$entry |
43 |
- let counter+=1 |
44 |
- done |
45 |
- |
46 |
-} |
47 |
- |
48 |
# Determine whether the directory defined within the index file |
49 |
# was specified in the convert_dirs |
50 |
am_adding_dir () |
51 |
{ |
52 |
- let counter=0 |
53 |
am_processing="0" |
54 |
- for i in ${real_convert[@]} |
55 |
+ tmplist= |
56 |
+ for i in ${real_convert} |
57 |
do |
58 |
- if [[ $fname == $i ]] |
59 |
+ if [ $fname == $i ] |
60 |
then |
61 |
- real_convert[$counter]="0" |
62 |
am_processing="1" |
63 |
- return |
64 |
- fi |
65 |
- let counter+=1 |
66 |
+ else |
67 |
+ tmplist="$tmplist $i" |
68 |
+ fi |
69 |
done |
70 |
+ real_convert=$tmplist |
71 |
} |
72 |
|
73 |
# The directory wasn't specified. This does nothing except cat the |
74 |
@@ -156,7 +139,7 @@ |
75 |
{ |
76 |
read line |
77 |
time=`echo $line | awk -F ":@:" '{print $1}'` |
78 |
- while [[ $time -ne 0 ]] |
79 |
+ while [ $time -ne 0 ] |
80 |
do |
81 |
echo $line |
82 |
echo $line >> $tmpdir/rarian-updates |
83 |
@@ -183,18 +166,18 @@ |
84 |
# If the given directory actually exists within the omf dir |
85 |
dirs_contains () |
86 |
{ |
87 |
- let counter=0 |
88 |
am_processing="0" |
89 |
- for i in ${entries[@]} |
90 |
+ tmplist= |
91 |
+ for i in ${entries} |
92 |
do |
93 |
- if [[ $1 == $i ]] |
94 |
+ if [ $1 == $i ] |
95 |
then |
96 |
- entries[$counter]="0" |
97 |
am_processing="1" |
98 |
- return |
99 |
+ else |
100 |
+ tmplist="$tmplist $i" |
101 |
fi |
102 |
- let counter+=1 |
103 |
done |
104 |
+ entries=$tmplist |
105 |
} |
106 |
|
107 |
# The meat. Goes through and checks each directory mtime against the |
108 |
@@ -202,27 +185,26 @@ |
109 |
# If the dir has been removed, delete. |
110 |
process_directory () |
111 |
{ |
112 |
- let counter=0 |
113 |
+ entries= |
114 |
for i in $(ls $fname) |
115 |
do |
116 |
- entries[$counter]="$fname/$i" |
117 |
- let counter+=1 |
118 |
+ entries="$entries $fname/$i" |
119 |
done |
120 |
|
121 |
read line |
122 |
|
123 |
old_time=`echo $line | awk -F ":@:" '{print $1}'` |
124 |
|
125 |
- while [[ $old_time && $old_time != "0" ]] |
126 |
+ while [ $old_time && $old_time != "0" ] |
127 |
do |
128 |
name=`echo $line | awk -F ":@:" '{print $2}'` |
129 |
|
130 |
dirs_contains $name |
131 |
|
132 |
- if [[ $am_processing != "0" ]] |
133 |
+ if [ $am_processing != "0" ] |
134 |
then |
135 |
new_time=`stat -c %Y $name` |
136 |
- if [[ $new_time -ne $old_time ]] |
137 |
+ if [ $new_time -ne $old_time ] |
138 |
then |
139 |
print_verbose "Directory $name has changed. Updating." |
140 |
process_dir $name |
141 |
@@ -231,7 +213,7 @@ |
142 |
fi |
143 |
else |
144 |
filenames=`echo $line | awk -F ":@:" '{print $3}'` |
145 |
- while [[ $filenames ]] |
146 |
+ while [ $filenames ] |
147 |
do |
148 |
entry=`echo $filenames | cut -d ';' -f 1` |
149 |
print_verbose "Directory resonsible for $entry has been removed. Deleting" |
150 |
@@ -246,13 +228,10 @@ |
151 |
old_time=`echo $line | awk -F ":@:" '{print $1}'` |
152 |
done |
153 |
|
154 |
- for i in ${entries[@]} |
155 |
+ for i in ${entries} |
156 |
do |
157 |
- if [[ $i != "0" ]] |
158 |
- then |
159 |
- print_verbose "Directory $i is new and will be added." |
160 |
- process_dir $i |
161 |
- fi |
162 |
+ print_verbose "Directory $i is new and will be added." |
163 |
+ process_dir $i |
164 |
done |
165 |
} |
166 |
|
167 |
@@ -326,7 +305,10 @@ |
168 |
if [ $skip_omf_translate = 0 ] |
169 |
then |
170 |
|
171 |
-split_omf_dirs |
172 |
+# Split up the omf dirs specified on the command line |
173 |
+# I've never seen this used in practice, but |
174 |
+# better safe than sorry |
175 |
+real_convert=$(echo $convert_dir | sed 's/:/ /g') |
176 |
|
177 |
if [ $update_output_dir ] && [ ! $overload_update ] |
178 |
then |
179 |
@@ -334,7 +316,7 @@ |
180 |
# omf files in <prefix>/share/omf |
181 |
# Also assumes only a single omf path |
182 |
print_verbose "Using non-installed location" |
183 |
- output_dir=`dirname $real_convert[0]`/help |
184 |
+ output_dir=$(dirname $(echo $real_convert | cut -d ' ' -f 1))/help |
185 |
fi |
186 |
|
187 |
print_verbose "Outputting to $output_dir" |
188 |
@@ -378,16 +360,16 @@ |
189 |
fname=`echo $line | awk -F ":@:" '{print $2}'` |
190 |
|
191 |
|
192 |
-while [[ $fname != "" ]] |
193 |
+while [ $fname != "" ] |
194 |
do |
195 |
print_verbose "Processing directory $fname" |
196 |
echo "0:@:$fname" >> $tmpdir/rarian-updates |
197 |
am_adding_dir $fname |
198 |
- if [[ ! $(ls $fname 2>&1) ]] |
199 |
+ if [ ! $(ls $fname 2>&1) ] |
200 |
then |
201 |
print_verbose "Previous directory $fname no longer exists" |
202 |
else |
203 |
- if [[ $am_processing != "0" ]] |
204 |
+ if [ $am_processing != "0" ] |
205 |
then |
206 |
process_directory |
207 |
else |
208 |
@@ -397,22 +379,18 @@ |
209 |
fi |
210 |
done |
211 |
|
212 |
-for i in ${real_convert[@]} |
213 |
+for i in ${real_convert} |
214 |
do |
215 |
- if [[ $i != "0" ]] |
216 |
- then |
217 |
res=$(ls $i 2>/dev/null) |
218 |
- if [[ ! $res ]] |
219 |
+ if [ ! $res ] |
220 |
then |
221 |
print_verbose "Path $i does not exist. Ignoring" |
222 |
else |
223 |
- |
224 |
print_verbose "Adding contents of directory $i" |
225 |
fname=$i |
226 |
echo "0:@:$fname" >> $tmpdir/rarian-updates |
227 |
add_all_files |
228 |
fi |
229 |
- fi |
230 |
done |
231 |
|
232 |
rm -f $statedir/rarian-update-mtimes |
233 |
@@ -422,4 +400,4 @@ |
234 |
fi |
235 |
rm -rf $tmpdir |
236 |
|
237 |
-fi # ENABLE_OMF_READ |
238 |
\ No newline at end of file |
239 |
+fi # ENABLE_OMF_READ |