Line 1: |
Line 1: |
− | ==Initial script to take the latest version of a module and move it to Gitea.==
| + | The script to use is smedev/git-cvs2git.sh |
− | <syntaxhighlight lang="shell">
| |
− | #!/bin/bash
| |
− | # $1 = Module name e.g. smeserver-ddclient
| |
− | # $2 = "contrib" ...anything else -=> core module
| |
− | if [ $1 = "" ]
| |
− | then
| |
− | echo "cvs2git <modulename> <contrib|base>"
| |
− | exit 0
| |
− | fi
| |
− | LocalUser="brianr"
| |
− | RemoteUser="brianr"
| |
− | if [ $2 == "contrib" ]; then
| |
− | CVSFiles="/home/$LocalUser/smecontribs/rpms"
| |
− | else
| |
− | CVSFiles="/home/$LocalUser/smeserver/rpms"
| |
− | fi
| |
− | GitFiles="/home/$LocalUser/GitFiles"
| |
− | RemoteRepoURL="https://src.koozali.org/$RemoteUser/$1"
| |
− | mkdir -p $GitFiles
| |
| | | |
− | #Make sure credentials taken from store | + | # $1 = Module name e.g. smeserver-ddclient |
− | git config --global credential.helper store #The first time you pull or push it will ask for credentials and then save them in a file.
| + | # $2 = Organisation (smeserver or smecontrib)e |
| + | # optional (can be in any order) |
| + | # <local> will use parameters set for local repository else it will use remote |
| + | # <debug> turn on debug regardless of ~/.smegit/config |
| + | # <noisy> print a line showing how it was called |
| | | |
− | # Clone the CVS repository
| + | This will take a CVS package and create a equivalent git repo and copy across the data. |
− | cd $CVSFiles
| |
− | cvs -d:ext:shell.koozali.org:/cvs/smecontribs checkout $1
| |
| | | |
− | # Fully populate the directory (gets the tar file - which is not strictly in CVS)
| + | See also: |
− | cd $1/contribs10
| |
− | make prep
| |
− | | |
− | #Extract the directory name for the file tree (it will include the name of the module plus some version information)
| |
− | cd $CVSFiles/$1/contribs10/
| |
− | TREEPATH=`ls -d */ | grep $1 | grep -v "\.old" | grep -v "_sme"`
| |
− | echo "TreePATH:$TREEPATH"
| |
− | | |
− | # Create the local Git repository
| |
− | cd $GitFiles
| |
− | rm -rf $1
| |
− | git init $1
| |
− | cd $1
| |
− | echo "PWD:"`pwd`
| |
− | #pull in all the files we want
| |
− | if [ $2 == "contrib" ]; then
| |
− | for fpath in "$TREEPATH" "*.spec" "Makefile" "$TREEPATH/createlinks"
| |
− | do
| |
− | cp -R $CVSFiles/$1/contribs10/$fpath .
| |
− | done
| |
− | mv $TREEPATH/root ./root
| |
− | rm -f $TREEPATH/*
| |
− | rmdir $TREEPATH
| |
− | else
| |
− | for fpath in "$TREEPATH" "*.spec" "Makefile" "$TREEPATH/createlinks"
| |
− | do
| |
− | cp -R $CVSFiles/$1/sme10/$fpath .
| |
− | done
| |
− | mv $TREEPATH/root ./root
| |
− | rm -f $TREEPATH/*
| |
− | rmdir $TREEPATH
| |
− | fi
| |
− | | |
− | #Now edit the spec file to remove all those patches and adjust the paths
| |
− | sed -i '/^Patch/d; /^%patch/d' $1.spec
| |
− | # no paths adjusted yet!
| |
− | | |
− | #Create the tar file needed (currently) for the rpm build
| |
− | tar -czf $TREEPATH.tar.gz root/
| |
− | | |
− | #Clone the common directory
| |
− | git clone https://src.koozali.org/brianr/common.git
| |
− | # and delete the .git else it pushes back a link to the repo
| |
− | cd common
| |
− | rm -fr ".git"
| |
− | cd ..
| |
− | | |
− | #
| |
− | # Use the https interface to create the remote repo (it will just bounce back if it exists already)
| |
− | # Currently this creates a private repo (making it public here causes a gitea internal server error, as does auto_init
| |
− | # Note that the token decides where the repo is created (i.e. under what user)
| |
− | # We will need this to be "organisation" (smecontribs or smeserver) finally.
| |
− | #
| |
− | curl -X 'POST' 'https://src.koozali.org/api/v1/user/repos' \
| |
− | -H 'accept: application/json' \
| |
− | -H 'Authorization: token 28b6ebca17d6a70d6c1848e8edce4007f072961c' \
| |
− | -H 'Content-Type: application/json' \
| |
− | -d '{
| |
− | "auto_init": false,
| |
− | "default_branch": "master",
| |
− | "description": "'"SMEServer git repo for $1 $2"'",
| |
− | "gitignores": "",
| |
− | "issue_labels": "",
| |
− | "license": "Apache 2.0",
| |
− | "name": "'"$1"'",
| |
− | "private": true,
| |
− | "readme": "",
| |
− | "template": false,
| |
− | "trust_model": "default"
| |
− | }'
| |
− | | |
− | | |
− | #stage and commit them
| |
− | git add -A
| |
− | git commit -m "initial commit of file from CVS for $1"
| |
− | | |
− | # Create the remote repo and push the converted git repository to the remote
| |
− | git remote remove origin
| |
− | git remote add origin $RemoteRepoURL
| |
− | # Need to have created the repo at this point....
| |
− | git pull --no-edit origin master
| |
− | git push -u origin master
| |
− | echo "Created $1 Repo in $RemoteRepoURL"
| |
− | exit 0
| |
− | | |
− | | |
− | | |
− | </syntaxhighlight>
| |
| | | |
| ==Issues:== | | ==Issues:== |