-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.sh
executable file
·152 lines (127 loc) · 3.63 KB
/
index.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
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
#!/bin/sh
## Simplistic ReaPack index.xml generator
## v0.1.1 (2018-08-07)
##
## Copyright (C) 2016-2018 Przemyslaw Pawelczyk <[email protected]>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
cd "${0%/*}"
if [ -r .reapack-index.conf ]; then
while read -r LINE; do
LINE=$(echo "$LINE" | sed 's,^[ \t]*,,;s,[ \t]*$,,')
if [ "$LINE" != "${LINE#-n}" ] \
|| [ "$LINE" != "${LINE#--name}" ]
then
name=$(echo "$LINE" | sed 's,^[^ \t]*[ \t]*,,')
fi
if [ "$LINE" != "${LINE#-U}" ] \
|| [ "$LINE" != "${LINE#--url-template}" ]
then
url_template=$(echo "$LINE" | sed 's,^[^ \t]*[ \t]*,,')
fi
done <.reapack-index.conf
fi
if [ -r index.conf ]; then
. ./index.conf
fi
STATUS=$(git status --porcelain | sed -r '/index\.(conf|sh|xml)$/d')
if [ -n "$STATUS" ]; then
echo "$0: You have uncommited changes in working tree:" >&2
echo "$STATUS" | sed 's,^,'"$0"': ,' >&2
fi
INDENT=0
beg() { INDENT=$((INDENT+1)); }
end() { INDENT=$((INDENT-1)); }
iprint() { FMT=$1; shift; printf "%*s$FMT\n" $((INDENT*2)) "" "$@"; }
catdirs(){ find . -mindepth 1 -type d \( -name '.*' -prune -o -print \) \
| LC_ALL=C sort; }
files() { find -maxdepth 1 -type f | LC_ALL=C sort; }
(
echo '<?xml version="1.0" encoding="utf-8"?>'
COCKOSFORUM="http://forum.cockos.com/"
REAPACK_IVER=1
HEADCOMMIT=$(git rev-parse HEAD)
iprint '<index version="%s" name="%s" commit="%s">' \
"$REAPACK_IVER" "$name" "$HEADCOMMIT"
beg
iprint '<metadata>'
beg
if [ -n "$REPO_COCKOSFORUM_TID" ]; then
iprint '<link rel="%s" href="%s">%s</link>' \
website \
"${COCKOSFORUM}showthread.php?t=$REPO_COCKOSFORUM_TID" \
"Cockos Forum thread"
fi
if [ -n "$REPO_AUTH_COCKOSFORUM_UID" ]; then
iprint '<link rel="%s" href="%s">%s</link>' \
website \
"${COCKOSFORUM}member.php?u=$REPO_AUTH_COCKOSFORUM_UID" \
"Cockos Forum user"
fi
if [ -n "$REPO_URL" ]; then
iprint '<link rel="%s" href="%s">%s</link>' \
website "$REPO_URL" Repository
fi
end
iprint '</metadata>'
catdirs | while read -r DIR; do
DIR=${DIR#./}
iprint '<category name="%s">' "$DIR"
beg
( cd "$DIR"; files | while read -r FILE; do
FILEDESC=$(
sed '/^[ \t]*descfmt = "/!d;s,,,;s,".*,,;s, ([^)]*),,g;q' "$FILE" \
)
if [ -z "$FILEDESC" ]; then
FILEDESC=$(
sed -r '/^.*(ReaScript|JSFX) Name: [ \t]*/!d;s,,,;q' "$FILE" \
)
fi
FILEVERS=$(sed -r '/^.*[Vv]er(sion)?:?[ \t]*v?/!d;s,,,;s,[ \t].*,,;q' "$FILE")
FILEVERS=${FILEVERS:-1.0}
FILEAUTH=$(sed -r '/^.*[Aa]uthor:?[ \t]*/!d;s,,,;q' "$FILE")
FILEAUTH=${FILEAUTH:-$REPO_AUTH}
FILETIME=$(git log -1 --date=iso-strict --pretty=tformat:%ad "$FILE")
FILECOMM=$(git log -1 --pretty=tformat:%H "$FILE")
FILE=${FILE#./}
FILETYPE=
case "$FILE" in
*.eel) FILETYPE=script ;;
*.jsfx) FILETYPE=effect ;;
*.lua) FILETYPE=script ;;
*.py) FILETYPE=script ;;
*.theme) FILETYPE=theme ;;
*) continue ;;
esac
# ReaPack-index half-compatibility
commit=$FILECOMM
path="$DIR/$FILE"
version=$FILEVERS
eval FILEURL="\"$url_template\""
#
FILEURL=$(echo "$FILEURL" | sed 's, ,%20,g')
if [ -z "$FILEDESC" ]; then
FILEDESC=$(
echo "$FILE" | sed -r 's,^([^ ]* - |[^_]*_),,;s,\.[^.]*$,,' \
)
fi
iprint '<reapack name="%s" desc="%s" type="%s">' \
"$FILE" "$FILEDESC" "$FILETYPE"
beg
iprint '<version name="%s" author="%s" time="%s">' \
"$FILEVERS" "$FILEAUTH" "$FILETIME"
beg
iprint '<source main="true">%s</source>' \
"$FILEURL"
end
iprint '</version>'
end
iprint '</reapack>'
done )
end
iprint '</category>'
done
end
iprint '</index>'
) >index.xml