#!/bin/sh set -e TEMP_D="" cleanup() { [ -z "$TEMP_D" ] || rm -Rf "${TEMP_D}" } trap cleanup EXIT Usage() { cat <&2; exit 1; } long_opt="" while [ $# -ne 0 ]; do cur=$1; next=$2 case "$cur" in -o|--output) output=$next; shift;; --long) long_opt="--long";; --) shift; break;; esac shift; done rev=${1:-HEAD} version=$(git describe ${long_opt} $rev) archive_base="cloud-init-$version" if [ -z "$output" ]; then output="$archive_base.tar.gz" fi # when building an archiving from HEAD, ensure that there aren't any # uncomitted changes in the working directory (because these would not # end up in the archive). if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then echo "ERROR: There are uncommitted changes in your working directory." >&2 exit 1 else echo "WARNING: There are uncommitted changes in your working directory." >&2 echo " This changes will not be included in the archive." >&2 fi fi git archive --format=tar.gz --prefix="$archive_base/" "$rev" > "$output" echo "$output"