#!/bin/sh

proto=$1
branch=$2

<<<<<<< HEAD
DIRNAME=xf86-video-nouveau-$( date +%Y%m%d )
||||||| merged common ancestors
DIRNAME=libdrm-$( date +%Y%m%d )
=======
if [ -z "$proto" ]; then
    echo "Usage: $0 <proto name> [<branch>]"
    exit 1
fi
>>>>>>> xorg-x11-proto-devel package update

dirname=$proto-$( date +%Y%m%d )

rm -rf $dirname
git clone git://git.freedesktop.org/git/xorg/proto/$proto $dirname
cd $dirname
if [ -z "$branch" ]; then
    git log | head -1
else
    git checkout $branch
fi
sha=`git rev-list --max-count=1 --abbrev-commit HEAD`
git repack -a -d
cd ..

<<<<<<< HEAD
git clone ${REF:+--reference $REF} \
	git://git.freedesktop.org/git/nouveau/xf86-video-nouveau $DIRNAME

GIT_DIR=$DIRNAME/.git git archive --format=tar --prefix=$DIRNAME/ ${1:-HEAD} \
	| xz > $DIRNAME.tar.xz

# rm -rf $DIRNAME
||||||| merged common ancestors
git clone ${REF:+--reference $REF} \
	git://git.freedesktop.org/git/mesa/drm $DIRNAME

GIT_DIR=$DIRNAME/.git git archive --format=tar --prefix=$DIRNAME/ ${1:-HEAD} \
	| bzip2 > $DIRNAME.tar.bz2

# rm -rf $DIRNAME
=======
# append sha to dirname
mv $dirname $dirname-git$sha
dirname=$dirname-git$sha
tarball=$dirname.tar.bz2
tar jcf $tarball $dirname
rm -rf $dirname
echo "$tarball is now available"
>>>>>>> xorg-x11-proto-devel package update
