Hi,

thanks for your input. I have modified the driver according to your replies (I
hope I understood them all). The actual version is attached. Are there any
further suggestions/recommendations/comments?

bye
richi (namenlos)
-- 
quoting guide: http://www.xs4all.nl/~hanb/documents/quotingguide.html
#!/bin/sh
#
# /etc/ports/drivers/git: git driver script for ports(8)
#
# The configuration files got to have following variables defined:
# URL:          The URL from where to clone the repository
# BRANCH:       The branch of the repository to use
# DESTINATION:  The destination directory for the checked out repository

OLDPWD=$PWD
export PAGER=cat

# checks whether we got a valid repository (exit code will be 0, if the
# repository is valid, otherwise 1)
function checkValidRepository() {
        if [ -d $DESTINATION/.git ]
        then
                cd $DESTINATION
                if [ "$URL" ==  `git config --get remote.origin.url` ]
                then
                        return 0
                fi
        fi
        return 1
}

# check, whether we got a configuration file given
if [ $# -ne 1 ]
then
        echo "usage: $0 <configuration file>"
        exit 1
fi

. $1

echo "Updating collection `basename $DESTINATION` from $URL"

checkValidRepository
if [ $? -ne 0 ]
then
        # the repository was not setup correctly -> delete it
        if [ -d $DESTINATION ]
        then
                rm -rf $DESTINATION
        fi

        # clone the repository
        git-clone --depth 1 --quiet $URL $DESTINATION
        cd $DESTINATION
else
        # there was already a clone -> fetch the changes
        cd $DESTINATION
        # print the files, which will be reseted
        git-diff --name-status -R $BRANCH
        git-reset --hard -q
        git-fetch --quiet
        git-gc --quiet

fi

# print all the updated files
git-diff --name-status -R $BRANCH

git-checkout -q $BRANCH

cd $OLDPWD

echo "Finished successfully"

Attachment: pgp3JuM2jWVxu.pgp
Description: PGP signature

_______________________________________________
crux-devel mailing list
crux-devel@lists.crux.nu
http://lists.crux.nu/mailman/listinfo/crux-devel

Reply via email to