Ticket #7: build_mediagoblin_docs.sh

File build_mediagoblin_docs.sh, 2.7 KB (added by Will Kahn-Greene, 13 years ago)

build_mediagoblin_docs.sh

Line 
1#!/bin/bash
2
3# GNU MediaGoblin -- federated, autonomous media hosting
4# Copyright (C) 2011 Free Software Foundation, Inc
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
20# Usage: build_docs.sh <path-to-git-repo> <target-dir> [<rev-ish>]
21
22# if we encounter errors, bail out
23set -o errexit
24
25# FIXME - need to convert these to absolute paths
26
27# check arguments
28#
29REPO=`pwd`/$1
30TARGET=`pwd`/$2
31REVISH=$3
32
33if [[ -z "$REPO" || -z "$TARGET" ]]
34then
35 echo "Usage: build_docs.sh <path-to-mediagoblin-repo> <target-dir> [<rev-ish>]"
36 exit 1;
37fi
38
39if [[ -z "$REVISH" ]]
40then
41 REVISH=master
42fi
43
44echo ">>> Testing commands...."
45
46# check commands
47#
48GIT_CMD=$(which git)
49if [[ -z $GIT_CMD ]]
50then
51 echo "Hrmm: I can't find the git command."
52 echo "Is git installed? Is git on your PATH?"
53 exit 1;
54fi
55
56SPHINX_CMD=$(which sphinx-build)
57if [[ -z $SPHINX_CMD ]]
58then
59 echo "Hrmm: I can't find the sphinx-build command."
60 echo "Is Sphinx installed? Is sphinx-build on your PATH?"
61 exit 1;
62fi
63
64echo "Woot: Commands tested. OK"
65
66echo ">>> Fiddling with the repository...."
67# create the directory and clone the repository if it doesn't exist
68#
69if [[ -d "$REPO" ]]
70then
71 echo "Woot: $REPO already created."
72else
73 echo ">>> Creating $REPO...."
74 mkdir -p $REPO
75 cd $REPO
76 "$GIT_CMD" clone git://gitorious.org/mediagoblin/mediagoblin.git mediagoblin
77 echo "Woot: $REPO created."
78 echo "Note: Use $REPO/mediagoblin for <path-to-mediagoblin-repo> next time."
79fi
80
81cd $REPO/mediagoblin
82
83# update the repository
84#
85echo ">>> Checking out $REVISH...."
86"$GIT_CMD" checkout "$REVISH"
87if [[ $? -ne 0 ]]
88then
89 echo "Hrmm: revish $REVISH does not exist."
90 exit 1;
91fi
92
93echo ">>> Pulling new changes...."
94echo "$GIT_CMD pull -t origin $REVISH"
95"$GIT_CMD" pull -t origin $REVISH
96
97if [[ $? -ne 0 ]]
98then
99 echo "Hrmm: Couldn't pull $REVISH."
100 exit 1;
101fi
102
103echo ">>> Building the docs...."
104cd docs/
105make clean
106make html
107
108if [[ -d "$TARGET" ]]
109then
110 echo "Woot: $TARGET exists."
111else
112 echo "Woot: Creating $TARGET...."
113 mkdir -p "$TARGET"
114fi
115
116echo ">>> Copying all the files over to $TARGET...."
117cp -r _build/html/* $TARGET
118
119echo "Woot: Done!"