Compare commits
48 Commits
6e9f8dddb9
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
50f193b2db | ||
e30641250e | |||
0c858eaba1 | |||
c4f00b4328 | |||
f984ec736d | |||
454e474564 | |||
![]() |
8f06ffbed9 | ||
![]() |
c15231193b | ||
![]() |
bd51a307e8 | ||
![]() |
f948bbc974 | ||
![]() |
6fff2d19f5 | ||
![]() |
fb6a44f132 | ||
![]() |
c5800c3e14 | ||
![]() |
1a4d5ade8f | ||
![]() |
331c908cb8 | ||
![]() |
c5d71a4da7 | ||
![]() |
452e84b2ca | ||
![]() |
1e00424274 | ||
e19bd34d0c | |||
f8e6992cea | |||
28d6cb1a44 | |||
0ca87cfbee | |||
13d705639c | |||
![]() |
c690004aca | ||
![]() |
a90599279b | ||
![]() |
9916c56721 | ||
![]() |
5c4f74da8f | ||
f7e6b20b25 | |||
![]() |
9fd4f2cce8 | ||
![]() |
c8f81a0315 | ||
![]() |
0c53f9fae6 | ||
![]() |
ce14ed07fc | ||
![]() |
eaf957da50 | ||
![]() |
4ddb8de08e | ||
c25fa1943a | |||
![]() |
19efadfa1d | ||
![]() |
750bde5b38 | ||
![]() |
de31b20e72 | ||
![]() |
c6e57c9475 | ||
![]() |
98eddc7b64 | ||
![]() |
e2b9906429 | ||
![]() |
99be082770 | ||
029b3fe3cd | |||
![]() |
70daf74b8d | ||
![]() |
307a492847 | ||
![]() |
ee106a077c | ||
![]() |
fd798e83c3 | ||
![]() |
477ecb7c4d |
92
README.md
92
README.md
@@ -26,8 +26,9 @@ optional parameters, can appear in any order
|
|||||||
## git-get-and-build-repo.sh
|
## git-get-and-build-repo.sh
|
||||||
bring down current git repository and run mockbuild
|
bring down current git repository and run mockbuild
|
||||||
|
|
||||||
git-get-and-build.sh <repository> <organisation> [<local> <debug>]
|
git-get-and-build.sh <repository> <organisation> [branch=<branch> <local> <debug>]
|
||||||
|
|
||||||
|
* \<branch=<branch\> will bring back a specific branch, otherwise Master
|
||||||
* \<repository\> repository (package) to be built (e.g. smeserver-yum)
|
* \<repository\> repository (package) to be built (e.g. smeserver-yum)
|
||||||
* \<organisation\> can be any organisation or user on the remote GITEA instance
|
* \<organisation\> can be any organisation or user on the remote GITEA instance
|
||||||
|
|
||||||
@@ -67,23 +68,20 @@ optional parameters, can appear in any order
|
|||||||
\<debug\> run in debug mode
|
\<debug\> run in debug mode
|
||||||
\<silent\> suppress success message
|
\<silent\> suppress success message
|
||||||
|
|
||||||
## rename-e-smith-pkg.sh
|
## git-retag.sh
|
||||||
Rename an e-smith package as smeserver and change relevant files
|
Create a new tag based on %version-%release in spec file (without trailing el7.sme) and optionally remove old tags
|
||||||
|
|
||||||
rename-emith-pkg.sh <pkg> [<organisation> <local> <force> <debug>]
|
git-retag.sh <repository> <organisation> [<local> <debug> <noisy>]
|
||||||
|
|
||||||
* \<pkg\> Module name to be renamed e.g. e-smith-dnscache
|
* \<repository\> repository to be retagged
|
||||||
|
* \<organisation\> organisation\owner that the repository belongs to
|
||||||
|
|
||||||
optional parameters, can appear in any order
|
optional parameters, can appear in any order
|
||||||
|
|
||||||
* \<organisation\> (any gitea organisation smeserver, smecontribs or user - defaults to smeserver)
|
* \<purge\> will remove all existing tags
|
||||||
* \<local\> will use parameters set for local repository else it will use remote
|
* \<local\> will use parameters set for local repository, else it will use remote
|
||||||
* \<force\> will automagically delete an existing repo, otherwise it will prompt
|
* \<debug\> run with debug output
|
||||||
* \<transfer\> will transfer the updated repository to the source org (need to be owner)
|
* \<noisy\> will will print a line showing how it was called
|
||||||
* \<debug\> run in debug mode
|
|
||||||
* \<silent\> will suppress the finished Ok message
|
|
||||||
|
|
||||||
This works whether the repo and local files exist of not (it deletes them if necessary)
|
|
||||||
|
|
||||||
## parse-list.sh
|
## parse-list.sh
|
||||||
Parse a list of parameters and execute script with those parameters
|
Parse a list of parameters and execute script with those parameters
|
||||||
@@ -131,6 +129,7 @@ Does:
|
|||||||
Create a release and upload the rpm (src and bin) as attachments to that release
|
Create a release and upload the rpm (src and bin) as attachments to that release
|
||||||
|
|
||||||
* \<repository\> repository (package) to be editted (e.g. smeserver-yum)
|
* \<repository\> repository (package) to be editted (e.g. smeserver-yum)
|
||||||
|
* \<draft | prerelease> create draft or prerelease else it will create full stable release
|
||||||
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
|
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
|
||||||
* \<release-tag\> will have "SME" added to the front of it (so e.g. 10.2 -> SME10.2)
|
* \<release-tag\> will have "SME" added to the front of it (so e.g. 10.2 -> SME10.2)
|
||||||
|
|
||||||
@@ -138,10 +137,75 @@ optional: (in any order)
|
|||||||
|
|
||||||
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
|
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
|
||||||
* \<noisy\> show line being executed
|
* \<noisy\> show line being executed
|
||||||
* \<debug\> run in debug modea
|
* \<debug\> run in debug mode
|
||||||
|
* \<draft\> create a draft release
|
||||||
|
* \<prerelease\> create a pre-release
|
||||||
|
|
||||||
|
Note that no release type will give a full stable release
|
||||||
|
|
||||||
Does:
|
Does:
|
||||||
|
|
||||||
Create the release (deleting one that is the same tag),
|
Create the release (deleting one that is the same tag),
|
||||||
Then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
|
Then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
|
||||||
|
|
||||||
|
## git-list-all-org-repos.sh
|
||||||
|
List the repos in any one organisation and optionally show the release and some associated fields
|
||||||
|
|
||||||
|
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
|
||||||
|
|
||||||
|
optional: (in any order)
|
||||||
|
|
||||||
|
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
|
||||||
|
* \<noisy\> show line being executed
|
||||||
|
* \<debug\> run in debug mode
|
||||||
|
* \<draftrelease\> Show all draft releases
|
||||||
|
* \<prerelease\> Show all prereleases
|
||||||
|
* \<release\> Show all full releases
|
||||||
|
* \<allreleases\> Show all releases
|
||||||
|
* \<cloneurl\> Show the url to use to clone this repo
|
||||||
|
* \<zipurl\> Show the url to get the zipped contents of the repo
|
||||||
|
* \<asseturls\> Show the URLs of the assets associated with the release
|
||||||
|
|
||||||
|
Does:
|
||||||
|
|
||||||
|
Display a "table" of each repo and the optional extras requested.
|
||||||
|
|
||||||
|
## git-update-release-in-one-repo.sh
|
||||||
|
Update the release (draft/prerelease/release)
|
||||||
|
|
||||||
|
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
|
||||||
|
* \<repo\> name of the repo (package)
|
||||||
|
* \<releasetag\> Full tag of the release (inc SME if applicable) OR
|
||||||
|
* \<id\>
|
||||||
|
* draft|prerelease|release
|
||||||
|
|
||||||
|
|
||||||
|
optional: (in any order)
|
||||||
|
|
||||||
|
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
|
||||||
|
* \<debug\> run in debug mode
|
||||||
|
|
||||||
|
Does:
|
||||||
|
|
||||||
|
Resets the release specified to the type specified.
|
||||||
|
|
||||||
|
## git-get-latest-tag.sh
|
||||||
|
|
||||||
|
Return the newest tag for the repo
|
||||||
|
|
||||||
|
* \<repo\> name of the repo (package)
|
||||||
|
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
|
||||||
|
|
||||||
|
## github-make-push-mirror.sh
|
||||||
|
|
||||||
|
Create a repo on github.com and add a push mirror entry to the equivalent gitea repo.
|
||||||
|
|
||||||
|
* \<repo\> Name of the repo
|
||||||
|
* \<organisation\> Name of the organisation in GITEA
|
||||||
|
* \<github organisation\> Name of the organisation in GITHUB
|
||||||
|
|
||||||
|
Note that .smegit/conf needd GITHUBTOKEN and GITHUBLOGIN the token must have the necessary permissions. Either fine-grain token or one of the orginal tokens. Created through settings/developer tools/api tokens on github.com.
|
||||||
|
|
||||||
|
Also need to login in to github using `gh auth login` before running the command.
|
||||||
|
|
||||||
|
|
||||||
|
6
config
6
config
@@ -2,9 +2,9 @@
|
|||||||
DEBUG=false
|
DEBUG=false
|
||||||
# if first character ~ will be relative to users home, otherwise absolute
|
# if first character ~ will be relative to users home, otherwise absolute
|
||||||
WORKDIR=~/smegit
|
WORKDIR=~/smegit
|
||||||
COMMONREPO=https://src.koozali.org/smedev/common.git
|
COMMONREPO=https://src.koozali.org/smeserver/common.git
|
||||||
# Brian's token, but please use wisely!
|
# OpenAI key for readme comment lookup.
|
||||||
OPENAI_API_KEY=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
|
OPENAI_API_KEY=<key - ask Brian for his..>
|
||||||
[local]
|
[local]
|
||||||
USER=<local GITEA user name>
|
USER=<local GITEA user name>
|
||||||
GITEAHOST=<local GITEA URL>
|
GITEAHOST=<local GITEA URL>
|
||||||
|
@@ -755,9 +755,8 @@ git push --force -u $QUIET origin master
|
|||||||
# Now create the version and release tag for these files
|
# Now create the version and release tag for these files
|
||||||
RELEASE=`rpm --queryformat '%{release}\n' --specfile $NAME.spec | head -n 1`
|
RELEASE=`rpm --queryformat '%{release}\n' --specfile $NAME.spec | head -n 1`
|
||||||
# Release is not reliable - if you run on Rocky it comes back EL8, centos 7 - EL7
|
# Release is not reliable - if you run on Rocky it comes back EL8, centos 7 - EL7
|
||||||
# so - confusing!!
|
# So, we need to just take the build part (first word)
|
||||||
# for now - take out the RELEASE from the tag
|
TAG=$VERSION"-"${RELEASE%.*}
|
||||||
TAG=$VERSION
|
|
||||||
git tag -a $TAG -m "$COMMENT"
|
git tag -a $TAG -m "$COMMENT"
|
||||||
git push origin $TAG $QUIET
|
git push origin $TAG $QUIET
|
||||||
|
|
||||||
|
84
git-delete-release-in-one-rep.sh
Executable file
84
git-delete-release-in-one-rep.sh
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# git-delete-release-in-one-rep.sh <organisation> <repo> [ <releasetag> | <id> ]
|
||||||
|
#
|
||||||
|
# Create the release (deleting one that is the same tag),
|
||||||
|
# then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
if [[ -z $1 ]] ; then
|
||||||
|
echo "git-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
echo "git-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
|
||||||
|
DEBUG=
|
||||||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
for param in $2 $3 $4 $5 $6 $7; do
|
||||||
|
if [ $param ] ; then
|
||||||
|
case $param in
|
||||||
|
local )
|
||||||
|
GITEAUser=${local_USER}
|
||||||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${local_GITEAHOST}
|
||||||
|
;;
|
||||||
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
* )
|
||||||
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Uses if ist char is numeric to see if an id or tag is provided
|
||||||
|
if [[ ! "${3:0:1}" =~ [0-9] ]]; then
|
||||||
|
# <organisation> <repo> <releasetag> - find the id from the info provided
|
||||||
|
ID=999;
|
||||||
|
# TBD
|
||||||
|
else
|
||||||
|
ID=$3;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $DEBUG ]; then echo "I:$ID"; fi
|
||||||
|
|
||||||
|
# And then delete it by id.
|
||||||
|
RESPONSE=$(curl -s -X 'DELETE' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN")
|
||||||
|
if [ $DEBUG ]; then echo "$RESPONSE"; fi
|
||||||
|
exit 0
|
70
git-edit-readme.sh
Executable file
70
git-edit-readme.sh
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# git-edit-readme.sh
|
||||||
|
#
|
||||||
|
# Edit the README.md for an smeserver package and alter the Bugzilla link
|
||||||
|
#
|
||||||
|
# $1 = package name
|
||||||
|
|
||||||
|
ORG=smecontribs # or smeserver
|
||||||
|
|
||||||
|
echo "$ORG / $1"
|
||||||
|
|
||||||
|
cd ~/GITFiles/$ORG
|
||||||
|
if [ -d "$1" ]; then
|
||||||
|
cd "$1"
|
||||||
|
git pull
|
||||||
|
else
|
||||||
|
git clone "https://src.koozali.org/$ORG/$1"
|
||||||
|
cd "$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Current directory: `pwd`"
|
||||||
|
|
||||||
|
if [ -f "README.md" ]; then
|
||||||
|
echo "Running awk to update README.md"
|
||||||
|
|
||||||
|
# Use a temporary file to handle multi-line replacement
|
||||||
|
awk '/Show list of outstanding bugs: \[here\]/{
|
||||||
|
print "Show list of outstanding bugs:"
|
||||||
|
print "[All](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=UNCONFIRMED&bug_status=CONFIRMED" \
|
||||||
|
"&bug_status=NEEDINFO&bug_status=IN_PROGRESS" \
|
||||||
|
"&bug_status=RESOLVED&bug_status=VERIFIED" \
|
||||||
|
"&classification=Contribs&component='"$1"'&list_id=105781" \
|
||||||
|
"&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[Confirmed](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=CONFIRMED&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[Unconfirmed](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=UNCONFIRMED&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[Need Info](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=NEEDINFO&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[In Progress](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=IN_PROGRESS&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[Verified](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=VERIFIED&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
print "[Resolved](https://bugs.koozali.org/buglist.cgi?action=wrap" \
|
||||||
|
"&bug_status=RESOLVED&classification=Contribs&component='"$1"'" \
|
||||||
|
"&list_id=105781&order=changeddate+DESC%2Ccomponent%2Cpriority" \
|
||||||
|
"%2Cbug_severity&product=SME+Contribs&query_format=advanced) "
|
||||||
|
next
|
||||||
|
}1' README.md > README.tmp && mv README.tmp README.md
|
||||||
|
|
||||||
|
git status
|
||||||
|
git add --all
|
||||||
|
git commit -m "Update README with specific Bugzilla links"
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "README.md not found in $1"
|
||||||
|
fi
|
57
git-get-latest-tag.sh
Executable file
57
git-get-latest-tag.sh
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [[ $# -ne 2 ]]; then
|
||||||
|
echo "git-get-latest-tag.sh <modulename> <organisation>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
echo "git-cvs2git.sh <modulename> <organization> [<local>]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
|
||||||
|
DEBUG=
|
||||||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
|
|
||||||
|
# Check that jq is installed
|
||||||
|
if command -v jq -V > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Jq is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************** jq is not installed (try EPEL)**************"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
|
||||||
|
REPO_OWNER="$2"
|
||||||
|
REPO_NAME="$1"
|
||||||
|
|
||||||
|
# Send request to Gitea API to get the list of tags
|
||||||
|
LATEST_TAG=$(curl -H "Authorization: token $GITEAACCESSTOKEN" -s $GITEAHOST/api/v1/repos/$REPO_OWNER/$REPO_NAME/tags | jq -r '.[0].name')
|
||||||
|
|
||||||
|
# Print the latest tag
|
||||||
|
echo "Latest tag for the repository $REPO_NAME is: $LATEST_TAG"
|
@@ -8,7 +8,7 @@ if [ ! -e $inifilename ] ; then
|
|||||||
# Not here, look at system default
|
# Not here, look at system default
|
||||||
if [ ! -e /etc/smegit.ini ] ; then
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
echo "No ini file found $inifiename or /etc/smegit.ini"
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
echo "get-repo-and-build.sh <organisation> <reponame> [<local> <debug>]"
|
echo "get-repo-and-build.sh <organisation> <reponame> [branch=<branch> <local> <debug>]"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
initfilename="/etc/smegit.ini"
|
initfilename="/etc/smegit.ini"
|
||||||
@@ -39,10 +39,14 @@ GITEAHOST=${remote_GITEAHOST}
|
|||||||
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
ORG_NAME="$2"
|
ORG_NAME="$2"
|
||||||
REPO_NAME="$1"
|
REPO_NAME="$1"
|
||||||
|
BRANCH=
|
||||||
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
for param in $3 $4 $5 $6; do
|
for param in $3 $4 $5 $6; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
case $param in
|
case $param in
|
||||||
|
branch=* )
|
||||||
|
BRANCH="--${param}"
|
||||||
|
;;
|
||||||
local )
|
local )
|
||||||
GITEAHOST=${local_GITEAHOST}
|
GITEAHOST=${local_GITEAHOST}
|
||||||
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
@@ -105,26 +109,33 @@ fi
|
|||||||
|
|
||||||
# See if repo exits in git
|
# See if repo exits in git
|
||||||
if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi
|
if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi
|
||||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
|
BRANCHES=
|
||||||
|
if [ $BRANCH ] ; then BRANCHES="/branches/${BRANCH#*=}" ; fi
|
||||||
|
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME$BRANCHES")
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME exists!" ; fi
|
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME exists!" ; fi
|
||||||
else
|
else
|
||||||
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME does not exist" ; fi
|
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME does not exist" ; fi
|
||||||
while true; do
|
if [ $BRANCH ] ; then
|
||||||
read -p "Do you wish to run git-cvs2git?(y/n) " yn
|
echo "Can't find the ${BRANCH#*=} branch of $ORG_NAME/$REPO_NAME - exiting"
|
||||||
case $yn in
|
exit 1
|
||||||
[Yy]* )
|
else
|
||||||
if [ $DEBUG ] ; then echo "running git-cvs2git.sh" ; fi
|
while true; do
|
||||||
logname="git-cvs2git-create-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log"
|
read -p "Do you wish to run git-cvs2git?(y/n) " yn
|
||||||
git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname
|
case $yn in
|
||||||
break;;
|
[Yy]* )
|
||||||
[Nn]* ) exit;;
|
if [ $DEBUG ] ; then echo "running git-cvs2git.sh" ; fi
|
||||||
* ) echo "Please answer yes or no.";;
|
logname="git-cvs2git-create-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log"
|
||||||
esac
|
git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname
|
||||||
done
|
break;;
|
||||||
|
[Nn]* ) exit;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
# And check it is now there
|
# And check it is now there
|
||||||
if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi
|
if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi
|
||||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
|
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME$BRANCHES")
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME created sucessfully!" ; fi
|
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME created sucessfully!" ; fi
|
||||||
else
|
else
|
||||||
@@ -141,8 +152,8 @@ if [[ -d $REPO_NAME ]] ; then
|
|||||||
if [ $DEBUG ] ; then echo "Deleting all files in $GITFiles/$REPO_NAME" ; fi
|
if [ $DEBUG ] ; then echo "Deleting all files in $GITFiles/$REPO_NAME" ; fi
|
||||||
rm -rf "$GITFiles/$REPO_NAME"
|
rm -rf "$GITFiles/$REPO_NAME"
|
||||||
fi
|
fi
|
||||||
if [ $DEBUG ] ; then echo "cloning $REPOURL" ; fi
|
if [ $DEBUG ] ; then echo "cloning $REPOURL $BRANCH" ; fi
|
||||||
git clone "$REPOURL" $QUIET
|
git clone "$REPOURL" $BRANCH $QUIET
|
||||||
|
|
||||||
cd $GITFiles
|
cd $GITFiles
|
||||||
if [[ ! -d $GITFiles/$REPO_NAME ]] ; then
|
if [[ ! -d $GITFiles/$REPO_NAME ]] ; then
|
||||||
|
494
git-getperl.sh
Executable file
494
git-getperl.sh
Executable file
@@ -0,0 +1,494 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# $1 = perl Module e.g. File::MMagic
|
||||||
|
# $2 = Organisation (smeserver, smecontrib or user) - default smeserver
|
||||||
|
# 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
|
||||||
|
# This works whether the repo and local files exist of not (it deletes them if necessary)
|
||||||
|
# However if the remote repo exists, it preserves the README.md file so that edits are not lost
|
||||||
|
# Also note: I have had difficulty deleting all the link files in the source tree!
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ -z $1 ]] ; then
|
||||||
|
echo "************git-getperl.sh <modulename> <organization> [<local> | <debug> | <noisy>]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
echo "git-getperl.sh <modulename> <organization> [<local>]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
DEBUG=
|
||||||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
|
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
NOISY=
|
||||||
|
EXTRAPARAMS=
|
||||||
|
MODULENAME=$1
|
||||||
|
ORGGITEA="smeserver"
|
||||||
|
for param in $2 $3 $4 $5 $6; do
|
||||||
|
if [ $param ] ; then
|
||||||
|
case $param in
|
||||||
|
local )
|
||||||
|
GITEAUser=${local_USER}
|
||||||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${local_GITEAHOST}
|
||||||
|
;;
|
||||||
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
noisy )
|
||||||
|
NOISY=true ;;
|
||||||
|
* )
|
||||||
|
ORGGITEA=$param ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $NOISY ] ; then echo "git-getperl.sh $1 $2 $3 $4 $5 $6" ; fi
|
||||||
|
if [ $DEBUG ] ; then echo "************found ini file: $inifilename" ; fi
|
||||||
|
# Make this null if you want lots of output. Still quite a bit anyway
|
||||||
|
QUIET="-q"
|
||||||
|
SILENT4CURL="-s"
|
||||||
|
SILENT4MAKE="-s"
|
||||||
|
if [ $DEBUG ] ; then
|
||||||
|
QUIET=
|
||||||
|
SILENT4CURL="-v"
|
||||||
|
SILENT4MAKE=
|
||||||
|
fi
|
||||||
|
# Make this null to get curl to check ssl cert
|
||||||
|
checkSSL="-k"
|
||||||
|
|
||||||
|
LOCALUser=${local_USER}
|
||||||
|
if [[ $smegit_WORKDIR == ~* ]] ; then
|
||||||
|
# relative to users home dir
|
||||||
|
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
|
||||||
|
else
|
||||||
|
# absolute path
|
||||||
|
WORKDIR=${smegit_WORKDIR}
|
||||||
|
fi
|
||||||
|
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
|
||||||
|
# create repo name from perl- module with :: replaced by -
|
||||||
|
IFS=::
|
||||||
|
words=()
|
||||||
|
for i in $MODULENAME; do words+=($i) ; done
|
||||||
|
RepoName="perl"
|
||||||
|
ShortName=
|
||||||
|
for word in ${words[@]}; do
|
||||||
|
RepoName="$RepoName-$word"
|
||||||
|
if [ $ShortName ] ; then
|
||||||
|
ShortName="$ShortName-$word"
|
||||||
|
else
|
||||||
|
ShortName="$word"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $DEBUG ] ; then echo "RepoName=$RepoName" ; fi
|
||||||
|
IFS="${IFS:0:3}"
|
||||||
|
RemoteRepoURL="$GITEAHOST/$ORGGITEA/$RepoName"
|
||||||
|
|
||||||
|
COMMONREPO=${smegit_COMMONREPO}
|
||||||
|
|
||||||
|
# Prepare variable for file in repo to indicate core or contrib.
|
||||||
|
# and init gitea organisation
|
||||||
|
# Adjust where we put the repo locally accordingly.
|
||||||
|
ORGGITEA="smeserver"
|
||||||
|
if [[ "$2" == "smecontribs" ]]; then
|
||||||
|
ORGGITEA=$2
|
||||||
|
BASEORCONTRIB="contribs10"
|
||||||
|
PRODUCTBUGZILLA="SME%20Contribs"
|
||||||
|
else
|
||||||
|
BASEORCONTRIB="sme10"
|
||||||
|
PRODUCTBUGZILLA="SME%20Server%2010.X"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Work out if it is an SMEServer package or a 3rd party one
|
||||||
|
PACKAGETYPE="3rd Party (Maintained by Koozali)"
|
||||||
|
|
||||||
|
# check that cpanspec is installed
|
||||||
|
if command -v cpanspec >/dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "************cpanspec is installed"; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************cpanspec is not installed*********** (try installing cpanspec)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check that git-lfs is installed
|
||||||
|
if command -v git-lfs > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Git LFS is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************** Git LFS is not installed ******************"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check that lua is installed (needed for change-log)
|
||||||
|
if command -v lua -V > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "************lua is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************** lua is not installed (try EPEL)**************"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# and check for the special scripts - changelog and BogusDateBot.sh - I think these are available in the
|
||||||
|
# mockbuild rpm, but beware Bug:12340 - changelog needs an edit to work!
|
||||||
|
if type -P change-log >/dev/null 2>&1; then
|
||||||
|
if [ $DEBUG ] ; then echo "************change-log is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************change-log is not installed*********** (try installing smeserver-mockbuild)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $DEBUG ] ; then echo "************..and also note bug:12340" ; fi
|
||||||
|
|
||||||
|
# Create work directories
|
||||||
|
cd $WORKDIR
|
||||||
|
perlFiles="$WORKDIR/$ORGGITEA/perl"
|
||||||
|
mkdir -p $perlFiles
|
||||||
|
|
||||||
|
# Make sure credentials taken from store
|
||||||
|
# The first time you pull or push it will ask for credentials and then save them in a file.
|
||||||
|
git config --global credential.helper store
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create the perl repository
|
||||||
|
#
|
||||||
|
cd $perlFiles
|
||||||
|
# First delete any existing module directory tree
|
||||||
|
# if there at all
|
||||||
|
if [ -d "$RepoName" ] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Deleting local CVS files" ; fi
|
||||||
|
rm -Rf $perlFiles/$RepoName
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Then get it fully from CVS
|
||||||
|
mkdir -p $perlFiles/$RepoName
|
||||||
|
cd $perlFiles/$RepoName
|
||||||
|
cpanspec "$MODULENAME"
|
||||||
|
|
||||||
|
# Check that the spec file is there
|
||||||
|
# First bet is the packagename.spec
|
||||||
|
SPECFILE=$RepoName.spec
|
||||||
|
ORIGSPECFILE=$SPECFILE
|
||||||
|
GOTONE=0
|
||||||
|
if [ ! -f $SPECFILE ] ; then
|
||||||
|
# See if it is a perl package which has the perl or perl-pear taken off the front
|
||||||
|
for front in "perl-" "perl-pear-" ; do
|
||||||
|
reg="^($front).*"
|
||||||
|
echo "$front $RepoName $reg"
|
||||||
|
if [[ "$RepoName" =~ $reg ]]; then
|
||||||
|
NEWNAME="${RepoName#$front}"
|
||||||
|
#echo $NEWNAME
|
||||||
|
SPECFILE="$NEWNAME.spec"
|
||||||
|
#echo $SPECFILE
|
||||||
|
if [ -f $SPECFILE ] ; then
|
||||||
|
GOTONE=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
GOTONE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $GOTONE -eq 0 ]] ; then
|
||||||
|
echo "Cannot find .spec file: `pwd`/$ORIGSPECFILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the tarball file extension
|
||||||
|
EXT=$(cat "$(basename $SPECFILE)" | grep -i ^Source | head -n 1 | sed -r 's/^[S|s]ource[0..9]?:\s?//' | xargs basename | sed -E 's/^([^.]*\.)(.*)$/\2/')
|
||||||
|
|
||||||
|
# Create the local Git repository
|
||||||
|
GITFiles=$WORKDIR/$ORGGITEA
|
||||||
|
mkdir -p $GITFiles
|
||||||
|
cd $GITFiles
|
||||||
|
|
||||||
|
# Delete the local first
|
||||||
|
if [ -d "$RepoName" ] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Deleting local GIT files" ; fi
|
||||||
|
rm -Rf $GITFiles/$RepoName
|
||||||
|
fi
|
||||||
|
|
||||||
|
# See if it exists on the Gitea host
|
||||||
|
if [ $DEBUG ] ; then echo "check that $GITEAHOST/$ORGGITEA/$RepoName exists" ; fi
|
||||||
|
RESPONSE=$(curl $checkSSL $SILENT4CURL -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$RepoName")
|
||||||
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Repository for $RepoName already exists!" ; fi
|
||||||
|
# Now delete the repo, re-create it and clone it in to local
|
||||||
|
if [ $DEBUG ] ; then echo "Delete $ORGGITEA/$RepoName" ; fi
|
||||||
|
RESPONSE=$(curl "$checkSSL" "$SILENT4CURL" -o /dev/null -w "%{http_code}" -X 'DELETE' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$ORGGITEA/$RepoName" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN")
|
||||||
|
if [[ $RESPONSE == "204" || $RESPONSE == "404" ]] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Repository $ORGGITEA/$RepoName deleted or does not exist" ; fi
|
||||||
|
else
|
||||||
|
echo "************Can NOT delete Repository $ORGGITEA/$RepoName - results will be unknown - Aborting!"
|
||||||
|
echo "RESPONSE=$RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Delete all files, links and directories
|
||||||
|
if [ $DEBUG ] ; then echo "************Deleting local GIT files" ; fi
|
||||||
|
cd $GITFiles
|
||||||
|
rm -Rf $GITFiles/$RepoName
|
||||||
|
else
|
||||||
|
if [ $DEBUG ] ; then echo "************Repository for $RepoName does not exist." ; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $GITFiles
|
||||||
|
|
||||||
|
#
|
||||||
|
# Re-create the repo
|
||||||
|
#
|
||||||
|
if [ $DEBUG ] ; then echo "************Creating repo for $RepoName $PACKAGETYPE" ; fi
|
||||||
|
RESPONSE=$(curl "$checkSSL" "$SILENT4CURL" -X 'POST' \
|
||||||
|
"$GITEAHOST/api/v1/orgs/$ORGGITEA/repos" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"auto_init": true,
|
||||||
|
"default_branch": "master",
|
||||||
|
"description": "'"$PACKAGETYPE git repo for $RepoName $ORGGITEA"'",
|
||||||
|
"gitignores": "",
|
||||||
|
"issue_labels": "Default",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"name": "'"$RepoName"'",
|
||||||
|
"private": false,
|
||||||
|
"readme": "Default",
|
||||||
|
"template": false,
|
||||||
|
"trust_model": "Default Trust Model"
|
||||||
|
}')
|
||||||
|
if [ $DEBUG ] ; then echo $RESPONSE ; fi
|
||||||
|
|
||||||
|
# And check it now exists
|
||||||
|
RESPONSE=$(curl "$SILENT4CURL" -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$RepoName")
|
||||||
|
if [[ "$RESPONSE" == "200" ]]; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Repository for $RepoName exists" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR*******Repository for $RepoName has not been created ($RESPONSE)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Tell repo to use koozali.org bugzilla and wiki - this does not work on CREATE currently - 19Apr2023
|
||||||
|
WIKILINK="https://wiki.koozali.org/$RepoName"
|
||||||
|
|
||||||
|
# and then update the repo parameters
|
||||||
|
RESPONSE=$(curl "$SILENT4CURL" -X 'PATCH' "$GITEAHOST/api/v1/repos/$ORGGITEA/$RepoName" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"external_tracker": {
|
||||||
|
"external_tracker_format": "https://bugs.koozali.org/show_bug.cgi?id={index}",
|
||||||
|
"external_tracker_style": "numeric",
|
||||||
|
"external_tracker_url": "'"https://bugs.koozali.org/buglist.cgi?component=$RepoName&product=$PRODUCTBUGZILLA"'"
|
||||||
|
},
|
||||||
|
"external_wiki": {
|
||||||
|
"external_wiki_url": "'"$WIKILINK"'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
')
|
||||||
|
# should check response here.
|
||||||
|
if [ $DEBUG ] ; then echo $RESPONSE ; fi
|
||||||
|
#exit 0
|
||||||
|
|
||||||
|
# Pull in the auto created or updated files
|
||||||
|
cd $GITFiles
|
||||||
|
git clone "$GITEAHOST/$ORGGITEA/$RepoName.git"
|
||||||
|
|
||||||
|
if [ ! -d $GITFiles/$RepoName ] ; then
|
||||||
|
echo "ERROR*******Unable to access the new repo directory for $GITFiles/$RepoName"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fully populate the directory (gets the tar file - which is not strictly in CVS) and creates the directory source tree
|
||||||
|
# applying the patches to the base in the tar file.
|
||||||
|
# Might need to replace this by the code from the makefile if we decide to move "make prep" to git moe likely we'll implement a new one "make gitprep".
|
||||||
|
cd $GITFiles/$RepoName
|
||||||
|
cp $perlFiles/$RepoName/* .
|
||||||
|
|
||||||
|
# create the Makefile
|
||||||
|
cat > Makefile <<- _EOT
|
||||||
|
# Makefile for source rpm: $RepoName
|
||||||
|
# \$Id: Makefile,v 1.1 2016/02/04 12:24:52 vip-ire Exp $
|
||||||
|
NAME := $RepoName
|
||||||
|
SPECFILE = \$(firstword \$(wildcard *.spec))
|
||||||
|
|
||||||
|
define find-makefile-common
|
||||||
|
for d in common ../common ../../common ; do if [ -f \$\$d/Makefile.common ] ; then if [ -f \$\$d/CVS/Root -a -w \$\$/Makefile.common ] ; then cd \$\$d ; cvs -Q update ; fi ; echo "\$\$d/Makefile.common" ; break ; fi ; done
|
||||||
|
endef
|
||||||
|
|
||||||
|
MAKEFILE_COMMON := \$(shell \$(find-makefile-common))
|
||||||
|
|
||||||
|
ifeq (\$(MAKEFILE_COMMON),)
|
||||||
|
# attept a checkout
|
||||||
|
define checkout-makefile-common
|
||||||
|
test -f CVS/Root && { cvs -Q -d \$\$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||||
|
endef
|
||||||
|
|
||||||
|
MAKEFILE_COMMON := \$(shell \$(checkout-makefile-common))
|
||||||
|
endif
|
||||||
|
|
||||||
|
include \$(MAKEFILE_COMMON)
|
||||||
|
_EOT
|
||||||
|
|
||||||
|
# Add file indicating which release and contribs or base - this is matched by the makefile with the contents of the branch file in the common directory
|
||||||
|
# to give the details of the release (EL7/8/9/ etc)
|
||||||
|
# This assumes SME10 and contribs10 or sme10 directory names, later releases can update the value in the file and Makefile should still work.
|
||||||
|
echo "sme11" > contriborbase
|
||||||
|
|
||||||
|
# and see if the spec file is not according to specification of <packagename>.spec
|
||||||
|
# if not rename it
|
||||||
|
if [[ $SPECFILE != $ORIGSPECFILE ]] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Renaming specfile from $(basename $SPECFILE) $(basename $ORIGSPECFILE)" ; fi
|
||||||
|
mv "$(basename $SPECFILE)" "$(basename $ORIGSPECFILE)"
|
||||||
|
SPECFILE=$ORIGSPECFILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
## and there may be extra files that maybe needed, these can be identified from the "Source" spec in the .spec files
|
||||||
|
SOURCES=$(grep -i -E '^Source[0-9]*:' $(basename $SPECFILE) | cut -d: -f2- | sed 's/ //g')
|
||||||
|
if [ $DEBUG ] ; then echo "$SOURCES" ; fi
|
||||||
|
|
||||||
|
#SOURCE=$(rpm --queryformat '$SOURCE\n' --specfile $SPECFILE | head -n 1)
|
||||||
|
for fpath in $SOURCES; do
|
||||||
|
# Needs another step incase the extraction from the spec file contains spec variables
|
||||||
|
fpathfile=$(basename $fpath)
|
||||||
|
if [ $DEBUG ] ; then echo "$fpathfile" ; fi
|
||||||
|
translatefpath=$(rpm --queryformat "$fpathfile\n" --specfile $(basename $SPECFILE) | head -n 1)
|
||||||
|
if [ $DEBUG ] ; then echo "$translatefpath" ; fi
|
||||||
|
if [[ -f $perlFiles/$RepoName/$translatefpath ]] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Copying $perlFiles/$RepoName/$translatefpath" ; fi
|
||||||
|
cp $perlFiles/$RepoName/$translatefpath .
|
||||||
|
else
|
||||||
|
if [ $DEBUG ] ; then echo "************Not found $perlFiles/$RepoName/$translatefpath ( $fpathfile )- so not copied" ; fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Take out the logs and rpms from the git save
|
||||||
|
echo "*.rpm" >> .gitignore
|
||||||
|
echo "*.log" >> .gitignore
|
||||||
|
# and the backed up spec file from BogusDateBot.sh
|
||||||
|
echo "*spec-20*" >>.gitignore
|
||||||
|
|
||||||
|
cd $GITFiles/$RepoName
|
||||||
|
# All perl packages are Third party packages
|
||||||
|
# copy over the archive file and make sure the extension is tracked by git-lfs
|
||||||
|
if [ $DEBUG ] ; then echo "************Found 3rd party package $NAME" ; fi
|
||||||
|
git lfs install
|
||||||
|
git lfs track "*.$EXT"
|
||||||
|
git add .gitattributes
|
||||||
|
if [[ -f $perlFiles/$RepoName/$ARCHIVEFILE ]] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Copying archivefile $perlFiles/$RepoName/$ARCHIVEFILE" ; fi
|
||||||
|
cp $perlFiles/$RepoName/$ARCHIVEFILE .
|
||||||
|
else
|
||||||
|
if [ $DEBUG ] ; then echo "Unable to find archivefile: $perlFiles/$RepoName/$ARCHIVEFILE - nothing copied" ; fi
|
||||||
|
fi
|
||||||
|
cd $GITFiles/$RepoName
|
||||||
|
|
||||||
|
# Add the BuildRequires now needed by el8(Rocky 8)
|
||||||
|
sed -i -e '/BuildRequires/{a\BuildRequires: perl(inc::Module::Install)' -e ':a;n;ba}' "$SPECFILE"
|
||||||
|
sed -i -e '/BuildRequires/{a\BuildRequires: perl(ExtUtils::Manifest)' -e ':a;n;ba}' "$SPECFILE"
|
||||||
|
|
||||||
|
# Re-factor the Common directory so that it is outside the repo being created.
|
||||||
|
# one Common directory for each Organisation
|
||||||
|
#
|
||||||
|
# See if it already exists
|
||||||
|
if [ ! -e $GITFiles/common ]; then
|
||||||
|
#Get it
|
||||||
|
cd $GITFiles
|
||||||
|
git clone "${smegit_COMMONREPO}"
|
||||||
|
if [ ! -e $GITFiles/common ]; then
|
||||||
|
echo "ERROR*******No Common Repo found - package $RepoName"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Just refresh it
|
||||||
|
cd $GITFiles/common
|
||||||
|
git pull $QUIET
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Edit the Readme.md - try to add the description from the spec file for this package
|
||||||
|
cd $GITFiles/$RepoName
|
||||||
|
DESCRIPTION=`rpm --queryformat '%{description}\n' --specfile $SPECFILE`
|
||||||
|
|
||||||
|
# create the README.md
|
||||||
|
cat > README.md <<- _EOT
|
||||||
|
# $RepoName ($MODULENAME)
|
||||||
|
|
||||||
|
SMEServer Koozali local git repo for $RepoName
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
https://metacpan.org/pod/$MODULENAME
|
||||||
|
|
||||||
|
## Bugs
|
||||||
|
CPAN bug report are [here](https://rt.cpan.org/Public/Dist/Display.html?Name=$ShortName)
|
||||||
|
|
||||||
|
Show list of Koozali outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=$RepoName&product=SME%20Server%2011.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
$DESCRIPTION
|
||||||
|
_EOT
|
||||||
|
|
||||||
|
cd $GITFiles/$RepoName
|
||||||
|
# stage and commit all the files created locally
|
||||||
|
git add -A
|
||||||
|
echo "$RepoName git status" >>gitstatus.log
|
||||||
|
git status >>gitstatus.log
|
||||||
|
if [ $DEBUG ] ; then git status ; fi
|
||||||
|
COMMENT="initial create of smeserver perl $MODULENAME on `date`"
|
||||||
|
git commit -m "$COMMENT" $QUIET
|
||||||
|
|
||||||
|
# push the converted git repository to the remote
|
||||||
|
git remote remove origin
|
||||||
|
git remote add origin "$GITEAHOST/$ORGGITEA/$RepoName.git"
|
||||||
|
git push --force -u $QUIET origin master
|
||||||
|
|
||||||
|
# Now create the version and release tag from the specfile
|
||||||
|
VERSION_RELEASE_LONG=`rpm --queryformat '%{version} %{release}\n' --specfile $SPECFILE`
|
||||||
|
VERSION_RELEASE=${VERSION_RELEASE_LONG%%$'\n'*}
|
||||||
|
VERSION=${VERSION_RELEASE% *}
|
||||||
|
VERSION=${VERSION//./_}
|
||||||
|
RELEASE=${VERSION_RELEASE#* }
|
||||||
|
TAG=$VERSION"-"${RELEASE%.*}
|
||||||
|
if [ $DEBUG ] ; then
|
||||||
|
echo "VERSION_RELEASE=$VERSION_RELEASE"
|
||||||
|
echo "VERSION=$VERSION"
|
||||||
|
echo "RELEASE=$RELEASE"
|
||||||
|
echo "TAG=$TAG"
|
||||||
|
fi
|
||||||
|
git pull
|
||||||
|
git tag -a $TAG -m "align tag with version and release from spec file: $TAG"
|
||||||
|
git push origin --tag $TAG $QUIET
|
||||||
|
|
||||||
|
|
||||||
|
echo "$COMMENT tag:$TAG"
|
||||||
|
exit 0
|
148
git-list-all-org-repos.sh
Executable file
148
git-list-all-org-repos.sh
Executable file
@@ -0,0 +1,148 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Pull in parameters from a ini file
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifilename or /etc/smegit.ini"
|
||||||
|
echo "git-list-all-org-repos.sh <organisation> [draftrelease | prerelease | release | allreleases] [cloneurl] [zipurl] [asseturls]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
inifilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
NOISY=
|
||||||
|
EXTRAPARAMS=
|
||||||
|
DEBUG=
|
||||||
|
for param in $2 $3 $4 $5 $6 $7 $8 $9 $10; do
|
||||||
|
if [ $param ] ; then
|
||||||
|
case $param in
|
||||||
|
local )
|
||||||
|
GITEAUser=${local_USER}
|
||||||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${local_GITEAHOST}
|
||||||
|
;;
|
||||||
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
noisy )
|
||||||
|
NOISY=true ;;
|
||||||
|
release )
|
||||||
|
SHOWRELEASE=true;SHOWPRERELEASE=false;SHOWDRAFT=false ;;
|
||||||
|
draftrelease )
|
||||||
|
SHOWRELEASE=true;SHOWPRERELEASE=false;SHOWDRAFT=true ;;
|
||||||
|
prerelease )
|
||||||
|
SHOWRELEASE=true;SHOWPRERELEASE=true;SHOWDRAFT=false ;;
|
||||||
|
allreleases )
|
||||||
|
SHOWRELEASE=true;SHOWALLRELEASES=true ;;
|
||||||
|
cloneurl )
|
||||||
|
SHOWCLONEURL=true ;;
|
||||||
|
zipurl )
|
||||||
|
SHOWZIPURL=true ;;
|
||||||
|
id )
|
||||||
|
SHOWID=true ;;
|
||||||
|
asseturls )
|
||||||
|
SHOWASSETURLS=true ;;
|
||||||
|
* )
|
||||||
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $1 ]] ; then
|
||||||
|
echo "git-list-all-org-repos.sh <organisation> [draftrelease | prerelease | release | allreleases] [cloneurl] [zipurl] [asseturls]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ORG_NAME="$1"
|
||||||
|
PAGE_COUNTER=1
|
||||||
|
REPO_LIST=""
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
REPO_PAGE=$(curl -s -H "Authorization: token $GITEAACCESSTOKEN" "$GITEAHOST/api/v1/orgs/$ORG_NAME/repos?page=$PAGE_COUNTER")
|
||||||
|
if [[ $(echo $REPO_PAGE | jq length) -eq 0 ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
REPO_LIST="$REPO_LIST $(echo $REPO_PAGE | jq -r .[].full_name | cut -d / -f 2 )"
|
||||||
|
PAGE_COUNTER=$((PAGE_COUNTER+1))
|
||||||
|
done
|
||||||
|
REPO_LIST=$(echo $REPO_LIST | tr -s '[:space:]' '\n' | sort)
|
||||||
|
for item in $REPO_LIST ; do
|
||||||
|
line=$item
|
||||||
|
if [[ $SHOWID || $SHOWRELEASE || $SHOWCLONEURL || $ZIPURL || $SHOWALLRELEASES ]] ; then
|
||||||
|
#Find and show releases
|
||||||
|
# echo "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=true&pre-release=true&limit=100" \
|
||||||
|
# -H 'accept: application/json' \
|
||||||
|
# -H "Authorization: token $GITEAACCESSTOKEN"
|
||||||
|
if [ $SHOWALLRELEASES ] ; then
|
||||||
|
RESPONSE=$(curl -s -X 'GET' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN");
|
||||||
|
else
|
||||||
|
RESPONSE=$(curl -s -X 'GET' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=$SHOWDRAFT&pre-release=$SHOWPRERELEASE&limit=100" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN");
|
||||||
|
fi
|
||||||
|
if [ $DEBUG ] ; then echo "$RESPONSE"; fi
|
||||||
|
if [ $SHOWRELEASE ] ; then
|
||||||
|
# Will need to use " jq 'map(.name)'" once we have more than one release.
|
||||||
|
REL=$(echo $RESPONSE | jq -r '.[0].tag_name')
|
||||||
|
ID=$(echo $RESPONSE | jq -r '.[0].id')
|
||||||
|
PRE=$(echo $RESPONSE | jq -r '.[0].prerelease')
|
||||||
|
DRAFT=$(echo $RESPONSE | jq -r '.[0].draft')
|
||||||
|
# Get assets - json for any files uploaded
|
||||||
|
ASSETS=$(echo $RESPONSE | jq -r '.[0].assets')
|
||||||
|
# Number of assets
|
||||||
|
NUMASSETS=$(echo $ASSETS | jq length)
|
||||||
|
if [ $DEBUG ]; then echo "Assets:$NUMASSETS"; fi
|
||||||
|
if [ $PRE = "true" ] ; then PRE="pre";
|
||||||
|
else PRE=""; fi
|
||||||
|
if [ $DRAFT = "true" ] ; then DRAFT="draft";
|
||||||
|
else DRAFT=""; fi
|
||||||
|
if [ $DEBUG ] ; then echo "pre:$PRE Draft:$DRAFT"; fi
|
||||||
|
if [ $DEBUG ] ; then echo $REL; fi
|
||||||
|
if [ "$REL" ] ; then line="$line $REL $ID $PRE $DRAFT $NUMASSETS"; fi
|
||||||
|
if [ $SHOWCLONEURL ] ; then
|
||||||
|
URL=$(echo $RESPONSE | jq -r '.[0].url')
|
||||||
|
if [ "$URL" ] ; then line="$line $URL"; fi
|
||||||
|
fi
|
||||||
|
if [ $SHOWZIPURL ] ; then
|
||||||
|
URL=$(echo $RESPONSE | jq -r '.[0].zipball_url')
|
||||||
|
if [ "$URL" ] ; then line="$line $URL"; fi
|
||||||
|
fi
|
||||||
|
if [[ $NUMASSETS -gt 0 && $SHOWASSETURLS ]]; then
|
||||||
|
ASSETURLS=$(echo $ASSETS | jq 'map("\(.name):\(.browser_download_url).")')
|
||||||
|
if [ $DEBUG ]; then echo "$ASSETURLS"; fi
|
||||||
|
# Turn the json into a list one on each line
|
||||||
|
ASSETURLS=$(echo $ASSETURLS | sed 's/\[//' | sed 's/\]//' | sed 's/,/\\n/g' | sed 's/\"//g')
|
||||||
|
line="$line\n$ASSETURLS";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo -e $line;
|
||||||
|
done
|
@@ -7,7 +7,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
if [[ -z $1 ]] ; then
|
if [[ -z $1 ]] ; then
|
||||||
echo "************make-release <modulename> <organization> <release> [local] [debug] [noisy]"
|
echo "git-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ if [ ! -e $inifilename ] ; then
|
|||||||
# Not here, look at system default
|
# Not here, look at system default
|
||||||
if [ ! -e /etc/smegit.ini ] ; then
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
echo "No ini file found $inifiename or /etc/smegit.ini"
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
echo "make-release <modulename> <organization> <release> [local] [debug] [noisy]"
|
echo "git-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
initfilename="/etc/smegit.ini"
|
initfilename="/etc/smegit.ini"
|
||||||
@@ -48,6 +48,8 @@ GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
|||||||
GITEAHOST=${remote_GITEAHOST}
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
NOISY=
|
NOISY=
|
||||||
EXTRAPARAMS=
|
EXTRAPARAMS=
|
||||||
|
MAKEPRE=false
|
||||||
|
MAKEDRAFT=false
|
||||||
for param in $4 $5 $6; do
|
for param in $4 $5 $6; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
case $param in
|
case $param in
|
||||||
@@ -60,6 +62,12 @@ for param in $4 $5 $6; do
|
|||||||
DEBUG=true ;;
|
DEBUG=true ;;
|
||||||
noisy )
|
noisy )
|
||||||
NOISY=true ;;
|
NOISY=true ;;
|
||||||
|
draft )
|
||||||
|
MAKEDRAFT=true ;;
|
||||||
|
prerelease )
|
||||||
|
MAKEPRE=true ;;
|
||||||
|
draftpre )
|
||||||
|
MAKEPRE=true;MAKEDRAFT=true ;;
|
||||||
* )
|
* )
|
||||||
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
esac
|
esac
|
||||||
@@ -68,6 +76,7 @@ for param in $4 $5 $6; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $DEBUG ] ; then echo "draft:$MAKEDRAFT*pre:$MAKEPRE"; fi
|
||||||
#check for release tag
|
#check for release tag
|
||||||
if [ -z $3 ]; then
|
if [ -z $3 ]; then
|
||||||
echo "Release tag not set";
|
echo "Release tag not set";
|
||||||
@@ -101,7 +110,7 @@ RemoteRepoURL="$GITEAHOST/$2/$1"
|
|||||||
if [ $DEBUG ] ; then echo "URL="$RemoteRepoURL; fi
|
if [ $DEBUG ] ; then echo "URL="$RemoteRepoURL; fi
|
||||||
|
|
||||||
# First see if release exists:
|
# First see if release exists:
|
||||||
RESPONSE=$(curl -X 'GET' \
|
RESPONSE=$(curl -s -X 'GET' \
|
||||||
"$GITEAHOST/api/v1/repos/$2/$1/releases/tags/SME$3" \
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/tags/SME$3" \
|
||||||
-H 'accept: application/json')
|
-H 'accept: application/json')
|
||||||
if [ $DEBUG ] ; then echo "See if Release exists response="$RESPONSE; fi
|
if [ $DEBUG ] ; then echo "See if Release exists response="$RESPONSE; fi
|
||||||
@@ -127,21 +136,56 @@ fi
|
|||||||
if [[ -z "$ID" ]]; then
|
if [[ -z "$ID" ]]; then
|
||||||
# Create Release
|
# Create Release
|
||||||
if [ $NOISY ]; then echo "Creating Release $3 for $2/$1"; fi
|
if [ $NOISY ]; then echo "Creating Release $3 for $2/$1"; fi
|
||||||
RESPONSE=$(curl -X 'POST' \
|
# 3 branches 'cos I can't get the ascaping correct for using $MAKEPRE and $MAKEDRAFT in the -d json parameter to curl!
|
||||||
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
|
if [ $MAKEDRAFT = "true" ]; then
|
||||||
-H 'accept: application/json' \
|
if [ $DEBUG ] ; then echo "$MAKEDRAFT:Creating draft release"; fi
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
RESPONSE=$(curl -s -X 'POST' \
|
||||||
-H 'Content-Type: application/json' \
|
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
|
||||||
-d '{
|
-H 'accept: application/json' \
|
||||||
"body": "'"1st Release of rpm built from git - `date` "'",
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
"draft": true,
|
-H 'Content-Type: application/json' \
|
||||||
"name": "'"$1"'",
|
-d '{
|
||||||
"prerelease": true,
|
"body": "'"1st Draft Release of rpm built from git - `date` "'",
|
||||||
"tag_name": "'SME"$3"'",
|
"draft": true,
|
||||||
"target_commitish": ""
|
"name": "'"$1"'",
|
||||||
}')
|
"prerelease": false,
|
||||||
|
"tag_name": "'SME"$3"'",
|
||||||
|
"target_commitish": ""}'
|
||||||
|
);
|
||||||
|
elif [ $MAKEPRE = "true" ]; then
|
||||||
|
if [ $DEBUG ] ; then echo "Creating pre-release"; fi
|
||||||
|
RESPONSE=$(curl -s -X 'POST' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"body": "'"1st Pre-Release of rpm built from git - `date` "'",
|
||||||
|
"draft": false,
|
||||||
|
"name": "'"$1"'",
|
||||||
|
"prerelease": true,
|
||||||
|
"tag_name": "'SME"$3"'",
|
||||||
|
"target_commitish": ""}'
|
||||||
|
);
|
||||||
|
else
|
||||||
|
if [ $DEBUG ] ; then echo "Creating full release"; fi
|
||||||
|
RESPONSE=$(curl -s -X 'POST' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"body": "'"1st Stable Release of rpm built from git - `date` "'",
|
||||||
|
"draft": false,
|
||||||
|
"name": "'"$1"'",
|
||||||
|
"prerelease": false,
|
||||||
|
"tag_name": "'SME"$3"'",
|
||||||
|
"target_commitish": ""}'
|
||||||
|
);
|
||||||
|
fi
|
||||||
# Extract id from release
|
# Extract id from release
|
||||||
if [ $DEBUG ]; then echo "Create Release response="$RESPONSE; fi
|
if [ $DEBUG ]; then echo "Create Release response="$RESPONSE; fi
|
||||||
|
exit 0
|
||||||
ID=$(echo $RESPONSE | jq -r '.id')
|
ID=$(echo $RESPONSE | jq -r '.id')
|
||||||
if [[ -z $ID ]] ; then
|
if [[ -z $ID ]] ; then
|
||||||
echo "Unable to create release for $2/$1 ($3)"
|
echo "Unable to create release for $2/$1 ($3)"
|
||||||
@@ -158,7 +202,7 @@ cd $WORKDIR/$2/$1
|
|||||||
RPMDIR=$(ls $(basename `pwd`)*.rpm | sort | head -n 1 | sed 's/.src.rpm//' | sed 's/\./_/g')
|
RPMDIR=$(ls $(basename `pwd`)*.rpm | sort | head -n 1 | sed 's/.src.rpm//' | sed 's/\./_/g')
|
||||||
echo $RPMDIR
|
echo $RPMDIR
|
||||||
# List the existing attachments
|
# List the existing attachments
|
||||||
ASSETSRESPONSE=$(curl -X 'GET' \
|
ASSETSRESPONSE=$(curl -s -X 'GET' \
|
||||||
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets" \
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets" \
|
||||||
-H 'accept: application/json')
|
-H 'accept: application/json')
|
||||||
if [ $DEBUG ]; then echo "Asset response:"$ASSETSRESPONSE; fi
|
if [ $DEBUG ]; then echo "Asset response:"$ASSETSRESPONSE; fi
|
||||||
@@ -179,7 +223,7 @@ for File in $(ls $RPMDIR/*.rpm) ; do
|
|||||||
#echo "ATTID:"$ATTID
|
#echo "ATTID:"$ATTID
|
||||||
ATTID=$(echo $ATTID | sed 's/\[//' | sed 's/\]//' | sed 's/ //g')
|
ATTID=$(echo $ATTID | sed 's/\[//' | sed 's/\]//' | sed 's/ //g')
|
||||||
if [ $DEBUG ]; then echo "ATTID:"$ATTID; fi
|
if [ $DEBUG ]; then echo "ATTID:"$ATTID; fi
|
||||||
RESPONSE=$(curl -X 'DELETE' \
|
RESPONSE=$(curl -s -X 'DELETE' \
|
||||||
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets/$ATTID" \
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets/$ATTID" \
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
-H 'accept: application/json')
|
-H 'accept: application/json')
|
||||||
@@ -190,12 +234,12 @@ for File in $(ls $RPMDIR/*.rpm) ; do
|
|||||||
echo "Delete failed $BASEFile from $2/$1 $3 ($ID) release ($RESPONSE)"
|
echo "Delete failed $BASEFile from $2/$1 $3 ($ID) release ($RESPONSE)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Did not find $BASEFile in \"$NAMES\""
|
if [ $DEBUG ]; then echo "Did not find $BASEFile in \"$NAMES\""; fi
|
||||||
fi
|
fi
|
||||||
# Then send current version
|
# Then send current version
|
||||||
FULLFILENAME=$FULLPATH/$File
|
FULLFILENAME=$FULLPATH/$File
|
||||||
if [ $DEBUG ] ; then echo $FULLFILENAME; fi
|
if [ $DEBUG ] ; then echo $FULLFILENAME; fi
|
||||||
RESPONSE=$(curl -X 'POST' \
|
RESPONSE=$(curl -s -X 'POST' \
|
||||||
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets?name=$BASEFile" \
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets?name=$BASEFile" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
@@ -50,7 +50,7 @@ SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
|||||||
TARGETHOST=${local_GITEAHOST}
|
TARGETHOST=${local_GITEAHOST}
|
||||||
TARGETACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
TARGETACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
TARGETORG=${local_USER}
|
TARGETORG=${local_USER}
|
||||||
MIRROR=
|
MIRROR=false
|
||||||
for param in $2 $3 $4 $5 $6; do
|
for param in $2 $3 $4 $5 $6; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
case $param in
|
case $param in
|
||||||
@@ -60,7 +60,7 @@ for param in $2 $3 $4 $5 $6; do
|
|||||||
CLONEADDRESS=$LOCALGITEAHOST/$2/$1.git
|
CLONEADDRESS=$LOCALGITEAHOST/$2/$1.git
|
||||||
;;
|
;;
|
||||||
copy )
|
copy )
|
||||||
MIRROR=
|
MIRROR=false
|
||||||
;;
|
;;
|
||||||
mirror )
|
mirror )
|
||||||
MIRROR=true ;;
|
MIRROR=true ;;
|
||||||
|
176
git-retag.sh
Executable file
176
git-retag.sh
Executable file
@@ -0,0 +1,176 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# $1 = Module name e.g. smeserver-ddclient
|
||||||
|
# $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
|
||||||
|
# <purge> will purge all old tags
|
||||||
|
# <debug> turn on debug regardless of ~/.smegit/config
|
||||||
|
# <noisy> print a line showing how it was called
|
||||||
|
# Module name must exist
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ -z $1 ]] ; then
|
||||||
|
echo "************git-retag.sh <modulename> <organization> [<local> | <purge> | <debug> | <noisy>]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Needs /usr/bin/rpmspec
|
||||||
|
if command -v /usr/bin/rpmspec > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "************rpmspec is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "ERROR********************** rpmspec is not installed ******************"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
echo "git-retag.sh <modulename> <organization> [<local> | <purge> | <debug> | <noisy>]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
DEBUG=
|
||||||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
|
|
||||||
|
REPO_NAME=$1
|
||||||
|
ORGGITEA=$2
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
NOISY=
|
||||||
|
CLEAN=
|
||||||
|
EXTRAPARAMS=
|
||||||
|
for param in $3 $4 $5 $6 ; do
|
||||||
|
if [ $param ] ; then
|
||||||
|
case $param in
|
||||||
|
local )
|
||||||
|
GITEAUser=${local_USER}
|
||||||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${local_GITEAHOST}
|
||||||
|
;;
|
||||||
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
noisy )
|
||||||
|
NOISY=true ;;
|
||||||
|
purge )
|
||||||
|
CLEAN=true ;;
|
||||||
|
* )
|
||||||
|
echo "Unkown parameter: $param"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $NOISY ] ; then echo "git-retag.sh $1 $2 $3 $4 $5 $6" ; fi
|
||||||
|
if [ $DEBUG ] ; then echo "************found ini file: $inifilename" ; fi
|
||||||
|
# Make this null if you want lots of output. Still quite a bit anyway
|
||||||
|
QUIET="-q"
|
||||||
|
SILENT4CURL="-s"
|
||||||
|
SILENT4MAKE="-s"
|
||||||
|
if [ $DEBUG ] ; then
|
||||||
|
QUIET=
|
||||||
|
SILENT4CURL="-v"
|
||||||
|
SILENT4MAKE=
|
||||||
|
fi
|
||||||
|
# Make this null to get curl to check ssl cert
|
||||||
|
checkSSL="-k"
|
||||||
|
|
||||||
|
LOCALUser=${local_USER}
|
||||||
|
if [[ $smegit_WORKDIR == ~* ]] ; then
|
||||||
|
# relative to users home dir
|
||||||
|
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
|
||||||
|
else
|
||||||
|
# absolute path
|
||||||
|
WORKDIR=${smegit_WORKDIR}
|
||||||
|
fi
|
||||||
|
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
|
||||||
|
RemoteRepoURL="$GITEAHOST/$ORGGITEA/$REPO_NAME"
|
||||||
|
|
||||||
|
# Make sure credentials taken from store
|
||||||
|
# The first time you pull or push it will ask for credentials and then save them in a file.
|
||||||
|
git config --global credential.helper store
|
||||||
|
|
||||||
|
# Create the local Git repository
|
||||||
|
GITFiles=$WORKDIR/$ORGGITEA
|
||||||
|
mkdir -p $GITFiles
|
||||||
|
cd $GITFiles
|
||||||
|
|
||||||
|
# Delete the local first
|
||||||
|
if [ -d "$REPO_NAME" ] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Deleting local GIT files" ; fi
|
||||||
|
rm -Rf $GITFiles/$REPO_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# See if it exists on the Gitea host
|
||||||
|
if [ $DEBUG ] ; then echo "check that $GITEAHOST/$ORGGITEA/$REPO_NAME exists" ; fi
|
||||||
|
RESPONSE=$(curl $checkSSL $SILENT4CURL -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME")
|
||||||
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
|
if [ $DEBUG ] ; then echo "************Repository for $REPO_NAME exists, cloning!" ; fi
|
||||||
|
# If so, clone it (just want the README.md)
|
||||||
|
if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$ORGGITEA/$REPO_NAME.git" ; fi
|
||||||
|
cd $GITFiles
|
||||||
|
git clone "$GITEAHOST/$ORGGITEA/$REPO_NAME.git"
|
||||||
|
else
|
||||||
|
echo "************Repository for $ORGGITEA/$REPO_NAME does not exist. Aborting $RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $GITFiles/$REPO_NAME
|
||||||
|
if [ $CLEAN ] ; then
|
||||||
|
# read the existing tags
|
||||||
|
OLDTAGS=$(git tag --list)
|
||||||
|
# delete old tag/s
|
||||||
|
for tag in $OLDTAGS ; do
|
||||||
|
if [ $DEBUG ] ; then echo "Removing tag $tag" ; fi
|
||||||
|
git tag --delete $tag
|
||||||
|
git push origin --delete $tag
|
||||||
|
git push --tags
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# Now create the version and release tag from the specfile
|
||||||
|
VERSION_RELEASE_LONG=`rpm --queryformat '%{version} %{release}\n' --specfile $REPO_NAME.spec`
|
||||||
|
VERSION_RELEASE=${VERSION_RELEASE_LONG%%$'\n'*}
|
||||||
|
VERSION=${VERSION_RELEASE% *}
|
||||||
|
VERSION=${VERSION//./_}
|
||||||
|
RELEASE=${VERSION_RELEASE#* }
|
||||||
|
TAG=$VERSION"-"${RELEASE%.*}
|
||||||
|
if [ $DEBUG ] ; then
|
||||||
|
echo "VERSION_RELEASE=$VERSION_RELEASE"
|
||||||
|
echo "VERSION=$VERSION"
|
||||||
|
echo "RELEASE=$RELEASE"
|
||||||
|
echo "TAG=$TAG"
|
||||||
|
fi
|
||||||
|
git pull
|
||||||
|
git tag -a $TAG -m "Setting tag to current Version-Release in spec file: $TAG"
|
||||||
|
git push origin --tag $TAG $QUIET
|
||||||
|
|
||||||
|
echo "Current $ORGGITEA/$REPO_NAME tagged as $TAG"
|
||||||
|
if [ $CLEAN ] ; then echo " - old tags removed" ; fi
|
||||||
|
exit 0
|
121
git-update-release-in-one-repo.sh
Executable file
121
git-update-release-in-one-repo.sh
Executable file
@@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release]
|
||||||
|
#
|
||||||
|
# Create the release (deleting one that is the same tag),
|
||||||
|
# then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
if [[ -z $1 ]] ; then
|
||||||
|
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $4 ]] ; then
|
||||||
|
echo "Must provide release type"
|
||||||
|
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
|
||||||
|
DEBUG=
|
||||||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
for param in $2 $3 $4 $5 $6 $7; do
|
||||||
|
if [ $param ] ; then
|
||||||
|
case $param in
|
||||||
|
local )
|
||||||
|
GITEAUser=${local_USER}
|
||||||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${local_GITEAHOST}
|
||||||
|
;;
|
||||||
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
* )
|
||||||
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Uses if ist char is numeric to see if an id or tag is provided
|
||||||
|
if [[ ! "${3:0:1}" =~ [0-9] ]]; then
|
||||||
|
# <organisation> <repo> <releasetag> - find the id from the info provided
|
||||||
|
ID=999;
|
||||||
|
# TBD
|
||||||
|
else
|
||||||
|
ID=$3;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $DEBUG ]; then echo "I:$ID"; fi
|
||||||
|
|
||||||
|
# And then edit it by id.
|
||||||
|
|
||||||
|
if [ $4 = "draft" ]; then
|
||||||
|
RESPONSE=$(curl -s -X 'PATCH' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"draft": true,
|
||||||
|
"prerelease": false
|
||||||
|
}')
|
||||||
|
elif [ $4 = "prerelease" ]; then
|
||||||
|
RESPONSE=$(curl -s -X 'PATCH' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": true
|
||||||
|
}')
|
||||||
|
else
|
||||||
|
RESPONSE=$(curl -s -X 'PATCH' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}')
|
||||||
|
fi
|
||||||
|
if [ $DEBUG ]; then echo "$RESPONSE"; fi
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
194
github-make-push-mirror.sh
Executable file
194
github-make-push-mirror.sh
Executable file
@@ -0,0 +1,194 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# $1 = Module name e.g. smeserver-ddclient (assumes github repo is to be called the same)
|
||||||
|
# $2 = gitea Organisation (smeserver or smecontrib)
|
||||||
|
# $3 = github Organisation (Koozali-SME-Server or Koozali-SME-Server-contribs or smeserver)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Make this null to get curl to check ssl cert
|
||||||
|
checkSSL="-k"
|
||||||
|
# and -v for curl verbose mode
|
||||||
|
SILENT4CURL="-s"
|
||||||
|
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
echo "Error: github-make-push-mirror.sh <modulename> <organization> <github orgamisation>"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check that jq is installed
|
||||||
|
if command -v jq -V > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "Jq is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "Error: jq is not installed (try EPEL)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#check gh is loaded
|
||||||
|
if command -v gh --version > /dev/null; then
|
||||||
|
if [ $DEBUG ] ; then echo "gh is installed" ; fi
|
||||||
|
else
|
||||||
|
echo "Error: gh is not installed **************"
|
||||||
|
echo "try: curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo | sudo tee /etc/yum.repos.d/github-cli.repo"
|
||||||
|
echo "then:sudo dnf -y install gh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Pull in parameters from a config file ~/.smegit/config
|
||||||
|
#
|
||||||
|
inifilename=$(echo ~)"/.smegit/config"
|
||||||
|
if [ ! -e $inifilename ] ; then
|
||||||
|
# Not here, look at system default
|
||||||
|
if [ ! -e /etc/smegit.ini ] ; then
|
||||||
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
initfilename="/etc/smegit.ini"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
|
if [[ $line =~ ^\[.*\]$ ]]
|
||||||
|
then
|
||||||
|
section=${line#*[}
|
||||||
|
section=${section%]*}
|
||||||
|
else
|
||||||
|
if [[ $line =~ ^[^#]*= ]]
|
||||||
|
then
|
||||||
|
key=${line%=*}
|
||||||
|
value=${line#*=}
|
||||||
|
declare "${section}_${key}=$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$inifilename"
|
||||||
|
|
||||||
|
GITEAUser=${remote_USER}
|
||||||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
|
||||||
|
#First check repo name exists in gitea
|
||||||
|
REPO_NAME=$1
|
||||||
|
RESPONSE=$(curl $checkSSL $SILENT4CURL -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$2/$REPO_NAME")
|
||||||
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
|
echo "$2/$1 exists in GITEA"
|
||||||
|
else
|
||||||
|
echo "Error: $2/$1 does not exists in GITEA"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# and that the github token has been installed in the .smegit file
|
||||||
|
# Note that this personal access token is generated by github against a particular login
|
||||||
|
GITHUBLOGIN=${remote_GITHUBLOGIN}
|
||||||
|
if [ -z "${remote_GITHUBTOKEN}" ]; then
|
||||||
|
echo "Error: The GITHUBTOKEN is not defined in .smegit/config ."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#and check that github is logged in
|
||||||
|
if ! gh auth status > /dev/null 2>&1; then
|
||||||
|
echo "You must log in with GitHub CLI first."
|
||||||
|
echo "Run 'gh auth login' and follow the instructions."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# first create repo on github or skip over if already created
|
||||||
|
REPO_NAME=$3/$1
|
||||||
|
DESCRIPTION="Repo-$1 - push mirror from Koozali gitea repo $1"
|
||||||
|
|
||||||
|
# Create the repository
|
||||||
|
|
||||||
|
# Check if the repository exists
|
||||||
|
repo_exists=$(gh repo view "$REPO_NAME" > /dev/null 2>&1)
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "The repository '$REPO_NAME' already exists."
|
||||||
|
else
|
||||||
|
echo "Creating GitHub repository '$REPO_NAME'..."
|
||||||
|
gh repo create "$REPO_NAME" --description "$DESCRIPTION" --public
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "GitHub Repository '$REPO_NAME' created successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to create repository '$REPO_NAME'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Now update the equivalent gitea repo to push to the github one.
|
||||||
|
GITHUB_REPO_URL="https://github.com/$3/$1.git"
|
||||||
|
|
||||||
|
# API endpoint to create a push mirror
|
||||||
|
API_ENDPOINT="${remote_GITEAHOST}/api/v1/repos/${2}/${1}/push_mirrors"
|
||||||
|
|
||||||
|
# See if the push mirror exists already
|
||||||
|
# Fetch repository mirror settings using the Gitea API
|
||||||
|
response=$(curl $checkSSL $SILENT4CURL -s -H "Authorization: token ${remote_GITEAACCESSTOKEN}" \
|
||||||
|
"$API_ENDPOINT")
|
||||||
|
|
||||||
|
if [ -z "$response" ]; then
|
||||||
|
echo "Failed to fetch mirror settings from Gitea."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if there are any push mirrors
|
||||||
|
push_mirrors=$(echo "$response" | jq -r '.[] | select(.sync_on_commit == true)')
|
||||||
|
|
||||||
|
if [ -z "$push_mirrors" ]; then
|
||||||
|
echo "No push mirror configurations found for the repository '$2/$1'."
|
||||||
|
else
|
||||||
|
echo "Push mirror configurations found for the repository '$2/$1:"
|
||||||
|
#echo "$push_mirrors" | jq
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if one of them is the one to github
|
||||||
|
github_mirror=$(echo "$response" | jq -r --arg address "${GITHUB_REPO_URL}" '.[] | select(.remote_address == $address)')
|
||||||
|
if [ -z "$github_mirror" ]; then
|
||||||
|
echo "No push mirror configuration with remote address '${GITHUB_REPO_URL}' found for the repository '$REPO_NAME'."
|
||||||
|
else
|
||||||
|
echo "Push mirror configuration with remote address '${GITHUB_REPO_URL}' found for the repository '$REPO_NAME':"
|
||||||
|
echo "$github_mirror" | jq
|
||||||
|
remote_name=$(echo "$github_mirror" | jq -r '.remote_name')
|
||||||
|
echo "Deleting this push mirror entry with remote_name: $remote_name"
|
||||||
|
# Delete the mirror using the mirror ID
|
||||||
|
delete_response=$(curl $checkSSL $SILENT4CURL -s -X DELETE -H "Authorization: token ${remote_GITEAACCESSTOKEN}" \
|
||||||
|
"$API_ENDPOINT/$remote_name")
|
||||||
|
if [ -z "$delete_response" ]; then
|
||||||
|
echo "Successfully deleted the mirror with remote name '$remote_name'."
|
||||||
|
else
|
||||||
|
echo "Failed to delete the mirror with remote name '$remote_name'. Response: $delete_response"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# JSON payload to be sent to the Gitea API to create the push mirrir
|
||||||
|
MIRROR_PAYLOAD=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"interval" : "8h0m0s",
|
||||||
|
"remote_address": "${GITHUB_REPO_URL}",
|
||||||
|
"remote_username": "${GITHUBLOGIN}",
|
||||||
|
"remote_password": "${remote_GITHUBTOKEN}",
|
||||||
|
"sync_on_commit" : true
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the push mirror
|
||||||
|
response=$(curl $checkSSL $SILENT4CURL -s -w "\nHTTP_STATUS_CODE:%{http_code}" -X POST "$API_ENDPOINT" \
|
||||||
|
-H "Authorization: token ${remote_GITEAACCESSTOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$MIRROR_PAYLOAD")
|
||||||
|
|
||||||
|
# Extract the response and HTTP status code
|
||||||
|
echo "Creating the push mirror for $2/$1 to $3/$1"
|
||||||
|
body=$(echo "$response" | sed -n '1,/HTTP_STATUS_CODE:/p' | sed '$d')
|
||||||
|
status_code=$(echo "$response" | grep "HTTP_STATUS_CODE:" | awk -F ':' '{print $2}')
|
||||||
|
|
||||||
|
# Evaluate the response
|
||||||
|
if [[ "$status_code" -ge 200 && "$status_code" -lt 300 ]]; then
|
||||||
|
echo "Successfully set up push mirror from Gitea repository to GitHub for $2/$1 to $3/$1."
|
||||||
|
else
|
||||||
|
echo "Failed to set up push mirror. HTTP Status Code: $status_code"
|
||||||
|
echo "Response: $body"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
@@ -1,370 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Rename an e-smith package as smeserver and change relevant files
|
|
||||||
# Will migrate a repository from the source organisation into your work area and rename it as smeserver and do all changes there.
|
|
||||||
# If transfer is specified it will then transfer the new repository to the source organisation (you MUST be an owner to fo this)
|
|
||||||
# $1 = Module name e.g. e-smith-dnscache
|
|
||||||
# $2-$5 can appear in any order and are optional
|
|
||||||
# = Organisation (smeserver or user - defaults to smeserver)
|
|
||||||
# = "local" will use parameters set for local repository else it will use remote
|
|
||||||
# = "force" will automagically delete an existing repo, otherwise it will prompt
|
|
||||||
# = "transfer" will push completed package into source organisation (other wise leave in your area)
|
|
||||||
# = "debug" run in debug mode
|
|
||||||
# = "silent" suppress success message
|
|
||||||
# This works whether the repo and local files exist of not (it deletes them if necessary)
|
|
||||||
#
|
|
||||||
|
|
||||||
if [[ -z $1 ]] ; then
|
|
||||||
echo "Rename an e-smith package as smeserver and change relevant files"
|
|
||||||
echo "rename-e-smith-pkg.sh <modulename> [<organization> <local> <force> <transfer> <debug> <silent>]"
|
|
||||||
echo "<modulename> = Module/package name (e.g. e-smith-dnscache)"
|
|
||||||
echo " can appear in any order and are optional"
|
|
||||||
echo " - <organisation> (any valid organisation - defaults to smeserver)"
|
|
||||||
echo " - <local> will use parameters set for local repository, else it will use remote"
|
|
||||||
echo " - <force> will automagically delete an existing repo, otherwise it will prompt"
|
|
||||||
echo " - <transfer> will push completed package into source organisation (other wise leave in your area)"
|
|
||||||
echo " - <debug> run in debug mode"
|
|
||||||
echo " - <silent> suppress success message"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Pull in parameters from a config file ~/.smegit/config
|
|
||||||
#
|
|
||||||
inifilename=$(echo ~)"/.smegit/config"
|
|
||||||
if [ ! -e $inifilename ] ; then
|
|
||||||
# Not here, look at system default
|
|
||||||
if [ ! -e /etc/smegit.ini ] ; then
|
|
||||||
echo "No ini file found $inifiename or /etc/smegit.ini"
|
|
||||||
echo "git-cvs2git.sh <modulename> <organization> [<local>]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
initfilename="/etc/smegit.ini"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
while read -r line || [[ -n "$line" ]]; do
|
|
||||||
if [[ $line =~ ^\[.*\]$ ]]
|
|
||||||
then
|
|
||||||
section=${line#*[}
|
|
||||||
section=${section%]*}
|
|
||||||
else
|
|
||||||
if [[ $line =~ ^[^#]*= ]]
|
|
||||||
then
|
|
||||||
key=${line%=*}
|
|
||||||
value=${line#*=}
|
|
||||||
declare "${section}_${key}=$value"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done < "$inifilename"
|
|
||||||
DEBUG=
|
|
||||||
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
|
||||||
if [ $DEBUG ] ; then echo "************found ini file: $inifilename" ; fi
|
|
||||||
|
|
||||||
if [[ $smegit_WORKDIR == ~* ]] ; then
|
|
||||||
# relative to users home dir
|
|
||||||
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
|
|
||||||
else
|
|
||||||
# absolute path
|
|
||||||
WORKDIR=${smegit_WORKDIR}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Command line parameters
|
|
||||||
#Extract <pkg>
|
|
||||||
SOURCEPKG=$1
|
|
||||||
TARGETPKG=${SOURCEPKG/e-smith/smeserver}
|
|
||||||
|
|
||||||
GITEAHOST=${remote_GITEAHOST}
|
|
||||||
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
|
||||||
SOURCEORG="smeserver"
|
|
||||||
TARGETORG=${remote_USER}
|
|
||||||
DELETEIT=
|
|
||||||
NOOUTPUT=
|
|
||||||
TRANSFER=
|
|
||||||
for param in $2 $3 $4 $5 $6; do
|
|
||||||
if [ $param ] ; then
|
|
||||||
case $param in
|
|
||||||
local )
|
|
||||||
GITEAHOST=${local_GITEAHOST}
|
|
||||||
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
|
||||||
TARGETORG=${local_USER} ;;
|
|
||||||
force )
|
|
||||||
DELETEIT=true ;;
|
|
||||||
debug )
|
|
||||||
DEBUG=true ;;
|
|
||||||
silent )
|
|
||||||
NOOUTPUT=true ;;
|
|
||||||
transfer )
|
|
||||||
TRANSFER=true ;;
|
|
||||||
* )
|
|
||||||
SOURCEORGORG=$param ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Debug settings
|
|
||||||
# Make this null if you want lots of output. Still quite a bit anyway
|
|
||||||
QUIET="--quiet"
|
|
||||||
SILENT="-s"
|
|
||||||
if [ $DEBUG ] ; then
|
|
||||||
QUIET=
|
|
||||||
SILENT="-v"
|
|
||||||
fi
|
|
||||||
# Make this null to get curl to check ssl cert
|
|
||||||
checkSSL="-k"
|
|
||||||
|
|
||||||
#Check that source package exists
|
|
||||||
if [ $DEBUG ] ; then echo "Check if $SOURCEORG/$SOURCEPKG is there!" ; fi
|
|
||||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG")
|
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
|
||||||
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$SOURCEPKG exists!" ; fi
|
|
||||||
else
|
|
||||||
echo "************Repository for $SOURCEORG/$SOURCEPKG does not exist on $GITEAHOST ($RESPONSE)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Check that target package does not exist
|
|
||||||
if [ $DEBUG ] ; then echo "Check if $TARGETORG/$TARGETPKG is there!" ; fi
|
|
||||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG")
|
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
|
||||||
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG exists!" ; fi
|
|
||||||
if [ -z ${DELETEIT} ] ; then
|
|
||||||
while true; do
|
|
||||||
read -p "Do you wish to delete it and continue?(y/n) " yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* )
|
|
||||||
DELETEIT=true
|
|
||||||
break ;;
|
|
||||||
[Nn]* )
|
|
||||||
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $GITEAHOST ($RESPONSE)"
|
|
||||||
exit 1 ;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ $DELETEIT ] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "Deleting $TARGETORG/$TARGETPKG" ; fi
|
|
||||||
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
|
|
||||||
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" )
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $GITEAHOST" ; fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Fork e-smith-<pkg> into users repositories as smeserver-<pkg>
|
|
||||||
# - add bugzilla and wiki references
|
|
||||||
|
|
||||||
# create a Bugzilla URL
|
|
||||||
PRODUCTBUGZILLA="SME%20Server%2010.X"
|
|
||||||
BASEORCONTRIB="base"
|
|
||||||
if [[ "$SOURCEORG" == "smecontribs" ]]; then
|
|
||||||
PRODUCTBUGZILLA="SME%20Contribs"
|
|
||||||
BASEORCONTRIB="contrib"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# migrate the source package over to target with updated fields
|
|
||||||
if [ $DEBUG ] ; then echo "Migrating $SOURCEORG/$SOURCEPKG as $TARGETORG/$TARGETPKG on $GITEAHOST" ; fi
|
|
||||||
RESPONSE=$(curl $SILENT $checkSSL -o /dev/null -w "%{http_code}" -X 'POST' \
|
|
||||||
"$GITEAHOST/api/v1/repos/migrate" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"auth_token": "'"$GITEAACCESSTOKEN"'",
|
|
||||||
"clone_addr": "'"$GITEAHOST/$SOURCEORG/$SOURCEPKG.git"'",
|
|
||||||
"description": "'"SMEServer Koozali developed git repo for $TARGETPKG $BASEORCONTRIB"'",
|
|
||||||
"repo_name": "'"$TARGETPKG"'",
|
|
||||||
"repo_owner": "'"$TARGETORG"'"
|
|
||||||
}'
|
|
||||||
)
|
|
||||||
if [[ $RESPONSE != 201 ]] ; then
|
|
||||||
echo "Unable to migrate $SOURCEORG/$SOURCEPKG to $TARGETORG/$TARGETPKG ($RESPOMNSE) - Aborting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Migrate does NOT copy accross the issues and wiki external links
|
|
||||||
# grab WIKILINK from source package
|
|
||||||
if [ $DEBUG ] ; then echo "Retrieving WIKIKLINK from $SOURCEORG/$SOURCEPKG" ; fi
|
|
||||||
WIKILINK=$(curl "$SILENT" "$checkSSL" -X 'GET' \
|
|
||||||
"$GITEAHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" | \
|
|
||||||
jq -r ' .external_wiki.external_wiki_url')
|
|
||||||
if [ $DEBUG ] ; then echo "WIKILINK=$WIKILINK" ; fi
|
|
||||||
|
|
||||||
# Update the repo with the changed bugzilla url and original wiki url
|
|
||||||
if [ $DEBUG ] ; then echo "Updating Bug and Wiki links" ; fi
|
|
||||||
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \
|
|
||||||
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"has_issues": true,
|
|
||||||
"external_tracker": {
|
|
||||||
"external_tracker_format": "https://bugs.koozali.org/show_bug.cgi?id={index}",
|
|
||||||
"external_tracker_style": "numeric",
|
|
||||||
"external_tracker_url": "'"https://bugs.koozali.org/buglist.cgi?component=$TARGETPKG&product=$PRODUCTBUGZILLA"'"
|
|
||||||
},
|
|
||||||
"has_wiki": true,
|
|
||||||
"external_wiki": {
|
|
||||||
"external_wiki_url": "'"$WIKILINK"'"
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create the local Git repository
|
|
||||||
GITFiles=$WORKDIR/GITFiles/$TARGETORG
|
|
||||||
mkdir -p $GITFiles
|
|
||||||
cd $GITFiles
|
|
||||||
|
|
||||||
# Delete the local first
|
|
||||||
if [ -d "$TARGETPKG" ] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "Deleting local GIT files" ; fi
|
|
||||||
rm -Rf $GITFiles/$TARGETPKG
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clone the package
|
|
||||||
if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$TARGETORG/$TARGETPKG.git" ; fi
|
|
||||||
cd $GITFiles
|
|
||||||
git clone "$GITEAHOST/$TARGETORG/$TARGETPKG.git" $QUIET
|
|
||||||
cd $GITFiles/$TARGETPKG
|
|
||||||
|
|
||||||
#Update README.md
|
|
||||||
# - new name
|
|
||||||
sed -i 's/e-smith/smeserver/g' README.md
|
|
||||||
|
|
||||||
# - Bugzilla link to new name whilst keeping old link for Legacy
|
|
||||||
sed -i '/Show list/p' README.md
|
|
||||||
sed -i "/Show list/{ n; s/Show list of outstanding bugs\:/And a list of outstanding Legacy bugs\: ($SOURCEPKG)/}" README.md
|
|
||||||
sed -i '/Show list/{ n; s/smeserver/e-smith/g}' README.md
|
|
||||||
sed -i '/Show list/ s/)/)\\/' README.md
|
|
||||||
|
|
||||||
git add README.md
|
|
||||||
|
|
||||||
#Update Makefile
|
|
||||||
# - NAME := smeserver-<pkg>
|
|
||||||
|
|
||||||
sed -i 's/e-smith/smeserver/g' Makefile
|
|
||||||
git add Makefile
|
|
||||||
|
|
||||||
# spec file
|
|
||||||
#Rename e-smith-<pkg>.spec as smeserver-<pkg>.spec
|
|
||||||
git mv "$SOURCEPKG.spec" "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
#Update smeserver-<pkg>.spec
|
|
||||||
# - change name to smeserver-<pkg>
|
|
||||||
sed -i "/^Summary:/ s/e-smith/smeserver/" "$TARGETPKG.spec"
|
|
||||||
sed -i "/^Name:/ s/e-smith/smeserver/" "$TARGETPKG.spec"
|
|
||||||
sed -i "s/^%define name.*$SOURCEPKG/%define name $TARGETPKG/" "$TARGETPKG.spec"
|
|
||||||
sed -i "/^%description/{ n; s/e-smith/smeserver/}" "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
# Hold off on these for now
|
|
||||||
# - change all Requires: and BuildRequires: e-smith* to smeserver*
|
|
||||||
#sed -i 's/^Requires:.*e-smith/Requires: smeserver/g' "$TARGETPKG.spec"
|
|
||||||
#sed -i 's/^BuildRequires:.*e-smith/BuildRequires: smeserver/g' "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
# - add changelog entry (Bugzilla #12359)
|
|
||||||
# Bump the release and add changelog
|
|
||||||
change-log "$TARGETPKG.spec" >/dev/null 2>&1
|
|
||||||
# and edit in the reason and add by whom
|
|
||||||
sed -i "s/fix \[SME: \]/Rename to $TARGETPKG \[SME: 12359\]/" "$TARGETPKG.spec"
|
|
||||||
sed -i 's/ME MYSELF <myemail@koozali.org>/rename-e-smith-pkg.sh by Trevor Batley <trevor@batley.id.au>/' "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
# - add PROVIDES: smeserver-<pkg>
|
|
||||||
sed -i "/%description/i Provides: $SOURCEPKG" "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
# - change Source: to new standard of tar.gz
|
|
||||||
#sed -i "/^Source:/ s/tar.xz/tar.gz/" "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
# tell git about the changes
|
|
||||||
git add "$TARGETPKG.spec"
|
|
||||||
|
|
||||||
#Delete archivefilename file if it follows the new standard
|
|
||||||
if [[ -e archivefilename ]] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "archivefilename exists" ; fi
|
|
||||||
if [[ $(cat archivefilename) == "$TARGETPKG-*.tar.gz" ]] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "deleteing archivefilename - meets new standard" ; fi
|
|
||||||
git rm archivefilename $QUIET
|
|
||||||
else
|
|
||||||
if [ $DEBUG ] ; then echo "substituting smeserver for e-smith in archivefilename" ; fi
|
|
||||||
sed -i 's/e-smith/smeserver/g' archivefilename
|
|
||||||
git add archivefilename
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#Update createlinks
|
|
||||||
# - if there is an e-smith-<pkg>-update event rename to smeserver-<pkg>-update and add symlink
|
|
||||||
|
|
||||||
git commit -m "rename-e-smith-pkg script (#12359)" $QUIET
|
|
||||||
git push origin &> /dev/null
|
|
||||||
|
|
||||||
# Do we want to transfer the new package into the source organisation
|
|
||||||
if [ $TRANSFER ] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "Transferring $TARGETORG/$TARGETPKG to $SOURCEORG/$TARGETPKG" ; fi
|
|
||||||
#Check that target package does not exist
|
|
||||||
if [ $DEBUG ] ; then echo "Check if $SORCEORG/$TARGETPKG is there!" ; fi
|
|
||||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$TARGETPKG")
|
|
||||||
EXISTS=
|
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
|
||||||
EXISTS=true
|
|
||||||
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$TARGETPKG exists!" ; fi
|
|
||||||
if [ -z ${DELETEIT} ] ; then
|
|
||||||
while true; do
|
|
||||||
read -p "$SOURCEORG/$TARGETPKG exists! Do you wish to delete it and continue?(y/n) " yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* )
|
|
||||||
DELETEIT=true
|
|
||||||
break ;;
|
|
||||||
[Nn]* )
|
|
||||||
DELETEIT=
|
|
||||||
break ;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ $DELETEIT ] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "Deleting $SOURCEORG/$TARGETPKG" ; fi
|
|
||||||
RESPONSE=$(curl "$checkSSL" "$SILENT" -o /dev/null -w "%{http_code}" -X 'DELETE' \
|
|
||||||
"$GITEAHOST/api/v1/repos/$SOURCEORG/$TARGETPKG" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" )
|
|
||||||
if [[ $RESPONSE != "204" ]] ; then
|
|
||||||
echo "Unable to delete $SOURCEORG/$TARGETPKG ($RESPONSE)"
|
|
||||||
else
|
|
||||||
EXISTS=
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$TARGETPKG does not exist on $GITEAHOST" ; fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Transfer the package back to source organisation
|
|
||||||
if [[ -z $EXISTS ]] ; then
|
|
||||||
if [ $DEBUG ] ; then echo "Actual Transfer" ; fi
|
|
||||||
RESPONSE=$(curl "$SILENT" "$checkSSL" -o /dev/null -w "%{http_code}" -X 'POST' \
|
|
||||||
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $GITEAACCESSTOKEN" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"new_owner": "'"$SOURCEORG"'"
|
|
||||||
}'
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
if [[ $EXISTS || $RESPONSE != "202" ]] ; then
|
|
||||||
echo "Unable to transfer $TARGETORG/$TARGETPKG to $SOURCEORG/$TARGETPKG ($RESPONSE) - Aborting!"
|
|
||||||
echo "But everything else has been done and $TARGETORG/$TARGETPKG should be complete."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
if [[ -z $NOOUTPUT ]] ; then echo "$SOURCEORG/$SOURCEPKG has been renamed as $SOURCEORG/$TARGETPKG" ; fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ -z $NOOUTPUT ]] ; then echo "$SOURCEORG/$SOURCEPKG has been renamed as $TARGETORG/$TARGETPKG" ; fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
Reference in New Issue
Block a user