2 #-------------------------------------------------------------------------------
4 # | ____| _| |_ / __ \ /\ | \/ |
5 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
6 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
7 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
8 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
10 # FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2010 Michael Wild <themiwi@users.sf.net>
13 # Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
16 # This file is part of FreeFOAM.
18 # FreeFOAM is free software; you can redistribute it and/or modify it
19 # under the terms of the GNU General Public License as published by the
20 # Free Software Foundation; either version 2 of the License, or (at your
21 # option) any later version.
23 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 # You should have received a copy of the GNU General Public License
29 # along with FreeFOAM; if not, write to the Free Software Foundation,
30 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 # foamPackSource [-h|--help]
34 # [-c|--create-tag [-t|--tag-key <keyId>] [-m|--tag-msg <msg>]]
35 # [-s|--sign-key <keyId>] <version> <outputDir>
38 # Creates a source tar-ball for a given <version> in <outputDir>.
40 # The <version> argument requires that a git tree-ish object with the name
41 # v<version> exists (i.e. a tag named e.g. v0.1.0). If no such tag exists,
42 # you can specify -c and the current HEAD will be tagged as v<version>. The
43 # output is named <outputDir>/freefoam-<version>.tar.bz2 and a detached
44 # signature is created using the users default GPG-key in
45 # <outputDir>/freefoam-<version>.tar.bz2.sig (can be overriden using -s).
46 # Further the md5 and sha1 digests are computed and placed in
47 # <outputDir>/freefoam-<version>.tar.bz2.md5 and
48 # <outputDir>/freefoam-<version>.tar.bz2.sha1, respectively.
51 # --help Print a help message
53 # --create-tag Create a tag named v<version>. By default it is signed
54 # by the default e-mail address's GPG-key.
56 # --tag-key <keyId> If -c is used, specify a different GPG-key ID to sign.
58 # --tag-msg <msg> Instead of prompting, use the given tag-message when
61 # --sign-key <keyId> Sign the created tar-ball using the GPG-key <keyId>
62 # instead of using the default key.
64 # --upload Upload to sourceforge.net.
65 # <version> Specify the version for which to create the source
66 # tar-ball. This expects a git object with the name
67 # v<version> to exist, which should be a tag.
68 # <outputDir> The directory in which to place the tar-ball.
70 #------------------------------------------------------------------------------
75 foamPackSource [options] <version> <outputDir>
77 Creates a source tar-ball for a given <version> in <outputDir>.
79 The <version> argument requires that a git tree-ish object with the name
80 v<version> exists (i.e. a tag named e.g. v0.1.0). If no such tag exists, you
81 can specify -c and the current HEAD will be tagged as v<version>. The output
82 is named <outputDir>/freefoam-<version>.tar.bz2 and a detached signature is
83 created using the users default GPG-key in
84 <outputDir>/freefoam-<version>.tar.bz2.sig (can be overriden using -s).
85 Further the md5 and sha1 digests are computed and placed in
86 <outputDir>/freefoam-<version>.tar.bz2.md5 and
87 <outputDir>/freefoam-<version>.tar.bz2.sha1, respectively.
89 c,create-tag Create a tag named v<version> and sign it with the default GPG-key.
90 t,tag-key= If -c is used, specify a different GPG-key ID to sign.
91 m,tag-msg= Use the given tag-message if -c is specified instead of prompting.
92 s,sign-key= Sign the tar-ball with the specified, non-default GPG-key.
93 u,upload Upload the created tar-ball to sourceforge.net."
95 .
"$(git --exec-path)/git-sh-setup"
100 die
"Require version number and output directory arguments."
111 while [ $# -gt 0 ]; do
126 SIGN_KEY
="--default-key $2"
142 if [ -z "$VERSION" -o -z "$OUTPUT_DIR" ]; then
143 die
"Version and output directory arguments are required"
146 if ! [ -d "$OUTPUT_DIR" -a -w "$OUTPUT_DIR" ]; then
147 die
"The output directory '$OUTPUT_DIR' does not exist or is not writeable"
150 for ext
in "" .sig .md5 .sha1
; do
151 if [ -e "$OUTPUT_DIR/freefoam-$VERSION.tar.bz2$ext" ]; then
152 die
"The output file $OUTPUT_DIR/freefoam-$VERSION.tar.bz2$ext already exists" >&2
156 # create the tag if requested
157 if [ "$CREATE_TAG" = "yes" ]; then
158 if git rev-list
--max-count=1 --quiet --tags "v$VERSION" > /dev
/null
2>&1; then
159 die
"Cannot create tag v$VERSION, it already exists"
162 if [ -n "$CUSTOM_TAG_KEY" ]; then
163 GIT_TAG_OPTS
="$GIT_TAG_OPTS -u $CUSTOM_TAG_KEY"
165 GIT_TAG_OPTS
="$GIT_TAG_OPTS -s"
167 if [ -n "$TAG_MSG" ]; then
168 GIT_TAG_OPTS
="$GIT_TAG_OPTS -m '$TAG_MSG'"
170 echo "Creating tag 'v$VERSION'"
171 eval "git tag $GIT_TAG_OPTS v$VERSION"
174 # create the tar-ball
175 echo "Creating the tar ball"
176 TMP
=`mktemp -d -t freefoam-XXXX` || die
"Failed to create temporary directory"
177 git archive
--format=tar --prefix=freefoam-
$VERSION/ v
$VERSION > \
178 $TMP/freefoam-
$VERSION.
tar || die
"Failed to create tar file"
180 # create HTML docs and add to tar-ball
181 echo "Creating HTML docs and adding them to the tar-ball"
182 mkdir
$TMP/freefoam-
$VERSION
183 for f
in ChangeLog INSTALL README ReleaseNotes HACKING
; do
184 git show v
$VERSION -- $f | \
185 asciidoc
-a toc
-f data
/asciidoc
/html.conf
- > \
186 $TMP/freefoam-
$VERSION/$f.html
188 tar -C $TMP -rf $TMP/freefoam-
$VERSION.
tar freefoam-
$VERSION
190 echo "Compressing the tar ball"
191 bzip2 --best $TMP/freefoam-
$VERSION.
tar || die
"Failed to compress the tar ball"
192 mv $TMP/freefoam-
$VERSION.
tar.bz2
$OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2 || \
193 die
"Failed to place the compressed tar ball in '$OUTPUT_DIR'"
194 rm -rf $TMP || die
"Failed to remove the temporary directory '$TMP'"
197 echo "Signing the tar ball"
198 gpg
--armor -o $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2.sig
$SIGN_KEY \
199 --sign --detach-sign $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2 || \
200 die
"Failed to sign the tar ball"
202 # create md5 and sha1 sums
203 echo "Computing checksums of the tar ball"
204 (cd $OUTPUT_DIR; openssl md5
-out freefoam-
$VERSION.
tar.bz2.md5 freefoam-
$VERSION.
tar.bz2
)
205 (cd $OUTPUT_DIR; openssl sha1
-out freefoam-
$VERSION.
tar.bz2.sha1 freefoam-
$VERSION.
tar.bz2
)
207 # create a MarkDown version of the ReleaseNotes
208 asciidoc
-b docbook
-f data
/asciidoc
/chunked.conf
-o - ReleaseNotes | \
209 xsltproc data
/utilities
/db2md.xsl
- > $OUTPUT_DIR/README.md
212 if [ "$DO_UPLOAD" = "yes" ]; then
213 echo "Uploading files to sourceforge.net"
214 rsync
-avP $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2 \
215 $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2.sig \
216 $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2.md5 \
217 $OUTPUT_DIR/freefoam-
$VERSION.
tar.bz2.sha1 \
218 $OUTPUT_DIR/README.md \
219 web.sourceforge.net
:uploads
/ || \
220 die
"Failed to upload the files to sourceforge.net"
221 echo "Finished upload. Remember to create a release on SF.net."
222 echo "You can do so on https://sourceforge.net/project/admin/editpackages.php?group_id=215833"
227 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file