Proper handling of tags in skip_transcode
[larjonas-mediagoblin.git] / devtools / maketarball.sh
blobc6c2bc2beff75c369678748528affd995b18b1c2
1 #!/bin/bash
3 # GNU MediaGoblin -- federated, autonomous media hosting
4 # Copyright (C) 2011, 2012 GNU MediaGoblin Contributors. See AUTHORS.
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.
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.
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/>.
20 # usage: maketarball [-drh] REVISH
22 # Creates a tarball of the repository at rev REVISH.
24 # If -d is passed in, then it adds the date to the directory name.
26 # If -r is passed in, then it does some additional things required
27 # for a release-ready tarball.
29 # If -h is passed in, shows help and exits.
31 # Examples:
33 # ./maketarball v0.0.2
34 # ./maketarball -d master
35 # ./maketarball -r v0.0.2
38 USAGE="Usage: $0 -h | [-dr] REVISH"
40 REVISH="none"
41 PREFIX="none"
42 NOWDATE=""
43 RELEASE="no"
45 while getopts ":dhr" opt;
47 case "$opt" in
49 echo "$USAGE"
50 echo ""
51 echo "Creates a tarball of the repository at rev REVISH."
52 echo ""
53 echo " -h Shows this help message"
54 echo " -d Includes date in tar file name and directory"
55 echo " -r Performs other release-related actions"
56 exit 0
59 NOWDATE=`date "+%Y-%m-%d-"`
60 shift $((OPTIND-1))
63 RELEASE="yes"
64 shift $((OPTIND-1))
66 \?)
67 echo "Invalid option: -$OPTARG" >&2
68 echo "$USAGE" >&2
70 esac
71 done
73 if [[ -z "$1" ]]; then
74 echo "$USAGE";
75 exit 1;
78 REVISH=$1
79 PREFIX="$NOWDATE$REVISH"
81 # convert PREFIX to all lowercase and nix the v from tag names.
82 PREFIX=`echo "$PREFIX" | tr '[A-Z]' '[a-z]' | sed s/v//`
84 # build the filename base minus the .tar.gz stuff--this is also
85 # the directory in the tarball.
86 FNBASE="mediagoblin-$PREFIX"
88 STARTDIR=`pwd`
90 function cleanup {
91 pushd $STARTDIR
93 if [[ -e tmp ]]
94 then
95 echo "+ cleaning up tmp/"
96 rm -rf tmp
98 popd
101 echo "+ Building tarball from: $REVISH"
102 echo "+ Using prefix: $PREFIX"
103 echo "+ Release?: $RELEASE"
105 echo ""
107 if [[ -e tmp ]]
108 then
109 echo "+ there's an existing tmp/. please remove it."
110 exit 1
113 mkdir $STARTDIR/tmp
114 echo "+ generating archive...."
115 git archive \
116 --format=tar \
117 --prefix=$FNBASE/ \
118 $REVISH > tmp/$FNBASE.tar
120 if [[ $? -ne 0 ]]
121 then
122 echo "+ git archive command failed. See above text for reason."
123 cleanup
124 exit 1
128 if [[ $RELEASE = "yes" ]]
129 then
130 pushd tmp/
131 tar -xvf $FNBASE.tar
133 pushd $FNBASE
134 pushd docs
136 echo "+ generating html docs"
137 make html
138 if [[ $? -ne 0 ]]
139 then
140 echo "+ sphinx docs generation failed. See above text for reason."
141 cleanup
142 exit 1
145 # NOTE: this doesn't work for gmg prior to v0.0.4.
146 echo "+ generating texinfo docs (doesn't work prior to v0.0.4)"
147 make info
148 popd
150 echo "+ moving docs to the right place"
151 if [[ -e docs/build/html/ ]]
152 then
153 mv docs/build/html/ docs/html/
154 mv docs/build/texinfo/ docs/texinfo/
156 rm -rf docs/build/
157 else
158 # this is the old directory structure pre-0.0.4
159 mv docs/_build/html/ docs/html/
161 rm -rf docs/_build/
164 # Remove .pyc files that may have been generated by sphinx
165 find mediagoblin -name '*.pyc' -exec rm {} \;
167 popd
169 tar -cvf $FNBASE.tar $FNBASE
170 popd
174 echo "+ compressing...."
175 gzip tmp/$FNBASE.tar
177 echo "+ archive at tmp/$FNBASE.tar.gz"
179 echo "+ done."