diff options
Diffstat (limited to '0003-Support-osc-copyprj-in-api-by-Islam-Amer-usage-osc-c.patch')
-rw-r--r-- | 0003-Support-osc-copyprj-in-api-by-Islam-Amer-usage-osc-c.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/0003-Support-osc-copyprj-in-api-by-Islam-Amer-usage-osc-c.patch b/0003-Support-osc-copyprj-in-api-by-Islam-Amer-usage-osc-c.patch new file mode 100644 index 000000000000..0a35306e86f9 --- /dev/null +++ b/0003-Support-osc-copyprj-in-api-by-Islam-Amer-usage-osc-c.patch @@ -0,0 +1,116 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Marko Lemmetty <marko.lemmetty@jollamobile.com> +Date: Fri, 15 May 2020 14:20:54 +0300 +Subject: [PATCH] Support 'osc copyprj' in api by Islam Amer usage: osc copyprj + SOURCEPRJ DESTPRJ + + A way to copy a project and all packages in it + It can not yet be done across buildservice instances + The user must be able to create DESTPRJ +--- + osc/commandline.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ + osc/core.py | 28 +++++++++++++++++++++++++ + 2 files changed, 80 insertions(+) + +diff --git a/osc/commandline.py b/osc/commandline.py +index b7c19bc63e1dbd5566ead116890df62a72a4bb05..ad45daa45efbb4f4e53e2bcc03e6731a22e78e59 100644 +--- a/osc/commandline.py ++++ b/osc/commandline.py +@@ -2106,6 +2106,58 @@ class Osc(cmdln.Cmdln): + else: + raise oscerr.WrongOptions('The --delete switch is only for pattern metadata or attributes.') + ++ @cmdln.option('-b', '--with-binaries', action='store_true', ++ help='copy the built binaries over to avoid a rebuild') ++ @cmdln.option('-x', '--with-history', action='store_true', ++ help='replicate the history of each package.') ++ @cmdln.option('-o', '--make-older', action='store_true', ++ help='No idea') ++ @cmdln.option('-r', '--re-sign', action='store_true', ++ help='re-sign the binaries') ++ @cmdln.option('-m', '--message', metavar='TEXT', ++ help='specify message TEXT') ++ def do_copyprj(self, subcmd, opts, *args): ++ """ ++ Copy a project ++ ++ A way to copy a project and all packages in it ++ ++ It can not yet be done across buildservice instances ++ ++ The user must be able to create DESTPRJ ++ ++ usage: ++ osc copyprj SOURCEPRJ DESTPRJ ++ """ ++ ++ args = slash_split(args) ++ ++ if not args or len(args) != 2: ++ raise oscerr.WrongArgs('Incorrect number of arguments.') ++ ++ src_project = args[0] ++ dst_project = args[1] ++ ++ src_apiurl = conf.config['apiurl'] ++ ++ if opts.message: ++ comment = opts.message ++ else: ++ comment = 'osc copyprj from project:%s' % ( src_project ) ++ ++ if src_project == dst_project: ++ raise oscerr.WrongArgs('Source and destination are the same.') ++ ++ print("calling cp") ++ r = copy_prj(src_apiurl, src_project, dst_project, ++ withbinaries = opts.with_binaries, ++ withhistory = opts.with_history, ++ makeolder = opts.make_older, ++ resign = opts.re_sign, ++ comment = comment) ++ print("done cp") ++ print(r) ++ + # TODO: rewrite and consolidate the current submitrequest/createrequest "mess" + + @cmdln.option('-m', '--message', metavar='TEXT', +diff --git a/osc/core.py b/osc/core.py +index 3a5543dc356d9831d5f868ff0ae62155e4135682..116d4f2e895d1ed03aba483588cd78ef168175f7 100644 +--- a/osc/core.py ++++ b/osc/core.py +@@ -6279,6 +6279,34 @@ def copy_pac( + raise oscerr.APIError('failed to copy: %s' % ', '.join(todo)) + return 'Done.' + ++def copy_prj(src_apiurl, src_project, dst_project, ++ withbinaries = False, ++ withhistory = False, ++ makeolder = False, ++ resign = False, ++ comment = None): ++ """ ++ Create a copy of a project. ++ ++ Copying can only be done on the server, in a single api call. ++ """ ++ ++ print('Copying project...') ++ query = {'cmd': 'copy', 'oproject': src_project } ++ if withbinaries: ++ query['withbinaries'] = '1' ++ if withhistory: ++ query['withhistory'] = '1' ++ if makeolder: ++ query['makeolder'] = '1' ++ if resign: ++ query['resign'] = '1' ++ if comment: ++ query['comment'] = comment ++ u = makeurl(src_apiurl, ['source', dst_project], query=query) ++ print("copyprj ", u, file=sys.stderr) ++ f = http_POST(u) ++ return f.read() + + def lock(apiurl: str, project: str, package: str, msg: str = None): + url_path = ["source", project] |