aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2024-01-23 09:16:12 +0100
committerPapoteur <papoteur@mageia.org>2024-01-23 09:16:12 +0100
commit91d2f2af45b29b9537e4e0c93b69bd17bb1cc772 (patch)
treef10cd9bc97e29f4a538217590763a6a0121ae2c0
parent9ed7d2f462b94e37fb3bb52e33ac37b0232292bc (diff)
downloadmgarepo-91d2f2af45b29b9537e4e0c93b69bd17bb1cc772.tar
mgarepo-91d2f2af45b29b9537e4e0c93b69bd17bb1cc772.tar.gz
mgarepo-91d2f2af45b29b9537e4e0c93b69bd17bb1cc772.tar.bz2
mgarepo-91d2f2af45b29b9537e4e0c93b69bd17bb1cc772.tar.xz
mgarepo-91d2f2af45b29b9537e4e0c93b69bd17bb1cc772.zip
Add cancel command
-rw-r--r--MgaRepo/commands/cancel.py64
-rwxr-xr-xmgarepo3
-rw-r--r--mgarepo-example.conf3
3 files changed, 69 insertions, 1 deletions
diff --git a/MgaRepo/commands/cancel.py b/MgaRepo/commands/cancel.py
new file mode 100644
index 0000000..899f0d5
--- /dev/null
+++ b/MgaRepo/commands/cancel.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+from MgaRepo import Error, config, layout, mirror
+from MgaRepo.svn import SVN
+from MgaRepo.command import *
+from MgaRepo.rpmutil import get_spec, get_submit_info
+from MgaRepo.util import get_auth, execcmd, get_helper
+import urllib.request, urllib.parse, urllib.error
+import getopt
+import sys
+import re
+import subprocess
+import uuid
+
+import xmlrpc.client
+
+HELP = """\
+Usage: mgarepo cancel [OPTIONS] [PACKAGE_SUBMISSION]
+
+Options:
+ -l cancel the last submission
+
+Examples:
+ mgarepo cancel -l
+ mgarepo cancel cauldron/core/release/20231231235959.pterjan.duvel.424242
+"""
+
+DEFAULT_TARGET = "cauldron"
+
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-l", dest="last", default=None)
+ opts, args = parser.parse_args()
+ opts.url = args[0]
+ return opts
+
+def cancel(url, last = False, submithost=None):
+ if submithost is None:
+ submithost = config.get("submit", "host")
+ if submithost is None:
+ # extract the submit host from the svn host
+ type, rest = urllib.parse.splittype(pkgdirurl)
+ host, path = urllib.parse.splithost(rest)
+ user, host = urllib.parse.splituser(host)
+ submithost, port = urllib.parse.splitport(host)
+ del type, user, port, path, rest
+ print(f"Trying to cancel {url}")
+ # runs a cancel_build in the server through ssh
+ cancel_build = get_helper("cancel_build")
+ command = ["ssh", submithost, cancel_build, url]
+ print(command)
+ status, output = execcmd(*command)
+ if status == 0:
+ print("Package canceled!")
+ else:
+ sys.stderr.write(output)
+ sys.exit(status)
+
+
+def main():
+ do_command(parse_options, cancel)
+
+
+# vim:et:ts=4:sw=4
diff --git a/mgarepo b/mgarepo
index 1d27a8b..2fa92f6 100755
--- a/mgarepo
+++ b/mgarepo
@@ -12,6 +12,7 @@ Usage: mgarepo COMMAND [COMMAND ARGUMENTS]
Tool to access and manage a package repository structure.
Useful commands:
+ cancel cancel a running build
co checkout a package
ci commit changes
sync add-remove all file changes from the .spec
@@ -85,7 +86,7 @@ def dispatch_command(command, argv, debug=0):
raise Error("invalid command '%s'" % command)
raise
command_module.main()
-
+
if __name__ == "__main__":
try:
plugins.load()
diff --git a/mgarepo-example.conf b/mgarepo-example.conf
index c80bbe8..0724fb2 100644
--- a/mgarepo-example.conf
+++ b/mgarepo-example.conf
@@ -32,6 +32,9 @@ create-srpm = /usr/share/mgarepo/create-srpm
# upload-srpm is called by create-srpm to copy the generated .src.rpm to
# the proper build queue
upload-srpm = /usr/local/bin/youri.devel
+# cancel a build
+cancel_build = cancel_build
+
# this section maps usernames found in svn commits to the ones that must be
# shown in the changelog