Remi Collet 00ab3d
#!/bin/bash
Remi Collet 00ab3d
Remi Collet 00ab3d
NAME=$(basename $PWD)
Remi Collet 00ab3d
OWNER=$(sed   -n '/^%global gh_owner/{s/.* //;p}'   $NAME.spec)
Remi Collet 00ab3d
PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec)
Remi Collet 00ab3d
VERSION=$(sed -n '/^Version:/{s/.* //;p}'           $NAME.spec)
Remi Collet 00ab3d
COMMIT=$(sed  -n '/^%global gh_commit/{s/.* //;p}'  $NAME.spec)
Remi Collet 00ab3d
SHORT=${COMMIT:0:7}
Remi Collet 00ab3d
Remi Collet 00ab3d
echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
Remi Collet 00ab3d
Remi Collet 00ab3d
echo "Cloning..."
Remi Collet 00ab3d
rm -rf $PROJECT-$COMMIT
Remi Collet 00ab3d
git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
Remi Collet 00ab3d
Remi Collet 00ab3d
echo "Getting commit..."
Remi Collet 00ab3d
pushd $PROJECT-$COMMIT
Remi Collet 00ab3d
git checkout $COMMIT
Remi Collet 00ab3d
popd
Remi Collet 00ab3d
Remi Collet 00ab3d
echo "Archiving..."
Remi Collet 00ab3d
tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
Remi Collet 00ab3d
Remi Collet 00ab3d
echo "Cleaning..."
Remi Collet 00ab3d
rm -rf $PROJECT-$COMMIT
Remi Collet 00ab3d
Remi Collet 00ab3d
echo "Done."