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.
33 # ./maketarball v0.0.2
34 # ./maketarball -d master
35 # ./maketarball -r v0.0.2
38 USAGE
="Usage: $0 -h | [-dr] REVISH"
45 while getopts ":dhr" opt
;
51 echo "Creates a tarball of the repository at rev REVISH."
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"
59 NOWDATE
=`date "+%Y-%m-%d-"`
67 echo "Invalid option: -$OPTARG" >&2
73 if [[ -z "$1" ]]; then
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"
95 echo "+ cleaning up tmp/"
101 echo "+ Building tarball from: $REVISH"
102 echo "+ Using prefix: $PREFIX"
103 echo "+ Release?: $RELEASE"
109 echo "+ there's an existing tmp/. please remove it."
114 echo "+ generating archive...."
118 $REVISH > tmp
/$FNBASE.
tar
122 echo "+ git archive command failed. See above text for reason."
128 if [[ $RELEASE = "yes" ]]
136 echo "+ generating html docs"
140 echo "+ sphinx docs generation failed. See above text for reason."
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)"
150 echo "+ moving docs to the right place"
151 if [[ -e docs
/build
/html
/ ]]
153 mv docs
/build
/html
/ docs
/html
/
154 mv docs
/build
/texinfo
/ docs
/texinfo
/
158 # this is the old directory structure pre-0.0.4
159 mv docs
/_build
/html
/ docs
/html
/
164 # Remove .pyc files that may have been generated by sphinx
165 find mediagoblin
-name '*.pyc' -exec rm {} \
;
169 tar -cvf $FNBASE.
tar $FNBASE
174 echo "+ compressing...."
177 echo "+ archive at tmp/$FNBASE.tar.gz"