summaryrefslogtreecommitdiff
path: root/doxygen/builder/rtems-doxygen-unpack-branches
blob: 299e82f5a79d3875698006b028db33b45d1d2804 (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
#! /bin/sh
#
# RTEMS Documentation Project
#
# Copyright 2017 Chris Johns <chrisj@rtems.org>
# All rights reserved
#
# Public domain
#

#
# Exit on error.
#
set -e

#
# Executables
#
cp=/bin/cp
curl=/usr/local/bin/curl
diff=/usr/bin/diff
mkdir=/bin/mkdir
mv=/bin/mv
tar=/usr/bin/tar
touch=/usr/bin/touch
rm=/bin/rm

#
# Top directory
#
top=$PWD

#
# Directory of the latest build.
#
latest=latest

#
# Directory of the current website build.
#
current=current

#
# Directory of the current website build.
#
new=new

#
# New doxygen file.
#
latest_doxygen=rtems-doxygen-latest.tar.gz

#
# The build tags files.
#
latest_tags=${latest}/.tags
current_tags=${current}/.tags
new_tags=${new}/.tags

#
# Branches to install as current
#
branches="master 4.11"

#
# Logging.
#
log() {
 echo $* >> ${log_file}
}
log_file=${top}/unpack.log
for f in 4 3 2 1
do
 t=`expr $f + 1`
 ${rm} -f ${top}/unpack-${t}.log
 if [ -f ${top}/unpack-${f}.log ]; then
  ${mv} ${top}/unpack-${f}.log ${top}/unpack-${t}.log
 fi
done
if [ -f ${top}/unpack.log ]; then
 ${mv} ${top}/unpack.log ${top}/unpack-1.log
fi
${rm} -rf ${log_file}

# Unpack the latest build and check if the hashes match and if different update
# the current with the latest.

log "RTEMS Doxygen Unpack: " `date`

if [ ! -d ${current} ]; then
 log "error: no current website found"
 exit 1
fi

#
# Remove any new website if there is one hanging about.
#
log ${rm} -rf ${new}
${rm} -rf ${new}
log ${mkdir} ${new}
log ${cp} -r ${current} ${new}
${cp} -r ${current} ${new}

#
# Unpack the latest website.
#
log ${rm} -rf ${latest}
${rm} -rf ${latest}
log ${mkdir} ${latest}
${mkdir} ${latest}
cd latest
 log ${tar} Jxf ../${latest_doxygen}
 ${tar} Jxf ../${latest_doxygen}
 cd ..

#
# if no current tag file create an empty one.
#
if [ ! -f ${current_tags} ]; then
 log touch ${current_tags}
 ${touch} ${current_tags}
fi

if [ -f ${latest_tags} ]; then
 #
 # Check each branch to see if the tags match.
 #
 for b in ${branches}
 do
  latest_hash=$(cat ${latest_tags} | grep ${b} | sed -e 's/.* //')
  current_hash=$(cat ${current_tags} | grep ${b} | sed -e 's/.* //')
  log "Latest ${b} hash: ${latest_hash}"
  log "Current ${b} hash: ${current_hash}"
  if [ ! -z "${latest_hash}" \
	 -a "${latest_hash}" != "${current_hash}" ]; then
   src=${latest}/${b}
   hash=${latest_hash}
   if [ -d ${src} ]; then
    log "New: ${b} from ${src} (${hash})"
    log rm -rf ${new}/${b}
    rm -rf ${new}/${b}
    log cp -r ${src} ${new}/${b}
    ${cp} -r ${src} ${new}/${b}
    log "Update ${b} in tags"
    cat ${new_tags} | grep -v ${b} > ${new_tags}.tmp
    echo "${b} ${hash}" >> ${new_tags}.tmp
    rm -f ${new_tags}
    mv ${new_tags}.tmp ${new_tags}
   fi
  fi
 done
else
 log "No tags found in the latest doxygen"
fi

exit 0