-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakesite.sh
executable file
·88 lines (76 loc) · 1.82 KB
/
makesite.sh
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
#!/bin/sh
#
# Copyright (c) 2008 Timothy Bourke. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the "BSD License" which is
# distributed with the software in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the BSD
# License for more details.
#
XSLT=./xsltsrc
SRCARG=""
DSTARG=""
VALID="--novalid"
HTMLDTD="/usr/local/share/xml/xhtml/1.1"
case `uname -s` in
Darwin*)
STAT="stat -f %m"
;;
Linux*)
STAT="stat -c %Y"
;;
esac
while [ $# -gt 0 ]
do
case "$1" in
-h)
echo "usage: `basename $0` [--validate] <srcdir> <dstdir>" 2>&1
;;
--validate)
VALID=""
;;
-*) echo "`basename $0`: invalid option \"$1\"."
;;
*) if [ -z $SRCARG ]; then
SRCARG=$1
elif [ -z $DSTARG ]; then
DSTARG=$1
else
echo "ignored argument: $1" >&2
fi
;;
esac
shift
done
SRC=${SRCARG:-${PWD}/src} # must be full paths (e.g., realpath)
DST=${DSTARG:-${PWD}/dst}
dodir () {
for f in `find $1 -maxdepth 1 -type f 2> /dev/null`
do
echo "<file name=\"$(basename $f)\" lastmod=\"$($STAT $f)\"/>"
done
for dir in `find $1/* -type d -maxdepth 0 2> /dev/null`
do
echo "<dir name=\"$(basename $dir)\">"
dodir $dir
echo "</dir>"
done
}
if [ -d "$SRC" -a -d "$DST" ]; then
(echo "<hier>"
echo "<filehier name=\"src\" path=\"$SRC\">"
dodir $SRC
echo "</filehier>"
echo "<filehier name=\"dst\" path=\"$DST\">"
dodir $DST
echo "</filehier>"
echo "</hier>") \
| xsltproc $VALID --nodtdattr \
--path "$XSLT $HTMLDTD" $XSLT/makesite.xsl -
else
echo "`basename $0`: ensure that \"$SRC\" and \"$DST\" exist."
fi