blob: 36fdf1bb7e7a9e7938dd17f0ca48e0135e0557a1 (
plain)
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
|
#!/bin/bash
PROJECT_HOME=$(dirname $(readlink -f $0))
cd $PROJECT_HOME || exit 1
WORK_DIR=$PROJECT_HOME/work
function on_exit()
{
echo "-- END $(date)"
}
function init()
{
trap on_exit EXIT
echo
echo "-- START $(date)"
echo "PROJECT_HOME = $PROJECT_HOME"
echo "Preparing work directories..."
mkdir -p $WORK_DIR || exit 1
mkdir -p $WORK_DIR/haproxy || exit 1
mkdir -p $WORK_DIR/haproxy-dconv || exit 1
UPDATED=0
PUSH=0
}
# Needed as "git -C" is only available since git 1.8.5
function git-C()
{
_gitpath=$1
shift
echo "git --git-dir=$_gitpath/.git --work-tree=$_gitpath $@" >&2
git --git-dir=$_gitpath/.git --work-tree=$_gitpath "$@"
}
function fetch_haproxy_dconv()
{
echo "Fetching latest haproxy-dconv public version..."
if [ ! -e $WORK_DIR/haproxy-dconv/master ];
then
git clone -v git://github.com/cbonte/haproxy-dconv.git $WORK_DIR/haproxy-dconv/master || exit 1
fi
GIT="git-C $WORK_DIR/haproxy-dconv/master"
OLD_MD5="$($GIT log -1 | md5sum) $($GIT describe --tags)"
$GIT checkout master && $GIT pull -v
version=$($GIT describe --tags)
version=${version%-g*}
NEW_MD5="$($GIT log -1 | md5sum) $($GIT describe --tags)"
if [ "$OLD_MD5" != "$NEW_MD5" ];
then
UPDATED=1
fi
echo "Fetching last haproxy-dconv public pages version..."
if [ ! -e $WORK_DIR/haproxy-dconv/gh-pages ];
then
cp -a $WORK_DIR/haproxy-dconv/master $WORK_DIR/haproxy-dconv/gh-pages || exit 1
fi
GIT="git-C $WORK_DIR/haproxy-dconv/gh-pages"
$GIT checkout gh-pages && $GIT pull -v
}
function fetch_haproxy()
{
url=$1
path=$2
echo "Fetching HAProxy 1.4 repository..."
if [ ! -e $path ];
then
git clone -v $url $path || exit 1
fi
GIT="git-C $path"
$GIT checkout master && $GIT pull -v
}
function _generate_file()
{
infile=$1
destfile=$2
git_version=$3
state=$4
$GIT checkout $git_version
if [ -e $gitpath/doc/$infile ];
then
git_version_simple=${git_version%-g*}
doc_version=$(tail -n1 $destfile 2>/dev/null | grep " git:" | sed 's/.* git:\([^ ]*\).*/\1/')
if [ $UPDATED -eq 1 -o "$git_version" != "$doc_version" ];
then
HTAG="VERSION-$(basename $gitpath | sed 's/[.]/\\&/g')"
if [ "$state" == "snapshot" ];
then
base=".."
HTAG="$HTAG-SNAPSHOT"
else
base="."
fi
$WORK_DIR/haproxy-dconv/master/haproxy-dconv.py -i $gitpath/doc/$infile -o $destfile --base=$base &&
echo "<!-- git:$git_version -->" >> $destfile &&
sed -i "s/\(<\!-- $HTAG -->\)\(.*\)\(<\!-- \/$HTAG -->\)/\1${git_version_simple}\3/" $docroot/index.html
else
echo "Already up to date."
fi
if [ "$doc_version" != "" -a "$git_version" != "$doc_version" ];
then
changelog=$($GIT log --oneline $doc_version..$git_version $gitpath/doc/$infile)
else
changelog=""
fi
GITDOC="git-C $docroot"
if [ "$($GITDOC status -s $destfile)" != "" ];
then
$GITDOC add $destfile &&
$GITDOC commit -m "Updating HAProxy $state $infile ${git_version_simple} generated by haproxy-dconv $version" -m "$changelog" $destfile $docroot/index.html &&
PUSH=1
fi
fi
}
function generate_docs()
{
url=$1
gitpath=$2
docroot=$3
infile=$4
outfile=$5
fetch_haproxy $url $gitpath
GIT="git-C $gitpath"
$GIT checkout master
git_version=$($GIT describe --tags --match 'v*')
git_version_stable=${git_version%-*-g*}
echo "Generating snapshot version $git_version..."
_generate_file $infile $docroot/snapshot/$outfile $git_version snapshot
echo "Generating stable version $git_version..."
_generate_file $infile $docroot/$outfile $git_version_stable stable
}
function push()
{
docroot=$1
GITDOC="git-C $docroot"
if [ $PUSH -eq 1 ];
then
$GITDOC push origin gh-pages
fi
}
init
fetch_haproxy_dconv
generate_docs http://git.1wt.eu/git/haproxy-1.4.git/ $WORK_DIR/haproxy/1.4 $WORK_DIR/haproxy-dconv/gh-pages configuration.txt configuration-1.4.html
generate_docs http://git.1wt.eu/git/haproxy-1.5.git/ $WORK_DIR/haproxy/1.5 $WORK_DIR/haproxy-dconv/gh-pages configuration.txt configuration-1.5.html
generate_docs http://git.1wt.eu/git/haproxy.git/ $WORK_DIR/haproxy/1.6 $WORK_DIR/haproxy-dconv/gh-pages configuration.txt configuration-1.6.html
generate_docs http://git.1wt.eu/git/haproxy.git/ $WORK_DIR/haproxy/1.6 $WORK_DIR/haproxy-dconv/gh-pages intro.txt intro-1.6.html
push $WORK_DIR/haproxy-dconv/gh-pages
|