diff options
author | Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | 2011-03-22 16:58:09 -0700 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | 2011-03-22 16:58:09 -0700 |
commit | 5580faccd62c6c4f873c4a6c95078147fe4c3bcb (patch) | |
tree | aa5f4176b25b294db5202208b3da3f2250d2486d | |
parent | c437574a113ad9972027d309b12c4a5ef8194354 (diff) |
add mk-archive to generate archives from git
-rwxr-xr-x | mk-archive | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/mk-archive b/mk-archive new file mode 100755 index 0000000..3f56db1 --- /dev/null +++ b/mk-archive @@ -0,0 +1,70 @@ +#! /bin/sh +# +# Copyright (C) 2009 Intel Corporation <linux-wimax@intel.com> +# Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version +# 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# +# See help for args +# +set -eua +shopt -s extglob + +function log +{ + echo $@ 1>&2 +} + +if [ $# != 1 ] +then + cat 1>&2 <<EOF +E: bad arguments +Usage: $(basename $0) REV + +This script generates a tar archive of the GIT tree with proper +versioning information. + +REV is a changeset id or (external) tag name for which the archive +should be generated. + +Has to be run from inside the tree. +EOF + exit 1 +fi + +tmpdir=`mktemp -d` +rev=$1 +name=${name:-wimax} +if ! desc=$(git describe --tags --always $rev) +then + echo "E: can't describe revision specification $1" + exit 1 +fi +if [ $rev = HEAD ] +then + rev=$desc +fi +# Remove leading v from vM.m.p +name_rev="$(echo "$rev" | sed '/^v[0-9]\+/s/^v//')" + +git archive --format=tar --prefix=$name-$name_rev/ $rev > $tmpdir/ar.tar +mkdir $tmpdir/tree +tar xf $tmpdir/ar.tar -C $tmpdir/tree +echo $rev > $tmpdir/tree/$name-$name_rev/.git_archive.txt +tar czf $name-$name_rev.tar.gz -C $tmpdir/tree . +tar cjf $name-$name_rev.tar.bz2 -C $tmpdir/tree . +rm -rf $tmpdir/ + |