summaryrefslogtreecommitdiff
path: root/docs/builder/rtems-docs-download
blob: 22a608f70cd01545f753946345bddec91f10cf2d (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
#! /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
diff=/usr/bin/diff
grep=/usr/bin/grep
mkdir=/bin/mkdir
rm=/bin/rm
sed=/usr/bin/sed

#
# We run where the script is located.
#
cd $(dirname $0)

#
# Top directory
#
top=$PWD

#
# The current directory.
#
wwwdocs=/data/www/docs.rtems.org/branches

#
# Handover path.
#
handover=/data/ftp/pub/rtems/people/chrisj/docs.rtems.org/docs

#
# Current tags.
#
current_tags=${wwwdocs}/.tags

#
# If no update directory create it.
#
if [ ! -d latest ]; then
 ${rm} -rf latest
 ${mkdir} latest
fi

cd latest
 update=no
 #
 # Download the latest tags and compare the branches in the package with the
 # current tags.
 #
 if [ -f ${handover}/rtems-docs-latest-tags ] && \
    [ -f ${handover}/rtems-docs-latest.tar.xz ]; then
  ${cp} ${handover}/rtems-docs-latest-tags rtems-docs-latest-tags
  if [ -f ${current_tags} ]; then
   exec 3<& 0
   exec 0< rtems-docs-latest-tags
   while read line
   do
    branch=$(echo ${line} | ${sed} -e 's/[[:space:]].*//g')
    latest_hash=$(echo ${line} | ${sed} -e 's/.*[[:space:]]//g')
    current_hash=$(cat ${current_tags} | ${grep} ${branch} | ${sed} -e 's/.*[[:space:]]//g')
    if [ "${latest_hash}" != "${current_hash}" ]; then
     update=yes
    fi
   done
  else
   update=yes
  fi
  if [ ${update} = yes ]; then
   ${rm} -rf current
   ${cp} -r /data/www/docs.rtems.org/branches current
   ${cp} ${handover}/rtems-docs-latest.tar.xz rtems-docs-latest.tar.xz
   set +e
    ../rtems-docs-unpack-branches
   set -e
  fi
  ${rm} -f rtems-docs-latest-tags
 fi
 cd ..

exit 0