[icinga-checkins] icinga.org: icinga-web/jmosshammer/default2: add make-tarball for make create-tarball(-nightly)

git at icinga.org git at icinga.org
Mon Jul 19 10:36:01 CEST 2010


Module: icinga-web
Branch: jmosshammer/default2
Commit: 199d2d6d455156debc9cab91cd5994fbe40b70bb
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=199d2d6d455156debc9cab91cd5994fbe40b70bb

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Jun 30 10:00:59 2010 +0200

add make-tarball for make create-tarball(-nightly)

it is now possible to create git archived tarballs
including submodules.

make create-tarball
- creates normal tgz+md5

make create-tarball-nightly
- creates tgz+md5 with $date-$shortcommithash

---

 Makefile.in  |    9 +++-
 make-tarball |  195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 203 insertions(+), 1 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6449a0b..7bea02b 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -34,6 +34,7 @@ none:
 	@printf "Other usefull targets:\n"
 	@printf "\t%-18s - %s\n" "testdeps" "test php dependencies"
 	@printf "\t%-18s - %s\n" "create-tarball" "creates a tarball for packaging"
+	@printf "\t%-18s - %s\n" "create-tarball-nightly" "creates a tarball from HEAD for nightly builds"
 	@printf "\t%-18s - %s\n" "devclean" "make source ready for commit or packaging"
 	@printf "\t%-18s - %s\n" "cacheclean" "purges the agavi xml cache"
 	
@@ -43,6 +44,7 @@ none:
 	@printf "\t%-18s - %s\n" "db-upgrade" "tries to upgrade from a available db revision"
 	@printf "\t%-18s - %s\n" "db-drop" "drop the entire db"
 	@printf "\t%-18s - %s\n" "db-purge-userprefs" "purge existing user preferences"
+	@printf "\t%-18s - %s\n" "db-doc2sql" "export doctrine db schema"
 
 	@printf "\nI18n targets:\n"
 	@printf "\t%-18s - %s\n" "loc-update-catalog" "Create a initial locale from source (default.po)"
@@ -77,7 +79,12 @@ devclean: remove-temp-files distclean cacheclean logclean make-create-files conf
 cleanall: distclean cacheclean configclean logclean 
 
 create-tarball:
-	tar -czf ../$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz ../$(TAR_DIR_NAME)
+	#tar -czf ../$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz ../$(TAR_DIR_NAME)
+	./make-tarball --prefix $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)/
+
+create-tarball-nightly:
+	#${MAKE} submodule-update
+	./make-tarball --prefix $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-`date +%Y%m%d`-`git rev-parse --short HEAD`/
 
 cacheclean:
 	rm -rf app/cache/config/*.php
diff --git a/make-tarball b/make-tarball
new file mode 100755
index 0000000..9775370
--- /dev/null
+++ b/make-tarball
@@ -0,0 +1,195 @@
+#!/bin/sh -
+#
+# File:        make-tarball 
+#
+# Description: A utility script that builds an archive file(s) of all
+#              git repositories and submodules in the current path.
+#              Useful for creating a single tarfile of a git super-
+#              project that contains other submodules.
+#              Derived from git-archive-all.sh, modified for Icinga
+
+# DEBUGGING
+set -e
+set -C # noclobber
+
+# TRAP SIGNALS
+trap 'cleanup' QUIT EXIT
+
+# For security reasons, explicitly set the internal field separator
+# to newline, space, tab
+OLD_IFS=$IFS
+IFS='
+ 	'
+
+cleanup () {
+    rm -f $TMPFILE
+    rm -f $TOARCHIVE
+    IFS="$OLD_IFS"
+}
+
+usage () {
+    echo "Usage is as follows:"
+    echo
+    echo "$PROGRAM <--version>"
+    echo "    Prints the program version number on a line by itself and exits."
+    echo
+    echo "$PROGRAM <--usage|--help|-?>"
+    echo "    Prints this usage output and exits."
+    echo
+    echo "$PROGRAM [--format <fmt>] [--prefix <path>] [--separate|-s] [output_file]"
+    echo "    Creates an archive for the entire git superproject, and its submodules"
+    echo "    using the passed parameters, described below."
+    echo
+    echo "    If '--format' is specified, the archive is created with the named"
+    echo "    git archiver backend. Obviously, this must be a backend that git-archive"
+    echo "    understands. The format defaults to 'tar' if not specified."
+    echo
+    echo "    If '--prefix' is specified, the archive's superproject and all submodules"
+    echo "    are created with the <path> prefix named. The default is to not use one."
+    echo
+    echo "    If '--separate' or '-s' is specified, individual archives will be created"
+    echo "    for each of the superproject itself and its submodules. The default is to"
+    echo "    concatenate individual archives into one larger archive."
+    echo
+    echo "    If 'output_file' is specified, the resulting archive is created as the"
+    echo "    file named. This parameter is essentially a path that must be writeable."
+    echo "    When combined with '--separate' ('-s') this path must refer to a directory."
+    echo "    Without this parameter or when combined with '--separate' the resulting"
+    echo "    archive(s) are named with a dot-separated path of the archived directory and"
+    echo "    a file extension equal to their format (e.g., 'superdir.submodule1dir.tar')."
+}
+
+version () {
+    echo "$PROGRAM version $VERSION"
+}
+
+# Internal variables and initializations.
+readonly PROGRAM=`basename "$0"`
+readonly VERSION=0.2
+
+OLD_PWD="`pwd`"
+TMPDIR=${TMPDIR:-/tmp}
+TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress
+TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"`
+OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default
+SEPARATE=0
+
+FORMAT=tar
+PREFIX=
+TREEISH=HEAD
+
+# RETURN VALUES/EXIT STATUS CODES
+readonly E_BAD_OPTION=254
+readonly E_UNKNOWN=255
+
+# Process command-line arguments.
+while test $# -gt 0; do
+    case $1 in
+        --format )
+            shift
+            FORMAT="$1"
+            shift
+            ;;
+
+        --prefix )
+            shift
+            PREFIX="$1"
+            shift
+            ;;
+
+        --separate | -s )
+            shift
+            SEPARATE=1
+            ;;
+
+        --version )
+            version
+            exit
+            ;;
+
+        -? | --usage | --help )
+            usage
+            exit
+            ;;
+
+        -* )
+            echo "Unrecognized option: $1" >&2
+            usage
+            exit $E_BAD_OPTION
+            ;;
+
+        * )
+            break
+            ;;
+    esac
+done
+
+if [ ! -z "$1" ]; then
+    OUT_FILE="$1"
+    shift
+fi
+
+# Validate parameters; error early, error often.
+if [ $SEPARATE -eq 1 -a ! -d $OUT_FILE ]; then
+    echo "When creating multiple archives, your destination must be a directory."
+    echo "If it's not, you risk being surprised when your files are overwritten."
+    exit
+elif [ `git config -l | grep -q '^core\.bare=false'; echo $?` -ne 0 ]; then
+    echo "$PROGRAM must be run from a git working copy (i.e., not a bare repository)."
+    exit
+fi
+
+# Create the superproject's git-archive
+git archive --format=$FORMAT --prefix="$PREFIX" $TREEISH > $TMPDIR/$(basename $(pwd)).$FORMAT
+echo $TMPDIR/$(basename $(pwd)).$FORMAT >| $TMPFILE # clobber on purpose
+superfile=`head -n 1 $TMPFILE`
+
+# find all '.git' dirs, these show us the remaining to-be-archived dirs
+find . -name '.git' -type d -print | sed -e 's/^\.\///' -e 's/\.git$//' | grep -v '^$' >> $TOARCHIVE
+
+while read path; do
+    TREEISH=$(git submodule | grep "^ .*${path%/}" | cut -d ' ' -f 2) # git-submodule does not list trailing slashes in $path
+    cd "$path"
+    git archive --format=$FORMAT --prefix="${PREFIX}$path" ${TREEISH:-HEAD} > "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT
+    if [ $FORMAT = 'zip' ]; then
+        # delete the empty directory entry; zipped submodules won't unzip if we don't do this
+        zip -d "$(tail -n 1 $TMPFILE)" "${PREFIX}${path%/}" >/dev/null # remove trailing '/'
+    fi
+    echo "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT >> $TMPFILE
+    cd "$OLD_PWD"
+done < $TOARCHIVE
+
+# Concatenate archives into a super-archive.
+if [ $SEPARATE -eq 0 ]; then
+    if [ $FORMAT = 'tar' ]; then
+        sed -e '1d' $TMPFILE | while read file; do
+            tar --concatenate -f "$superfile" "$file" && rm -f "$file"
+        done
+    elif [ $FORMAT = 'zip' ]; then
+        sed -e '1d' $TMPFILE | while read file; do
+            # zip incorrectly stores the full path, so cd and then grow
+            cd `dirname "$file"`
+            zip -g "$superfile" `basename "$file"` && rm -f "$file"
+        done
+        cd "$OLD_PWD"
+    fi
+
+    echo "$superfile" >| $TMPFILE # clobber on purpose
+fi
+
+while read file; do
+    mv "$file" "$OUT_FILE"
+done < $TMPFILE
+
+gzip $OUT_FILE/icinga-web.tar
+
+TAR_NAME=${PREFIX%/}
+mv $OUT_FILE/icinga-web.tar.gz ../$TAR_NAME.tar.gz
+
+echo "../$TAR_NAME.tar.gz created for uploading..."
+
+cd ..
+md5sum $TAR_NAME.tar.gz > $TAR_NAME.tar.gz.md5
+
+echo "../$TAR_NAME.tar.gz.md5 created for uploading..."
+





More information about the icinga-checkins mailing list