# [PATCH] extend cg-export to support release tarball creation

1 messages from 2005-05-03 to 2005-05-03. Participants: Mark Allen.
Thread: https://gitlist.dev/t/468

## Mark Allen, 2005-05-03 22:57

Subject: [PATCH] extend cg-export to support release tarball creation
Message-ID: <20050503225712.74818.qmail@web41211.mail.yahoo.com>
URL: https://gitlist.dev/e/20050503225712.74818.qmail%40web41211.mail.yahoo.com

```
Here's a patch for cg-export which supports a "-r RELEASE" option. It will export the
specific ID or HEAD and then create a tar gz and a tar bz2 in your previous working
directory using RELEASE as the tarball name and the directory inside the tarball.

Within cogito itself,

cg-export -r $(cat VERSION) /tmp/foo

seems to work quite nicely to make release tarballs.

Unlike my previous attempt, this one does not make evil tarballs. :-)  One could insert a
script to update the .spec file before the tarfiles get created if desired.

Cheers,

--Mark

Signed-off-by: Mark Allen <mrallen1@yahoo.com>

Index: cg-export
===================================================================
--- aa6233be6d1b8bf42797c409a7c23b50593afc99/cg-export  (mode:100755
sha1:a4497314ab33f6a6387bc278e84f88d4442070ce)
+++ uncommitted/cg-export  (mode:100755 sha1:b0dfdf6049e7a074ef8c8c3f6a43e04a30e5cb89)
@@ -8,10 +8,17 @@

 . cg-Xlib

-destdir=$1
-id=$(tree-id $2)

-([ "$destdir" ] && [ "$id" ]) || die "usage: cg-export DESTDIR [TREE_ID]"
+if [ "$1" = "-r" ]; then
+       release=$2
+       destdir="$3/$2"
+       id=$(tree-id $4)
+else
+       destdir=$1
+       id=$(tree-id $2)
+fi
+
+([ "$destdir" ] && [ "$id" ]) || die "usage: cg-export [-r RELEASE] DESTDIR [TREE_ID]"

 [ -e "$destdir" ] && die "$destdir already exists."

@@ -20,3 +27,14 @@
 git-read-tree $id
 git-checkout-cache "--prefix=$destdir/" -a
 rm $GIT_INDEX_FILE
+
+if [ "$1" = "-r" ]; then
+       origdir=$PWD
+       cd $destdir
+       cd ..
+       tar czf $origdir/$release.tar.gz $release
+       tar cjf $origdir/$release.tar.bz2 $release
+       cd $origdir
+else
+       exit 0
+fi



```
