#!/bin/sh # # Migrate TCOS to GIT # SVN_TRUNK=http://tcosproject.org/svn/tcos/trunk GIT_WEB=http://tcosproject.org/gitweb/ GIT_SSH=ssh://git@tcosproject.org/git/ GIT_ANO=http://tcosproject.org/git/ AUTHORS=/ftp/tcosproject.org/authors.txt ROOT=/ftp/tcosproject.org/root GITROOT=/ftp/tcosproject.org/gitroot/ migrate_repo() { PKG=$1 if [ "$1" = "" ]; then echo "Need a package to migrate" return fi if [ -d ${GITROOT}/${PKG}.git ]; then #echo "Error: Package '$PKG' found" return fi # import with git-svn mkdir -p ${ROOT}/${PKG} ( cd ${ROOT}/${PKG} && git-svn clone ${SVN_TRUNK}/${PKG} --authors-file=${AUTHORS} ) if [ $? != 0 ]; then echo "Error while downloading SVN repos of $PKG" return fi # create git from SVN mkdir -p ${ROOT}/${PKG}.git (cd ${ROOT}/${PKG}.git && git --bare init) # go to git-svn, add remote and push ( cd ${ROOT}/${PKG}/$PKG && git remote add origin ${ROOT}/${PKG}.git ) if [ $? != 0 ]; then echo "Error while pushing repos of $PKG" return fi ( cd ${ROOT}/${PKG}/$PKG && git-push origin master ) if [ $? != 0 ]; then echo "Error while pushing repos of $PKG" return fi rm -rf ${ROOT}/${PKG} mv ${ROOT}/${PKG}.git ${GITROOT} echo "${PKG}.git mariodebian@gmail.com" >> ${GITROOT}/gitweb-projects echo "Done" } configure_git() { PKG=$1 if [ "$1" = "" ]; then echo "Need a package to migrate" return fi cat << EOF > ${GITROOT}/${PKG}.git/config [core] repositoryformatversion = 0 filemode = true bare = true [gitweb] owner = "Mario Izquierdo (mariodebian)" EOF cat << EOF > ${GITROOT}/${PKG}.git/description TCOS GIT repository of $PKG package EOF touch ${GITROOT}/${PKG}.git/git-daemon-export-ok chmod a+x ${GITROOT}/${PKG}.git/hooks/post-update # set URLS cat << EOF > ${GITROOT}/${PKG}.git/cloneurl $GIT_ANO$PKG.git (anonymous) $GIT_SSH$PKG.git (SSH key) $GIT_WEB?p=$PKG;a=summary (browse) EOF echo " * configured ${PKG}" #echo "${GITROOT}/${PKG}.git/cloneurl" } # get SVN dirs from trunk PACKAGES=$(svn ls $SVN_TRUNK| grep "/$") for _p in $PACKAGES; do p=$(basename $_p) migrate_repo "$p" configure_git "$p" done