Difference between revisions of "First Steps with Gitea"

From SME Server
Jump to navigationJump to search
(Streamlined the file copy, added remove old git directory)
Line 15: Line 15:
 
RemoteRepoURL="https://src.koozali.org/$RemoteUser/$1"
 
RemoteRepoURL="https://src.koozali.org/$RemoteUser/$1"
 
mkdir -p $GitFiles
 
mkdir -p $GitFiles
 +
 
#Make sure credentials taken from store
 
#Make sure credentials taken from store
git config --global credential.helper store
+
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.
  
 
# Clone the CVS repository
 
# Clone the CVS repository
Line 28: Line 29:
 
# Create the local Git repository
 
# Create the local Git repository
 
cd $GitFiles
 
cd $GitFiles
 +
rm -rf $1
 
git init $1
 
git init $1
 
cd $1
 
cd $1
Line 34: Line 36:
 
if [ $2 == "contrib" ]; then
 
if [ $2 == "contrib" ]; then
 
     mkdir -p contribs10
 
     mkdir -p contribs10
cp $CVSFiles/$1/contribs10/*.patch ./contribs10/
+
    for fpath in "*.patch" "*.spec" "*.gz" "*.tgz" "*.xz" "Makefile"
cp $CVSFiles/$1/contribs10/*.spec ./contribs10/
+
    do
cp $CVSFiles/$1/contribs10/*.tar.gz ./contribs10/
+
    cp $CVSFiles/$1/contribs10/$fpath ./contribs10/
cp $CVSFiles/$1/contribs10/*.tgz ./contribs10/
+
    done
cp $CVSFiles/$1/contribs10/*.xz ./contribs10/
 
cp $CVSFiles/$1/contribs10/Makefile ./contribs10/
 
 
else
 
else
mkdir -p sme10
+
mkdir -p sme10
        cp $CVSFiles/$1/sme10/*.patch ./sme10/
+
    for fpath in "*.patch" "*.spec" "*.gz" "*.tgz" "*.xz" "Makefile"
        cp $CVSFiles/$1/sme10/*.spec ./sme10/
+
    do
        cp $CVSFiles/$1/sme10/*.tar.gz ./sme10/
+
         cp $CVSFiles/$1/sme10/$fpath ./sme10/
        cp $CVSFiles/$1/sme10/*.tgz ./sme10/
+
    done
         cp $CVSFiles/$1/sme10/*.xz ./sme10/
 
cp $CVSFiles/$1/sme10/Makefile ./sme10/
 
 
fi
 
fi
  
Line 65: Line 63:
 
echo "Created $1 Repo in $RemoteRepoURL"
 
echo "Created $1 Repo in $RemoteRepoURL"
 
exit 0  
 
exit 0  
 
 
 
 
</syntaxhighlight>Issues:
 
</syntaxhighlight>Issues:
  

Revision as of 10:04, 7 February 2023

Initial script to take the latest version of a module and move it to Gitea.

#!/bin/bash
# $1  = Module name e.g. smeserver-ddclient
# $2 = "contrib" ot anything else -=> core module
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
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.

# Clone the CVS repository
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)
cd $1/contribs10
make prep

# Create the local Git repository
cd $GitFiles
rm -rf $1
git init $1
cd $1
echo `pwd`
#pull in all the files we want
if [ $2 == "contrib" ]; then
    mkdir -p contribs10
    for fpath in "*.patch" "*.spec" "*.gz" "*.tgz" "*.xz" "Makefile" 
    do 
    	cp $CVSFiles/$1/contribs10/$fpath ./contribs10/
    done
else
	mkdir -p sme10
    for fpath in "*.patch" "*.spec" "*.gz" "*.tgz" "*.xz" "Makefile" 
    do 
        cp $CVSFiles/$1/sme10/$fpath ./sme10/
    done
fi

#Get Clone the common directory
git clone https://src.koozali.org/brianr/common.git

#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

Issues:

  1. How to partition the repos between smecontribs and core? different User?
  2. Need ssh access to gitea for automatic creation of repos, else each one has to be created by hand!
  3. Realising that I need the contribs10/11/12 directories under the module name if I am going to get make mockbuild to work.
  4. Are going to hold the rpm's in the git repo as well? Otherwise we need the .gitignore set to *.rpm