From: Rene Scharfe Date: Tue, 26 Apr 2005 22:24:14 GMT Subject: Re: [PATCH] cg-export to tarball Message-ID: <426EBF8E.5000906@lsrfire.ath.cx> In-Reply-To: <20050426202014.GJ13224@pasky.ji.cz> Petr Baudis schrieb: > Dear diary, on Tue, Apr 26, 2005 at 09:12:46AM CEST, I got a letter > where "Joshua T. Corbin" told me that... > >> The following patch to cg-export will simlpy create a tarball if >> the argument ends in .tar.gz, .tar.bz2, or .tar. >> >> Signed-off-by; Joshua T. Corbin > > > What about cooperating with Rene Scharfe and using his tar-tree? I > didn't actually try it yet (not even look at the code so far), it'd > be cool if someone would give it some review and testing. Yes, this looks like a job for tar-tree. You could do something like this: destbasename=${destdir##*/} case "$destdir" in *.tar) tar-tree $id "${destbasename%.tar}" > "$destdir" ;; *.tgz) tar-tree $id "${destbasename%.tgz}" | gzip -9 > "$destdir" ;; # *.tar.gz, *.tar.bz2, ... *) mkdir -p "$destdir" || die "cannot create $destdir" export GIT_INDEX_FILE="$destdir/.git-index" read-tree $id checkout-cache "--prefix=$destdir/" -a rm "$GIT_INDEX_FILE" ;; esac The second parameter to tar-tree is an optional prefix for all paths inside the archive (official kernel tarballs always have linux-2.x.xx as a prefix). It makes some sense to set this value to the archive filename, "cg-export linux-2.6.12-rc3.tar.bz2" would than work as expected. What do you think? If you like it I'll cook up a patch later unless you beat me to it. Thanks, Rene