Blob Blame History Raw
#!/bin/sh

function archive_it() {
    name=$1
    uri=$2
    path=$3
    
    if test -d $name
    then
	cd $name
	git checkout master
	git reset --hard
	git pull
	cd ..
    else
	git clone $uri
    fi
    
    cd $name
    DATE=$(git log -1 --format=%cd --date=short | tr -d \-)
    HASH=`git rev-parse --short HEAD`

    FILE=${name}-${DATE}git${HASH}.tar.gz

    git archive --format tar.gz --prefix ${name}/ -o ../$FILE HEAD $path
    cd ..
}

function print_hash() {
    name=$1

    cd $name
    HASH=`git rev-parse --short HEAD`

    today=$(git log -1 --format=%cd --date=short | tr -d \-)

    macro=`echo $name | sed -e 's/-/_/g'`
    echo "%global ${macro}_version ${today}git${HASH}"
    cd ..
}

archive_it zart https://github.com/c-koi/zart .
archive_it gmic-qt https://github.com/c-koi/gmic-qt .
archive_it gmic-community https://github.com/dtschump/gmic-community libcgmic

print_hash zart
print_hash gmic-qt
print_hash gmic-community