Compare commits

...

151 Commits

Author SHA1 Message Date
trevorb
50f193b2db fix README for git-retag.sh 2024-12-20 20:09:10 +11:00
e30641250e use awk and markdown for contribs 2024-10-27 15:44:50 +00:00
0c858eaba1 Add git-edit-readme.sh 2024-10-27 12:07:54 +00:00
c4f00b4328 Update Readme.md 2024-05-26 21:24:58 +02:00
f984ec736d Update Readme.md 2024-05-26 21:22:14 +02:00
454e474564 Add github-make-push-mirror.sh 2024-05-26 20:18:34 +01:00
Trevor Batley
8f06ffbed9 fix cpan bug link 2024-03-27 18:21:03 +11:00
Trevor Batley
c15231193b README take 5 2024-03-27 18:03:21 +11:00
Trevor Batley
bd51a307e8 README take 3README take 3 2024-03-27 17:34:16 +11:00
Trevor Batley
f948bbc974 fix Makefile 2024-03-27 16:57:44 +11:00
Trevor Batley
6fff2d19f5 fix bugs 2024-03-27 16:45:48 +11:00
Trevor Batley
fb6a44f132 fix lfs, Makefile, README.md and BuildRequires 2024-03-27 15:05:25 +11:00
Trevor Batley
c5800c3e14 Get tarball extension for lfs 2024-03-26 17:21:10 +11:00
Trevor Batley
1a4d5ade8f change name in generated Makefile 2024-03-26 16:38:45 +11:00
Trevor Batley
331c908cb8 add makefile and tag in getperl 2024-03-25 08:24:32 +11:00
TrevorB
c5d71a4da7 add git-getperl 2024-03-24 22:35:07 +11:00
Trevor Batley
452e84b2ca TAG to use _ instead of . 2024-03-24 10:29:15 +11:00
Trevor Batley
1e00424274 look for common in smeserver 2024-03-22 17:42:23 +11:00
e19bd34d0c revert f8e6992cea
revert Add in change to tar file name
2024-03-15 10:50:35 +01:00
f8e6992cea Add in change to tar file name 2024-03-14 20:06:45 +01:00
28d6cb1a44 Update 'README.md' 2024-03-12 21:43:12 +01:00
0ca87cfbee Update README with git-get-latest-tag.sh 2024-03-12 20:41:40 +00:00
13d705639c Add git-get-latest-tag.sh 2024-03-12 20:38:19 +00:00
Brian Read
c690004aca Add rpmspec test 2024-03-11 19:31:47 +00:00
Trevor Batley
a90599279b add clean option 2024-03-11 21:01:54 +11:00
Trevor Batley
9916c56721 fix for version release 2024-03-11 20:56:30 +11:00
Trevor Batley
5c4f74da8f version release 2024-03-11 09:18:16 +11:00
f7e6b20b25 Fix dot points under git-retag.sh 2024-02-16 01:11:43 +01:00
Trevor Batley
9fd4f2cce8 fix mirror=false 2023-11-20 11:43:02 +11:00
Trevor Batley
c8f81a0315 use gitea api instead of git for tag delete 2023-11-18 07:54:54 +11:00
Trevor Batley
0c53f9fae6 add git-retag.sh to README 2023-11-17 15:00:14 +11:00
Trevor Batley
ce14ed07fc fix version release 2023-11-17 14:49:55 +11:00
Trevor Batley
eaf957da50 delete ALL old tags 2023-11-17 12:40:43 +11:00
Trevor Batley
4ddb8de08e add release back into tag 2023-11-17 09:35:33 +11:00
c25fa1943a Fix OpenAI key 2023-08-21 08:21:03 +02:00
Trevor Batley
19efadfa1d move rename-e-smith to it's own repository 2023-07-24 09:21:32 +10:00
Trevor Batley
750bde5b38 typo again 2023-07-23 19:23:17 +10:00
Trevor Batley
de31b20e72 typo 2023-07-23 19:20:25 +10:00
Trevor Batley
c6e57c9475 add branch parameter 2023-07-23 17:28:12 +10:00
Trevor Batley
98eddc7b64 Added branch option 2023-07-23 15:17:45 +10:00
Brian Read
e2b9906429 Add in asseturls to options for git-list.. 2023-07-20 20:00:36 +01:00
Brian Read
99be082770 Alter foprmat for list and a small fix for make-release 2023-07-20 15:42:16 +01:00
029b3fe3cd Update README for update-release 2023-07-20 12:58:26 +02:00
Brian Read
70daf74b8d Add in update and delete release scripts 2023-07-20 11:55:03 +01:00
Brian Read
307a492847 Update list-all-ord-repos to include all releases 2023-07-19 13:20:02 +01:00
Brian Read
ee106a077c Take out early exit - left in by mistake! 2023-07-19 12:31:00 +01:00
Brian Read
fd798e83c3 Add release types to make-release 2023-07-19 12:22:50 +01:00
Brian Read
477ecb7c4d Add release type to make-release, add WIP list of repos
Update email address
2023-07-19 12:17:27 +01:00
6e9f8dddb9 Add comment re: scripts being in path 2023-07-18 07:10:38 +02:00
Brian Read
133cea8089 Add test for null release tag and exit if so 2023-07-17 10:27:17 +01:00
Trevor Batley
e966afb059 Delete reference to make-archive - no longer used 2023-07-14 14:15:58 +10:00
be872a008e Delete reference to make-archive - no longer in use. 2023-07-12 09:18:36 +02:00
Brian Read
b60d27a7fe Forgot SME in tag for release search API call 2023-07-10 11:54:02 +01:00
Brian Read
ff0eeb0fce Remove RELEASE from tag as reflects build system not system being built 2023-07-09 16:15:44 +01:00
5b30bee2a9 fix format for git-make-release.sh doc 2023-07-09 12:56:38 +02:00
Brian Read
89e71d95a5 Added git-make-release.sh 2023-07-09 11:52:15 +01:00
Brian Read
21a3a248b2 Add check for lua - needed for change-log 2023-07-05 13:56:36 +01:00
Brian Read
36616d567f Bring BogusDateBot check and call into line - remove /usr/bin 2023-07-05 13:48:37 +01:00
Brian Read
44432a300b Sort out parameter to make prep for DEBUG mode 2023-07-05 12:20:56 +01:00
Brian Read
11c8552978 Remove SILENT from make prep as it treats the -v as version 2023-07-04 06:50:43 -04:00
Brian Read
211c2ee576 Re-instate exit if change-log or bogus data not found 2023-07-03 11:00:19 -04:00
Trevor Batley
27b59de7aa remove e-smith-openssh special fix 2023-06-25 11:04:14 +10:00
Trevor Batley
afe2c69d3e mistype 2023-06-24 17:06:42 +10:00
Trevor Batley
5cf5ed1278 wap Requires from e-smith to e-smith-base 2023-06-24 16:54:17 +10:00
Trevor Batley
38fa8363e5 change tar.gz or tgz to tar.xz 2023-06-24 16:39:53 +10:00
Trevor Batley
b7188cbf4b Updated comments 2023-06-21 16:53:28 +10:00
Trevor Batley
7a7a68753a fix e-smith-lib sed 2023-06-15 15:53:29 +10:00
Trevor Batley
6d940ffda8 moved package specific to cvs2git 2023-06-15 15:47:06 +10:00
Trevor Batley
988513d86b package specific changes from make prep 2023-06-15 15:46:13 +10:00
Trevor Batley
bf8e39046a tell sed which file 2023-06-15 15:09:57 +10:00
Trevor Batley
913c24a33f delete the setup lines for Source1 & 2 2023-06-15 15:04:11 +10:00
Trevor Batley
f50cfc1ca7 add after not before 2023-06-15 14:45:23 +10:00
Trevor Batley
3094498fc6 square brackets 2023-06-15 14:29:36 +10:00
Trevor Batley
a0fe5dd71d add package specific fixes 2023-06-15 14:24:59 +10:00
Trevor Batley
999c22b420 show return code on non-zero exit 2023-06-15 10:19:59 +10:00
Trevor Batley
3f8e6f31ae remove trailing - in sed 2023-06-14 17:09:01 +10:00
Trevor Batley
1333f1a651 sed Name as well as defne name 2023-06-14 17:02:03 +10:00
Trevor Batley
8f8632e65e fix archivefilename 2023-06-14 16:48:14 +10:00
Trevor Batley
e3f3040073 get quotes right 2023-06-13 16:58:04 +10:00
Trevor Batley
a99d2a59c1 change e-smith to smeserver in archivefilename 2023-06-13 16:53:39 +10:00
Trevor Batley
ea5551e41f check format of archivefilename 2023-06-13 16:39:10 +10:00
Trevor Batley
15899ef0c7 lots more debug 2023-06-13 10:12:49 +10:00
Trevor Batley
9c4d268e3d add in extra parms 2023-06-13 09:37:45 +10:00
94f7e151c0 Take out "GITFiles" in mkdir as the WORKDIR var includes it already. 2023-06-09 07:12:53 +02:00
4671bb0abd Remove "GITFiles" in mkdir as already specified in the $WORKDIR var 2023-06-09 07:06:44 +02:00
Trevor Batley
bb5278ebd5 hold off on requires changes for now 2023-06-07 10:38:12 +10:00
Trevor Batley
9c827793e0 correct return code processing 2023-06-06 20:40:43 +10:00
Trevor Batley
5207676ada cant rm whilst in the directory... 2023-06-06 20:19:09 +10:00
Trevor Batley
5861b6af76 show output of failed script 2023-06-06 20:08:26 +10:00
Trevor Batley
7c125e18d1 QUIET a different way 2023-06-06 19:39:40 +10:00
Trevor Batley
6237cbec79 correct order of params in README.md 2023-06-06 19:36:22 +10:00
Trevor Batley
d0242b29ce add clarity to error display 2023-06-06 19:34:10 +10:00
Trevor Batley
7eb6b5769e quieten a little 2023-06-06 19:31:48 +10:00
Trevor Batley
dc0ed1b79d correctly arrange $1=repo and $2=org in all places 2023-06-06 19:23:05 +10:00
Trevor Batley
96094332ef remove spurious -q 2023-06-06 16:57:14 +10:00
Trevor Batley
1e40fa679c fix paramlist missing 2023-06-06 16:46:48 +10:00
Trevor Batley
2b60851ea3 encapsulate params 2023-06-06 12:26:36 +10:00
Trevor Batley
51ecfe7ee1 delete spurious quotes 2023-06-06 12:18:51 +10:00
Trevor Batley
f0a02bc746 define array 2023-06-06 12:14:00 +10:00
Trevor Batley
ff91ef36e3 remove extra displays 2023-06-06 12:12:27 +10:00
Trevor Batley
09f76ab8ab param vs file 2023-06-06 11:51:56 +10:00
Trevor Batley
d05df71e5c fix sppend 2023-06-06 11:49:16 +10:00
Trevor Batley
0c2b8da54f parse input fiile to array before provcessing 2023-06-06 11:45:25 +10:00
Trevor Batley
f2b2c021f8 add in debug param 2023-06-05 16:18:06 +10:00
Trevor Batley
72625870bf remove git-migrate-org.sh script 2023-06-05 15:43:44 +10:00
Trevor Batley
485c2090a1 add git-transfer-repo.sh to README.md 2023-06-05 15:41:58 +10:00
Trevor Batley
15ffd74a3e add git-transfer-repo.sh script 2023-06-05 15:31:16 +10:00
Trevor Batley
ef23cc5f9a capture fail of migrate 2023-06-05 14:54:51 +10:00
Trevor Batley
c9e3f1782c more debug statements 2023-06-05 14:04:19 +10:00
Trevor Batley
de4a821af5 check code not data 2023-06-05 11:03:12 +10:00
Trevor Batley
32268cd2a9 error message re: unable to delete 2023-06-05 10:58:40 +10:00
Trevor Batley
9fd1578a7e delete the target not the source 2023-06-05 10:45:49 +10:00
Trevor Batley
75aa177430 added in delete of pkg on transfer 2023-06-05 10:41:39 +10:00
Trevor Batley
1116647ec2 check code not data 2023-06-05 10:18:11 +10:00
Trevor Batley
9cd1d56a72 undo in-situ - must be owner 2023-06-05 09:56:26 +10:00
Trevor Batley
96f7295f96 do it all in the same org 2023-06-05 09:42:48 +10:00
Trevor Batley
901042b562 GITEAHOST not GITEAURL 2023-06-05 09:31:37 +10:00
Trevor Batley
2036ae59f4 add optional transfer back to source org 2023-06-05 09:21:54 +10:00
Trevor Batley
178d0f37ab remove forked comment on success 2023-06-05 08:57:13 +10:00
Trevor Batley
a7b3cda711 add back in update of external issues and wiki 2023-06-05 08:52:52 +10:00
Trevor Batley
ce96666422 add back in bug & wiki 2023-06-05 08:44:51 +10:00
Trevor Batley
9b86646411 add in cloneurl 2023-06-04 21:56:51 +10:00
Trevor Batley
6f09d7a865 variable names wrong 2023-06-04 21:43:34 +10:00
Trevor Batley
80d42edbc1 FIIK 2023-06-04 18:04:38 +10:00
Trevor Batley
80f76cf8ac ? accesstokens ? 2023-06-04 17:50:56 +10:00
Trevor Batley
1aeb5b4c36 mixed up source & target 2023-06-04 17:39:24 +10:00
Trevor Batley
b497a00693 change to migrate rather than fork 2023-06-04 17:00:24 +10:00
Trevor Batley
277035cf55 tidy up parameter descriptions and add example 2023-06-04 10:44:39 +10:00
Trevor Batley
61f97c908e add additional params 2023-06-04 09:08:49 +10:00
Trevor Batley
6b45e5f846 missed review option for parse-list.sh 2023-06-03 17:09:24 +10:00
Trevor Batley
7cde1aaeff escape < and > 2023-06-03 17:07:31 +10:00
Trevor Batley
96e105213e escape < and > 2023-06-03 17:06:40 +10:00
Trevor Batley
d0ceacf5ef update parse-list.sh options 2023-06-03 17:04:49 +10:00
Trevor Batley
db62df1090 silence curl output 2023-06-03 16:57:10 +10:00
Trevor Batley
51d864512f add local to extraparams if set 2023-06-03 16:54:12 +10:00
Trevor Batley
ec984efd3d use $1 2023-06-03 16:51:39 +10:00
Trevor Batley
5c065162dd too many " 2023-06-03 16:46:27 +10:00
Trevor Batley
255cce967a add in smegit/config processing 2023-06-03 16:42:01 +10:00
Trevor Batley
7fb53cc776 add org= option 2023-06-03 16:22:03 +10:00
Trevor Batley
a7eebc7ac7 use $SOURCEHOST 2023-06-03 15:17:31 +10:00
Trevor Batley
aab64d1ed7 remove quotes with jq -r 2023-06-03 14:24:26 +10:00
Trevor Batley
2822c44f8e correct continiuation character 2023-06-03 14:18:21 +10:00
Trevor Batley
3b2ab5189a typo 2023-06-03 13:36:24 +10:00
Trevor Batley
240928b74b direct extract or wikiurl from curl 2023-06-03 13:29:22 +10:00
Trevor Batley
d05be5fa35 spurious , 2023-06-03 12:23:25 +10:00
Trevor Batley
840b9e9057 get wiki link from source repo and use it 2023-06-03 12:11:10 +10:00
Trevor Batley
5199f9ea5e remove suppress 2023-06-03 09:09:26 +10:00
456cee3067 Typos. 2023-06-02 15:36:24 +02:00
9cbece1ab8 Update README with git-post-create-repo.sh details 2023-06-02 15:34:55 +02:00
b97d611c79 Merge branch 'master' of https://src.koozali.org/smedev/smeserver-gitutils
ok
2023-06-02 14:27:53 +01:00
56969eff40 Add post create frm template script 2023-06-02 14:26:42 +01:00
19 changed files with 2316 additions and 569 deletions

169
README.md
View File

@@ -4,6 +4,8 @@ Utilities to use with smeserver on Koozali.org GITEA instance
Just a repackaging of some of Brian Read's tools with some modifications for the new git structure and some tidy-up of the ini file and debug statements
It's a good idea to have the scripts somewhere in your path (some do call others). You can put them in ~/bin (you may need to create this if it doesn't exist)
## config
sample ~/.smegit/config or /etc/smegit.ini file - fill in your details\
It will use the user config first and system ini, if user config does not exist
@@ -24,8 +26,9 @@ optional parameters, can appear in any order
## git-get-and-build-repo.sh
bring down current git repository and run mockbuild
git-get-and-build.sh <organisation> <repository> [<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)
* \<organisation\> can be any organisation or user on the remote GITEA instance
@@ -37,58 +40,172 @@ optional parameters, can appear in any order
## git-migrate-repo.sh
create mirror or copy of src.koozali.org repository in a local GITEA instance
git-migrate-repo.sh <repository> <organisation> [<copy|mirror> <target organisation> <debug>]
git-migrate-repo.sh <repository> <organisation> [<target organisation> <copy|mirror> <local> <debug>]
* \<repository\> repository (package) to be copied (e.g. smeserver-yum)
* \<organisation\> can be any organisation or user on the remote GITEA instance
* \<debug\> run in debug mode
optional parameters, can appear in any order
* \<target organisation\> within your local GITEA, otherwise local user - must exist already
* \<copy|mirror\> will create local repo as either a copy or a mirror of the remote repo (default = copy)
* \<target organisation\> within your local GITEA, otherwise local user - must exist already
* \<local\> use local GITEA as source (i.e. copy between organisations on local GITEA)
* \<debug\> run in debug mode
## git-migrate-org.sh
create mirrors of all repos for an organisation in a local GITEA instance
## git-transfer-repo.sh
Transfer a repo to a different user (or organisation)
git-migrate-org.sh <organisation> [<copy|mirror> <review> <target organisation> <debug>]
git-transfer-repo.sh <repository> <source organization> <target organisation> [<local> <force> <debug> <silent>]
* \<organisation\> can be any organisation or user on the remote GITEA instance
* \<repository\> repository name to be transferred (e.g. smeserver-clamav)
* \<source organisation\> to be transferred from (any valid organisation or user)
* \<target organisation\> to be transferred to (any valid organisation or user - you need owner privileges)
optional parameters, can appear in any order
* \<copy|mirror\> will create local repos as either a copy or a mirror of the remote repos (default = copy)
* \<review\> will just list the repos to be migrated, rather than doing it
* \<target organisation\> within your local GITEA, otherwise local user - must exist already
* \<debug\> run in debug mode
* \<noisy\> show each repo being migrated
\<local\> will use parameters set for local repository, else it will use remote
\<force\> will automagically delete an existing target repo, otherwise it will prompt
\<debug\> run in debug mode
\<silent\> suppress success message
## rename-e-smith-pkg.sh
Rename an e-smith package as smeserver and change relevant files
## git-retag.sh
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
* \<organisation\> (any gitea organisation smeserver, smecontribs 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
* \<debug\> run in debug mode
This works whether the repo and local files exist of not (it deletes them if necessary)
* \<purge\> will remove all existing tags
* \<local\> will use parameters set for local repository, else it will use remote
* \<debug\> run with debug output
* \<noisy\> will will print a line showing how it was called
## parse-list.sh
Parse a list of parameters and execute script with those parameters
parse-list.sh <param file> <script> [<noisy> <additional> <additional> <additional>]
parse-list.sh <param file|org='organisation'> <script> [<local> <noisy> <review> <additional*>]
* \<param file\> name of file containing parameters
* \<param file\|org='organisation'> name of file containing parameters or organisation which will be used to generate a list of all repos for input to \<script\>
* \<script\> script to run (e.g. rename-e-smith-pkg.sh)
optional params can appear 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
* \<additional\> additional params to be passed (up to 3) e.g. debug,force,local
* \<review\> show line to be executed, but NOT executing
* \<additional\> additional params to be passed (up to 3) e.g. debug,force,local
### example:
parse-list.sh org=smeserver git-migrate-repo.sh review
will echo the command that would be run for each repo in the smeserver organisation on the remote GITEA instance
git-migrate-repo.sh perl-Moo smeserver
git-migrate-repo.sh buildsys-macros smeserver
git-migrate-repo.sh clamav smeserver
...
## git-post-create-repo.sh
Update a repo created from a template (contribs,base or 3rd party) with things not able to be updated from the template:
* \<repository\> repository (package) to be editted (e.g. smeserver-yum)
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
optional:
* \<local\> will migrate into your local GITEA (in config), otherwise remote GITEA
Does:
Rename spec file
Set current date in change log
Set Wiki and Issues links external (SME Wiki and Bugzilla)
## git-make-release.sh
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)
* \<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
* \<release-tag\> will have "SME" added to the front of it (so e.g. 10.2 -> SME10.2)
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
* \<draft\> create a draft release
* \<prerelease\> create a pre-release
Note that no release type will give a full stable release
Does:
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)
## 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
View File

@@ -2,9 +2,9 @@
DEBUG=false
# if first character ~ will be relative to users home, otherwise absolute
WORKDIR=~/smegit
COMMONREPO=https://src.koozali.org/smedev/common.git
# Brian's token, but please use wisely!
OPENAI_API_KEY=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
COMMONREPO=https://src.koozali.org/smeserver/common.git
# OpenAI key for readme comment lookup.
OPENAI_API_KEY=<key - ask Brian for his..>
[local]
USER=<local GITEA user name>
GITEAHOST=<local GITEA URL>

View File

@@ -77,12 +77,12 @@ if [ $NOISY ] ; then echo "git-cvs2git.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"
curlsilent="-s"
suppress=" &> /dev/null"
SILENT4CURL="-s"
SILENT4MAKE="-s"
if [ $DEBUG ] ; then
QUIET=
curlsilent="-v"
suppress=
SILENT4CURL="-v"
SILENT4MAKE=
fi
# Make this null to get curl to check ssl cert
checkSSL="-k"
@@ -144,12 +144,23 @@ else
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
@@ -157,6 +168,7 @@ if type -P BogusDateBot.sh >/dev/null 2>&1; then
if [ $DEBUG ] ; then echo "************BogusDateBot.sh is installed"; fi
else
echo "ERROR********************BogusDateBot.sh is not installed*********** (try installing smeserver-mockbuild)"
exit 1
fi
# Create work directories
@@ -225,7 +237,7 @@ if [[ $GOTONE -eq 0 ]] ; then
fi
# Create the local Git repository
GITFiles=$WORKDIR/GITFiles/$ORGGITEA
GITFiles=$WORKDIR/$ORGGITEA
mkdir -p $GITFiles
cd $GITFiles
@@ -239,7 +251,7 @@ fi
REPO_NAME=$1
if [ $DEBUG ] ; then echo "check that $GITEAHOST/$ORGGITEA/$REPO_NAME exists" ; fi
READMECONTENTS=
RESPONSE=$(curl $checkSSL $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME")
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 $1 already exists!" ; fi
# If so, clone it (just want the README.md)
@@ -253,7 +265,7 @@ if [ "$RESPONSE" == "200" ]; then
fi
# Now delete the repo, re-create it and clone it in to local
if [ $DEBUG ] ; then echo "Delete $ORGGITEA/$1" ; fi
RESPONSE=$(curl "$checkSSL" "$curlsilent" -o /dev/null -w "%{http_code}" -X 'DELETE' \
RESPONSE=$(curl "$checkSSL" "$SILENT4CURL" -o /dev/null -w "%{http_code}" -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$ORGGITEA/$1" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN")
@@ -279,7 +291,7 @@ cd $GITFiles
# Re-create the repo
#
if [ $DEBUG ] ; then echo "************Creating repo for $1 $PACKAGETYPE" ; fi
RESPONSE=$(curl "$checkSSL" "$curlsilent" -X 'POST' \
RESPONSE=$(curl "$checkSSL" "$SILENT4CURL" -X 'POST' \
"$GITEAHOST/api/v1/orgs/$ORGGITEA/repos" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
@@ -310,7 +322,7 @@ if [[ -z "${HTTP_URL}" ]]; then
fi
# And check it now exists
RESPONSE=$(curl "$curlsilent" -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$1")
RESPONSE=$(curl "$SILENT4CURL" -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$1")
if [[ "$RESPONSE" == "200" ]]; then
if [ $DEBUG ] ; then echo "************Repository for $1 exists" ; fi
else
@@ -333,7 +345,8 @@ cd $CVSFiles/$1/$BASEORCONTRIB
# 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".
make prep "$suppress"
make $SILENT4MAKE prep
#echo `pwd`; exit 0
# Extract the directory name for the file tree (it will include the name of the module plus some version information)
# Same trick that we use in the makefile.common - taking the name and verison from the .spec file.
@@ -500,9 +513,9 @@ else
# Third party package
# 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 $QUIET
git lfs track "*.$EXT" $QUIET
git add .gitattributes $QUIET
git lfs install
git lfs track "*.$EXT"
git add .gitattributes
#git config lfs.http://gitea.bjsystems.co.uk/SMEContribs/bugzilla.git/info/lfs.locksverify true
if [[ -f $CVSFiles/$1/$BASEORCONTRIB/$ARCHIVEFILE ]] ; then
if [ $DEBUG ] ; then echo "************Copying archivefile $CVSFiles/$1/$BASEORCONTRIB/$ARCHIVEFILE" ; fi
@@ -514,24 +527,37 @@ else
fi
cd $GITFiles/$1
if [[ $ARCHIVEFILE != "$TREEPATH.tar.gz" ]] ; then
echo "$ARCHIVEFILE" > archivefilename
fi
#if [[ $ARCHIVEFILE != "$TREEPATH.tar.gz" ]] ; then
# echo "$ARCHIVEFILE" > archivefilename
#fi
# Take out any bogus dates:
/usr/bin/BogusDateBot.sh $(basename $SPECFILE) "$suppress"
BogusDateBot.sh $(basename $SPECFILE)
# If it is an SME package, take out the patches and then update the release.
if [[ "$NAME" =~ ^(smeserver-|e-smith-).* ]]; then
# Now edit the spec file to remove all those patches and adjust the paths
sed -i '/^Patch/d; /^%patch/d' $(basename $SPECFILE)
# no paths need adjusting at this time!
# - change Source: to new standard of tar.xz
sed -i '/^Source:/s/tar.gz/tar.xz/;s/tgz/tar.xz/' $(basename $SPECFILE)
# Bump the release and add changelog
change-log $(basename $SPECFILE) "$suppress"
change-log $(basename $SPECFILE)
# and edit in the reason
# sed - TBD - to look for "fix [SME: ]"
sed -i 's/fix \[SME: \]/Roll up patches and move to git repo \[SME: 12338\]/' $(basename $SPECFILE)
sed -i 's/ME MYSELF <myemail@koozali.org>/cvs2git.sh aka Brian Read <brianr@koozali.org>/' $(basename $SPECFILE)
# package specific changes needed because we use make prep to create the root tree
if [[ $NAME == "e-smith-grub" ]] ; then
sed -i '/^Source1:/d' $(basename $SPECFILE)
sed -i '/^Source2:/d' $(basename $SPECFILE)
sed -i '/^%setup/{n;N;N;N;d}' $(basename $SPECFILE)
sed -i '/\[SME: 12338\]/a - Remove Source1 & Source2 \[SME: 12338\]' $(basename $SPECFILE)
fi
if [[ $NAME == "e-smith-lib" ]] ; then
sed -i '/^%setup/{n;N;d}' $(basename $SPECFILE)
sed -i '/\[SME: 12338\]/a - Remove create e-smith-lib-update event \[SME: 12338\]' $(basename $SPECFILE)
fi
# Add in the autochangelog and autorelease macros into the spec file
# Commented out for now until we have build systems that can install the rpmautospec package (CEntos, Rocky etc V9 only so far)
# sed -i 's/Release:.*/Release: %autorelease/' $(basename $SPECFILE)
@@ -577,9 +603,6 @@ else
git pull $QUIET
fi
# Now make sure that the make-archive is executible
chmod +x $GITFiles/common/make-archive.sh
# Edit the Readme.md - try to add a link to the wiki for this package - only if it is an SME package
cd $GITFiles/$1
if [ $DEBUG ] ; then echo "************READMECONTENTS:$READMECONTENTS" ; fi
@@ -646,7 +669,7 @@ if [[ "$NAME" =~ ^(smeserver-|e-smith-).* ]]; then
model="text-davinci-003"
temperature=0.8
# Send the request to the API
response=$(curl "$curlsilent" -X POST https://api.openai.com/v1/engines/$model/completions \
response=$(curl "$SILENT4CURL" -X POST https://api.openai.com/v1/engines/$model/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"prompt": "'"$prompt"'", "temperature": 0.8, "max_tokens": 256}')
@@ -670,7 +693,7 @@ else
model="text-davinci-003"
temperature=0.8
# Send the request to the API
response=$(curl "$curlsilent" -X POST https://api.openai.com/v1/engines/$model/completions \
response=$(curl "$SILENT4CURL" -X POST https://api.openai.com/v1/engines/$model/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"prompt": "'"$prompt"'", "temperature": 0.8, "max_tokens": 256}')
@@ -695,7 +718,7 @@ if [[ -z $WIKILINK ]] ; then
fi
# and then update the repo parameters
RESPONSE=$(curl "$curlsilent" -X 'PATCH' "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME" \
RESPONSE=$(curl "$SILENT4CURL" -X 'PATCH' "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
@@ -731,7 +754,9 @@ git push --force -u $QUIET origin master
# Now create the version and release tag for these files
RELEASE=`rpm --queryformat '%{release}\n' --specfile $NAME.spec | head -n 1`
TAG=$VERSION-$RELEASE
# Release is not reliable - if you run on Rocky it comes back EL8, centos 7 - EL7
# So, we need to just take the build part (first word)
TAG=$VERSION"-"${RELEASE%.*}
git tag -a $TAG -m "$COMMENT"
git push origin $TAG $QUIET

View 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
View 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
View 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"

View File

@@ -8,7 +8,7 @@ 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 "get-repo-and-build.sh <organisation> <reponame> [<local>]"
echo "get-repo-and-build.sh <organisation> <reponame> [branch=<branch> <local> <debug>]"
exit 1
else
initfilename="/etc/smegit.ini"
@@ -30,27 +30,45 @@ while read -r line || [[ -n "$line" ]]; do
done < "$inifilename"
if [[ -z $1 && -z $2 ]] ; then
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
echo "get-repo-and-build.sh <reponame> <organisation> [<local>]"
exit 0
fi
DEBUG=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
if [ $DEBUG ] ; then echo "found ini file: $inifilename" ; fi
curlsilent="-s"
if [ $DEBUG ] ; then curlsilent= ; fi
GITEAHOST=${remote_GITEAHOST}
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
if [ $3 ] ; then
if [ $3 == "local" ] ; then
GITEAHOST=${local_GITEAHOST}
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
fi
ORG_NAME="$2"
REPO_NAME="$1"
BRANCH=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
for param in $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
branch=* )
BRANCH="--${param}"
;;
local )
GITEAHOST=${local_GITEAHOST}
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
;;
debug )
DEBUG=true ;;
* )
TARGETORG=$param ;;
esac
else
break
fi
done
SILENT="-s"
QUIET="-q"
if [ $DEBUG ] ; then
echo "found ini file: $inifilename"
SILENT=
QUIET=
fi
ORG_NAME="$1"
REPO_NAME="$2"
if [[ $smegit_WORKDIR == ~* ]] ; then
# relative to users home dir
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
@@ -59,7 +77,7 @@ else
WORKDIR=${smegit_WORKDIR}
fi
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
GITFiles=$WORKDIR/GITFiles/$ORG_NAME
GITFiles=$WORKDIR/$ORG_NAME
REPOURL="$GITEAHOST/$ORG_NAME/$REPO_NAME.git"
if [ $DEBUG ] ; then echo "getting $REPO_NAME from $ORG_NAME on $GITEAHOST" ; fi
@@ -75,81 +93,82 @@ if [ $DEBUG ] ; then echo $GITFiles ; fi
# See if it already exists
if [ ! -e $GITFiles/common ]; then
#Get it
if [ $DEBUG ] ; then echo "clone common" ; fi
cd $GITFiles
git clone "${smegit_COMMONREPO}"
git clone "${smegit_COMMONREPO}" $QUIET
if [ ! -e $GITFiles/common ]; then
echo "ERROR*******No Common Repo found - package $1"
echo "ERROR*******No Common Repo found - package $REPO_NAME"
exit 1
fi
else
# Just refresh it
if [ $DEBUG ] ; then echo "refresh common" ; fi
cd $GITFiles/common
git pull
fi
# Now make sure that the make-archive is executible
chmod +x $GITFiles/common/make-archive.sh
# See if repo exits in git
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi
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 [ $DEBUG ] ; then echo "Repository for $1/$2 exists!" ; fi
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME exists!" ; fi
else
if [ $DEBUG ] ; then echo "Repository for $1/$2 does not exist" ; fi
logname="git-cvs2git-create-$2-$1-$(date +'%FT%H%M').log"
while true; do
read -p "Do you wish to run git-cvs2git?(y/n) " yn
case $yn in
[Yy]* ) git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME does not exist" ; fi
if [ $BRANCH ] ; then
echo "Can't find the ${BRANCH#*=} branch of $ORG_NAME/$REPO_NAME - exiting"
exit 1
else
while true; do
read -p "Do you wish to run git-cvs2git?(y/n) " yn
case $yn in
[Yy]* )
if [ $DEBUG ] ; then echo "running git-cvs2git.sh" ; fi
logname="git-cvs2git-create-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log"
git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname
break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# And check it is now there
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
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 [ "$RESPONSE" == "200" ]; then
if [ $DEBUG ] ; then echo "Repository for $1/$2 created sucessfully!" ; fi
if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME created sucessfully!" ; fi
else
echo "git-cvs2git.sh was unable to create $1/$2 sucessfully"
echo "git-cvs2git.sh was unable to create $ORG_NAME/$REPO_NAME sucessfully"
exit 1
fi
fi
# Ok, we have a repo!!
cd $GITFiles
echo $GITFiles
if [ $DEBUG ] ; then echo $GITFiles ; fi
# Delete it if these already
if [[ -d $REPO_NAME ]] ; then
# Should delete everything....
cd $GITFiles/$REPO_NAME
if [ $DEBUG ] ; then echo "Deleting all files in $GITFiles/$REPO_NAME" ; fi
rm -rf "$REPO_NAME"
rm -rf "$GITFiles/$REPO_NAME"
fi
cd $GITFiles
git clone "$REPOURL"
if [ $DEBUG ] ; then echo "cloning $REPOURL $BRANCH" ; fi
git clone "$REPOURL" $BRANCH $QUIET
cd $GITFiles
if [[ ! -d $REPO_NAME ]] ; then
echo "git clone has not created the directory"
if [[ ! -d $GITFiles/$REPO_NAME ]] ; then
echo "git clone has not created the $REPO_NAME directory"
exit 1
fi
cd $GITFiles/$REPO_NAME
# and run mockbuild
logname="mockbuild-$2-$1-$(date +'%FT%H%M').log"
if [ $DEBUG ] ; then echo "running make mockbuild" ; fi
logname="mockbuild-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log"
if make mockbuild 2>&1 > $logname ; then
echo "Looks like mockbuild worked for $1/$2"
echo "$(date +'%FT%H%M') Mockbuild worked for $1/$2 " >> $GITFiles/mockbuilds.log
echo "Looks like mockbuild worked for $ORG_NAME/$REPO_NAME"
echo "$(date +'%FT%H%M') Mockbuild worked for $ORG_NAME/$REPO_NAME " >> $GITFiles/mockbuilds.log
else
echo "Mockbuild failed"
echo "$(date +'%FT%H%M') Mockbuild failed for $1/$2 " >> $GITFiles/mockbuilds.log
echo "$(date +'%FT%H%M') Mockbuild failed for $ORG_NAME/$REPO_NAME " >> $GITFiles/mockbuilds.log
exit 1
fi

494
git-getperl.sh Executable file
View 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
View 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

255
git-make-release.sh Executable file
View File

@@ -0,0 +1,255 @@
#!/bin/bash
#
# git-make-release.sh <organisation> <repo> <tagname> [usual options]
#
# 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-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]"
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-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]"
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=
MAKEPRE=false
MAKEDRAFT=false
for param in $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 ;;
draft )
MAKEDRAFT=true ;;
prerelease )
MAKEPRE=true ;;
draftpre )
MAKEPRE=true;MAKEDRAFT=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
else
break
fi
done
if [ $DEBUG ] ; then echo "draft:$MAKEDRAFT*pre:$MAKEPRE"; fi
#check for release tag
if [ -z $3 ]; then
echo "Release tag not set";
exit 1;
fi
if [ $NOISY ] ; then echo "make-release $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/$2/$1"
if [ $DEBUG ] ; then echo "URL="$RemoteRepoURL; fi
# First see if release exists:
RESPONSE=$(curl -s -X 'GET' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/tags/SME$3" \
-H 'accept: application/json')
if [ $DEBUG ] ; then echo "See if Release exists response="$RESPONSE; fi
#parse result
ID=""
if echo "$RESPONSE" | jq empty >/dev/null 2>&1; then
if echo "$RESPONSE" | jq 'has("errors")' | grep -q 'true'; then
if [ $DEBUG ] ; then echo "Error detected:"; fi
ERROR=$(echo "$RESPONSE" | jq '.message')
if [ $DEBUG ] ; then echo "Error="$ERROR; fi
elif echo "$RESPONSE" | jq 'has("id")' | grep -q 'true'; then
if [ $DEBUG ] ; then echo "Id detected:"; fi
ID=$(echo "$RESPONSE" | jq -r '.id')
else
echo "No error or id detected ($RESPONSE)."
exit 1
fi
else
echo "Invalid JSON string ($RESPONSE)"
exit 1
fi
if [[ -z "$ID" ]]; then
# Create Release
if [ $NOISY ]; then echo "Creating Release $3 for $2/$1"; fi
# 3 branches 'cos I can't get the ascaping correct for using $MAKEPRE and $MAKEDRAFT in the -d json parameter to curl!
if [ $MAKEDRAFT = "true" ]; then
if [ $DEBUG ] ; then echo "$MAKEDRAFT:Creating draft 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 Draft Release of rpm built from git - `date` "'",
"draft": true,
"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
if [ $DEBUG ]; then echo "Create Release response="$RESPONSE; fi
exit 0
ID=$(echo $RESPONSE | jq -r '.id')
if [[ -z $ID ]] ; then
echo "Unable to create release for $2/$1 ($3)"
exit 1
fi
else
if [ $NOISY ]; then echo "Found Release $ID for $2/$1 ($3)"; fi
fi
if [ $DEBUG ] ; then echo "ID:"$ID; fi
# And use it to upload the rpm and src rpm
cd $WORKDIR/$2/$1
# Got to cd to rpm directory here
RPMDIR=$(ls $(basename `pwd`)*.rpm | sort | head -n 1 | sed 's/.src.rpm//' | sed 's/\./_/g')
echo $RPMDIR
# List the existing attachments
ASSETSRESPONSE=$(curl -s -X 'GET' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets" \
-H 'accept: application/json')
if [ $DEBUG ]; then echo "Asset response:"$ASSETSRESPONSE; fi
NAMES=$(echo $ASSETSRESPONSE | jq -r '.[].name' | paste -sd "," -)
if [ $DEBUG ]; then echo "Names:"$NAMES; fi
if [ $DEBUG ]; then echo $(ls $RPMDIR/*.rpm); fi
FULLPATH=$(pwd);
for File in $(ls $RPMDIR/*.rpm) ; do
if [ $NOISY ]; then echo "Uploading $File"; fi
BASEFile=$(basename $File)
if [ $DEBUG ]; then echo $BASEFile; fi
# Need to check if file is there already
if [[ "$NAMES" == *"$BASEFile"* ]] ; then
#Delete it - need the ID for it
if [ $NOISY ]; then echo "Deleting $BASEFile from $1/$2 $3 ($ID) release"; fi
ATTID=$(echo $ASSETSRESPONSE | jq -r '[ .[] | select(.name == "'"$BASEFile"'") | .id]')
#echo "ATTID:"$ATTID
ATTID=$(echo $ATTID | sed 's/\[//' | sed 's/\]//' | sed 's/ //g')
if [ $DEBUG ]; then echo "ATTID:"$ATTID; fi
RESPONSE=$(curl -s -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets/$ATTID" \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'accept: application/json')
if [ $DEBUG ]; then echo "DELETED Response:"$RESPONSE; fi
if [[ -z $RESPONSE ]] ; then
echo "Deleted $BASEFile from $1/$2 $3 ($ID) release"
else
echo "Delete failed $BASEFile from $2/$1 $3 ($ID) release ($RESPONSE)"
fi
else
if [ $DEBUG ]; then echo "Did not find $BASEFile in \"$NAMES\""; fi
fi
# Then send current version
FULLFILENAME=$FULLPATH/$File
if [ $DEBUG ] ; then echo $FULLFILENAME; fi
RESPONSE=$(curl -s -X 'POST' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets?name=$BASEFile" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: multipart/form-data' \
-F "attachment=@$FULLFILENAME;type=application/x-rpm")
if [ $DEBUG ]; then echo "Send current version($File) response="$RESPONSE; fi
if echo "$RESPONSE" | jq 'has("errors")' | grep -q 'true'; then
ERROR=$(echo "$RESPONSE" | jq '.message')
echo "$BASEFile not sucessfully uploaded ($ERROR)"
else
if [ $NOISY ]; then echo "$BASEFile sucessfully uploaded"; fi
fi
done

View File

@@ -1,114 +0,0 @@
#!/bin/bash
#
# Migrate (mirror) a remote repository
#
# migrate-repo.sh <reponame> <organisation> [<traget organisation>]
#
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-mirror-org.sh <source organisation> [<target organisation>]"
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"
if [[ -z $1 ]] ; then
echo "migrate-org.sh <source organisation> [<target organisation> <review>]"
echo "<target organisation> is optional and will default to the gitea user"
echo "<review> is optional and will echo the changes, but not execute"
exit 0
fi
DEBUG=
curlsilent="-s"
if [ ${smegit_DEBUG} == true ] ; then DEBUG=true ; fi
if [ $DEBUG ] ; then
echo "found ini file: $inifilename"
curlsilent="-v"
fi
MIRROR="copy"
TARGETORG=
for param in $2 $3 $4 ; do
if [ $param ] ; then
if [[ $param == "copy" || $param == "mirror" ]] ; then
MIRROR=$param
elif [[ $param == "review" ]] ; then
REVIEW=true
else
TARGETORG=$param
fi
else
break
fi
done
REMOTEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
LOCALACCESSTOKEN=${local_GITEAACCESSTOKEN}
REMOTEGITEAHOST=${remote_GITEAHOST}
LOCALGITEAHOST=${local_GITEAHOST}
if [ $DEBUG ] ; then echo "TARGETORG=$TARGETORG" ; fi
# check that the target organisation exists locally
if [ $DEBUG ] ; then echo "checking that $TARGETORG exists on $LOCALGITEAHOST" ; fi
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [[ "$RESPONSE" != "200" ]] ; then
echo "$TARGETORG does not exist on $LOCALGITEAHOST"
exit 1
fi
if [[ ! $REVIEW ]] ; then
while true; do
read -p "Are you sure?(y/n) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# get a list of repositories in the source organisation
for page in {1..10} ; do
if [ $DEBUG ] ; then echo "getting page $page of repos from $REMOTEGITHOST $1" ; fi
RESPONSE=$(curl $curlsilent -X 'GET' \
"$REMOTEGITEAHOST/api/v1/orgs/$1/repos?page=$page" \
-H 'accept: application/json' \
-H "Authorization: token $REMOTEACCESSTOKEN"
)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [[ $RESPONSE == '[]' ]] ; then
# we have them all
break
else
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
if [ $DEBUG ] ; then echo "git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR" ; fi
if [[ $REVIEW ]] ; then
echo "git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR"
else
git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR
fi
done
fi
done

View File

@@ -4,6 +4,13 @@
#
# migrate-repo.sh <reponame> <organisation> [<target organisation>]
#
if [[ -z $1 ]] ; then
echo "git_migrate-repo.sh <reponame> <organisation> [<target organization> <copy|mirror> <local> <debug>]"
echo "will migrate repo to local user unless <target organisation> specified"
exit 0
fi
# get config file and params
inifilename=$(echo ~)"/.smegit/config"
if [ ! -e $inifilename ] ; then
# Not here, look at system default
@@ -31,62 +38,67 @@ while read -r line || [[ -n "$line" ]]; do
fi
done < $inifilename
if [[ -z $1 ]] ; then
echo "git_migrate-repo.sh <reponame> <organisation> [<target organization>]"
echo "will migrate repo to local user unless <target organisation> specified"
exit 0
fi
DEBUG=
if [ ${smegit_DEBUG} == true ] ; then DEBUG=true ; fi
if [ $DEBUG ] ; then echo "found ini file: $inifilename" ; fi
curlsilent="-s"
if [ $DEBUG ] ; then curlsilent="-v" ; fi
SILENT="-s"
if [ $DEBUG ] ; then SILENT="-v" ; fi
REMOTEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
LOCALACCESSTOKEN=${local_GITEAACCESSTOKEN}
REMOTEGITEAHOST=${remote_GITEAHOST}
CLONEADDRESS=$REMOTEGITEAHOST/$2/$1.git
LOCALGITEAHOST=${local_GITEAHOST}
SOURCEHOST=${remote_GITEAHOST}
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
TARGETHOST=${local_GITEAHOST}
TARGETACCESSTOKEN=${local_GITEAACCESSTOKEN}
TARGETORG=${local_USER}
#if [ $3 ] ; then TARGETORG=$3 ; fi
MIRROR="false"
for param in $3 $4 ; do
if [ $param ] ; then
if [[ $param == "copy" || $param == "mirror" ]] ; then
if [ $param == "mirror" ] ; then MIRROR="true" ; fi
else
TARGETORG=$param
fi
else
break
fi
MIRROR=false
for param in $2 $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
local )
SOURCEHOST=${local_GITEAHOST}
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
CLONEADDRESS=$LOCALGITEAHOST/$2/$1.git
;;
copy )
MIRROR=false
;;
mirror )
MIRROR=true ;;
debug )
DEBUG=true ;;
* )
TARGETORG=$param ;;
esac
else
break
fi
done
CLONEADDRESS=$SOURCEHOST/$2/$1.git
if [ $DEBUG ] ; then
echo "MIRROR=$MIRROR"
echo "TARGETORG=$TARGETORG"
fi
# check that the TARGETORG exists
if [ $DEBUG ] ; then echo "checking if $TARGETORG exists on $LOCALGITEAHOST" ; fi
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG)
if [ $DEBUG ] ; then echo "checking if $TARGETORG exists on $TARGETHOST" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" $TARGETHOST/$TARGETORG)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [[ "$RESPONSE" != "200" ]] ; then
echo "$TARGETORG does not exist on $LOCALGITEAHOST"
echo "$TARGETORG does not exist on $TARGETHOST"
exit 1
fi
# And check if this repo already exists on the target
if [ $DEBUG ] ; then echo "checking if $TARGETORG/$1 already exists on $LOCALGITEAHOST" ; fi
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG/$1)
if [ $DEBUG ] ; then echo "checking if $TARGETORG/$1 already exists on $TARGETHOST" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" $TARGETHOST/$TARGETORG/$1)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [ "$RESPONSE" == "200" ] ; then
echo "Repository $TARGETORG/$1 already exists on $LOCALGITEAHOST - cannot migrate"
echo "Repository $TARGETORG/$1 already exists on $TARGETHOST - cannot migrate"
exit 1
fi
DATA=$(cat << EOT
"auth_token": "$REMOTEACCESSTOKEN",
"auth_token": "$TARGETACCESSTOKEN",
"clone_addr": "$CLONEADDRESS",
"issues": true,
"labels": true,
@@ -105,11 +117,11 @@ EOT
)
if [ $DEBUG ] ; then echo "JSON DATA=$DATA" ; fi
if [ $DEBUG ] ; then echo "Migrating $2/$1 as $TARGETORG/$1 on $LOCALGITEAHOST MIRROR=$MIRROR" ; fi
RESPONSE=$(curl $curlsilent -k -X 'POST' \
"$LOCALGITEAHOST/api/v1/repos/migrate" \
if [ $DEBUG ] ; then echo "Migrating $2/$1 as $TARGETORG/$1 on $TARGETHOST MIRROR=$MIRROR" ; fi
RESPONSE=$(curl $SILENT -k -X 'POST' \
"$TARGETHOST/api/v1/repos/migrate" \
-H 'accept: application/json' \
-H "Authorization: token $LOCALACCESSTOKEN" \
-H "Authorization: token $TARGETACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d "{ $DATA }"
)
@@ -117,7 +129,7 @@ if [ $DEBUG ] ; then echo $? $RESPONSE ; fi
# And check if this repo is there
if [ $DEBUG ] ; then echo "checking that $TARGETORG/$1 exists" ; fi
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG/$1)
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" $TARGETHOST/$TARGETORG/$1)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [ "$RESPONSE" == "200" ] ; then
msg="Repository $TARGETORG/$1 has been created"

126
git-post-create-repo.sh Executable file
View File

@@ -0,0 +1,126 @@
#!/bin/bash
#
# Fiddle with the newly created repo to fix things that cannot be done throug the gitea template
#
# $1 = Module name e.g. smeserver-null
# $2 = Organisation (smeserver or smecontrib)e
# $3 = "local" will use parameters set for local repository else it will use remote
#
if [[ -z $1 ]] ; then
echo "************git-post-create-repo.sh <modulename> <organization> [<local>]"
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-post-create-repo.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"
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
GITEAUser=$remote_USER
GITEAACCESSTOKEN=$remote_GITEAACCESSTOKEN
GITEAHOST=$remote_GITEAHOST
if [ $3 ] ; then
if [ "$3" == "local" ] ; then
GITEAUser=$local_USER
GITEAACCESSTOKEN=$local_GITEAACCESSTOKEN
GITEAHOST=$local_GITEAHOST
fi
fi
RemoteRepoURL="$GITEAHOST/$2/$1"
cd $WORKDIR/$2/$1
echo `pwd`
# Rename the spec file accordingly to $1
mv change-this-to-the-package-name.spec $1.spec
# Set the date in the spec file changelog to today
dateH=`date "+%a %b %d %Y"`
sed -i "s/Day MMMM DD YYYY/$dateH/" $1.spec
#Now write them all back to the repo
git add -A
git status
git commit -m "post create changes"
git push
# and fix up the external links to the Wiki and the Issues
# (this is a bug that I have logged) - they say is not supported.
TARGETPKG=$1
if [[ "$2" == "smecontribs" ]]; then
BASEORCONTRIB="contribs10"
PRODUCTBUGZILLA="SME%20Contribs"
else
BASEORCONTRIB="sme10"
PRODUCTBUGZILLA="SME%20Server%2010.X"
fi
TARGETORG=brianr
PRODUCTBUGZILLA=
WIKILINK="https://wiki.koozali.org"
RESPONSE=$(curl -X 'PATCH' \
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"description": "'"SMEServer Koozali developed repo for $TARGETPKG base"'",
"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"'"
}
}'
)
echo $RESPONSE
#That's All for now folks!!
exit 0

176
git-retag.sh Executable file
View 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

178
git-transfer-repo.sh Executable file
View File

@@ -0,0 +1,178 @@
#!/bin/bash
#
# Transfer a repo to a different user (or organisation)
# $1 = Module name e.g. e-smith-dnscache
# $2 = Source Organisation (any valid organisation or user)
# $3 = Target Organisation (any valid organisation or user - you need owner privileges)
# $4-$7 can appear in any order and are optional
# = "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 in debug mode
# = "silent" suppress success message
#
if [[ -z $1 ]] ; then
echo "Transfer a repo to a different user (or organisation)"
echo "git-transfer-repo.sh <repository> <source organization> ,target organisation> [<local> <force> <debug> <silent>]"
echo "<repository> = repository name (e.g. smeserver-clamav)"
echo "<source organisation> (any valid organisation or user)"
echo "<target organisation> (any valid organisation or user - you need owner privileges)"
echo " can appear in any order and are optional"
echo " - <local> will use parameters set for local repository, else it will use remote"
echo " - <force> will automagically delete an existing target repo, otherwise it will prompt"
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
REPO=$1
SOURCEORG=$2
TARGETORG=$3
GITEAHOST=${remote_GITEAHOST}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
DELETEIT=
NOOUTPUT=
for param in $4 $5 $6 $7; do
if [ $param ] ; then
case $param in
local )
GITEAHOST=${local_GITEAHOST}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
;;
force )
DELETEIT=true ;;
debug )
DEBUG=true ;;
silent )
NOOUTPUT=true ;;
* )
echo "Ignoring $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/$REPO is there!" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$REPO")
if [ "$RESPONSE" == "200" ]; then
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$REPO exists!" ; fi
else
echo "************Repository for $SOURCEORG/$REPO does not exist on $GITEAHOST ($RESPONSE)"
exit 1
fi
if [ $DEBUG ] ; then echo "Transferring $TARGETORG/$REPO to $SOURCEORG/$REPO" ; fi
#Check that target repo does not exist
if [ $DEBUG ] ; then echo "Check if $TARGETORG/$REPO is there!" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$TARGETORG/$REPO")
EXISTS=
if [ "$RESPONSE" == "200" ]; then
EXISTS=true
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$REPO exists!" ; fi
if [ -z ${DELETEIT} ] ; then
while true; do
read -p "$TARGETORG/$REPO 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 $TARGETORG/$REPO" ; fi
RESPONSE=$(curl "$checkSSL" "$SILENT" -o /dev/null -w "%{http_code}" -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$TARGETORG/$REPO" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" )
if [[ $RESPONSE != "204" ]] ; then
echo "Unable to delete $TARGETORG/$REPO ($RESPONSE)"
else
EXISTS=
fi
fi
else
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$REPO does not exist on $GITEAHOST" ; fi
fi
# Transfer the repo
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/$SOURCEORG/$REPO/transfer" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"new_owner": "'"$TARGETORG"'"
}'
)
fi
if [[ $EXISTS || $RESPONSE != "202" ]] ; then
echo "Unable to transfer $SOURCEORG/$REPO to $TARGETORG/$REPO ($RESPONSE) - Aborting!"
exit 1
else
if [[ -z $NOOUTPUT ]] ; then echo "$SOURCEORG/$REPO has been transferred to $TARGETORG/$REPO" ; fi
fi
exit 0

121
git-update-release-in-one-repo.sh Executable file
View 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
View 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

View File

@@ -5,17 +5,53 @@
if [[ -z $1 ]] ; then
echo "parse a list of parameters and execute script with those parameters"
echo "parse-list.sh <param file> <script> [<noisy> <additional> <additional> <additional>]"
echo "<param file> = name of file containing parameters"
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
echo "optional params can appear in any order"
echo " <noisy> show line being executed"
echo " <additional> additional params to be passed (up to 3)"
exit 0
echo "<param file|org='organisation'> name of file containing parameters"
echo " or the organisation list of repos"
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
echo "optional params can appear in any order"
echo " <review> show line being executed but do NOTHING!"
echo " <noisy> show line being executed"
echo " <additional> additional params to be passed (up to 3)"
exit 0
fi
if [[ ! -f $1 ]] ; then
# parse the command line parameters
PROCESSORG=
EXTRAPARAMS=
if [[ $1 == org=* ]] ; then
# using a list of the repos in this organisatoin as input
PROCESSORG=${1#*=}
EXTRAPARAMS=$PROCESSORG # add the org as the first additional param
# Get the ini file and relevant parameters - only needed for org processing
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"
else
# using a file as input
if [[ ! -f $1 ]] ; then
echo "Can NOT find $1 - Aborting"
exit 1
fi
fi
if [[ $(which $2 | grep "no $2") ]] ; then
@@ -23,13 +59,25 @@ if [[ $(which $2 | grep "no $2") ]] ; then
exit 1
fi
DEBUG=
REVIEW=
NOISY=
EXTRAPARAMS=
GITEAHOST=${remote_GITEAHOST}
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
for param in $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
review )
REVIEW=true ;;
noisy )
NOISY=true ;;
local )
GITEAHOST=${local_GITEAHOST}
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
EXTRAPARAMS=$EXTRAPARAMS" "$param
;;
debug )
DEBUG=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
@@ -38,10 +86,42 @@ for param in $3 $4 $5 $6; do
fi
done
# read through input file and run script using params from file
while read -r line
# Build array of parameters to cycle through
PARAMLIST=()
if [ $PROCESSORG ] ; then
# get a list of repositories in the source organisation and store in array of parameters
for page in {1..10} ; do
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITEAHOST $PROCESSORG" ; fi
RESPONSE=$(curl -s -X 'GET' \
"$GITEAHOST/api/v1/orgs/$PROCESSORG/repos?page=$page" \
-H 'accept: application/json' \
-H "Authorization: token $ACCESSTOKEN"
)
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
if [[ $RESPONSE == '[]' ]] ; then
# we have them all
break
else
PARAMLIST="$PARAMLIST $(echo $RESPONSE | grep -oP '(?<="name":").+?(?=")')"
fi
done
else
# load array of parameters from input file
while read -r line ; do PARAMLIST+=($line) ; done < $1
fi
# Cycle through array of parameters and execute script
for param in ${PARAMLIST[@]}
do
if [[ $NOISY ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi
done < $1
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $param $EXTRAPARAMS" ; fi
if [[ -z $REVIEW ]] ; then
if [[ $param ]] ; then
RESPONSE=$($2 $param $EXTRAPARAMS) ; rc=$?
if [ $rc -ne 0 ] ; then echo "($rc)\n$RESPONSE" ; fi
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
fi
fi
done
exit 0

View File

@@ -1,295 +0,0 @@
#!/bin/bash
#
# Rename an e-smith package as smeserver and change relevant files
# $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
# = "debug" run in debug mode
# 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> <debug>]"
echo "<modulename> = Module/package name (e.g. e-smith-dnscache)"
echo " can appear in any order and are optional"
echo " - <organisation> (smeserver, smecontribs or user - 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 " - <debug> run in debug mode"
echo " - <nooutput> completely suppress all output"
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
SOURCEHOST=${remote_GITEAHOST}
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
SOURCEORG="smeserver"
TARGETORG=${remote_USER}
DELETEIT=
NOOUTPUT=
for param in $2 $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
local )
SOURCEHOST=${local_GITEAHOST}
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
TARGETORG=${local_USER} ;;
force )
DELETEIT=true ;;
debug )
DEBUG=true ;;
nooutput )
NOOUTPUT=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"
#Extract <pkg>
SOURCEPKG=$1
TARGETPKG=${SOURCEPKG/e-smith/smeserver}
#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}" "$SOURCEHOST/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 $SOURCEHOST ($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}" "$SOURCEHOST/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 $SOURCEHOST ($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' \
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
-H 'accept: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" )
fi
else
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $SOURCEHOST" ; fi
fi
#Fork e-smith-<pkg> into users repositories as smeserver-<pkg>
# - add bugzilla and wiki references
if [ $DEBUG ] ; then echo "Forking $SORCEORG/$SOURCEPKG into $TARGETORG/$TARGETPKG!" ; fi
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'POST' \
"https://src.koozali.org/api/v1/repos/$SOURCEORG/$SOURCEPKG/forks" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" \
-d '{
"name": "'"$TARGETPKG"'",
"description": "'"SMEServer Koozali developed git repo for $TARGETPKG base"'"
}')
# create a Bugzilla URL
PRODUCTBUGZILLA="SME%20Server%2010.X"
if [[ "$SOURCEORG" == "smecontribs" ]]; then
PRODUCTBUGZILLA="SME%20Contribs"
fi
# find the relevant wiki entry
WIKILINK="https://wiki.koozali.org"
MEDIAWIKI_SITE="https://wiki.koozali.org/api.php"
SEARCH_TERM=${SOURCEPKG/e-smith-/}
# Call the API to perform the search and store the JSON response in a variable
RESPONSE=$(curl -s "$MEDIAWIKI_SITE?action=query&format=json&list=search&srsearch=${SEARCH_TERM}&srprop=size%7Cwordcount%7Ctimestamp%7Csnippet&srlimit=10")
# Use jq to extract the titles and pageids of the pages that match the search term (case-insensitive)
RESULTS=$(echo "$RESPONSE" | jq -r '.query.search[] | select(.title | ascii_downcase | contains("'"${SEARCH_TERM}"'" | ascii_downcase)) | .title, .pageid')
# Loop through the results and construct the URL for each page
URLS=$(while read -r TITLE; do \
read -r PAGEID; \
URL="https://wiki.koozali.org/${TITLE}"; \
URL=$(echo $URL | sed 's/ /_/g'); \
echo "<br />${URL}"; \
done <<< "${RESULTS}" )
# and get the first non french (sorry JP!)
WIKILINK=$(while read -r TITLE; do \
read -r PAGEID; \
URL="https://wiki.koozali.org/${TITLE}"; \
URL=$(echo $URL | sed 's/ /_/g'); \
if [[ ! "$URL" =~ 'fr' ]] ; then echo "${URL}"; break; fi \
done <<< "${RESULTS}" )
if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
-H 'accept: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"description": "'"SMEServer Koozali developed repo for $TARGETPKG base"'",
"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 $SOURCEHOST/$TARGETORG/$TARGETPKG.git" ; fi
cd $GITFiles
git clone "$SOURCEHOST/$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 "s/^%define name.*$SOURCEPKG/%define name $TARGETPKG/" "$TARGETPKG.spec"
sed -i "/^%description/{ n; s/e-smith/smeserver/}" "$TARGETPKG.spec"
# - 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 git rm archivefilename $QUIET ; 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
#Convert repository to a Regular Repository (rather than fork)
#Can't do via API call ATM, so leave a message
if [[ -z $NOOUTPUT ]] ; then
echo "$SOURCEORG/$SOURCEPKG has been renamed as $TARGETORG/$TARGETPKG"
echo "It is still a forked repository, so you need to 'Convert to Regular Repository' in GITEA and then 'Transfer' it to it's final Organisation"
fi
exit 0