diff --git a/mpcdf_remove.py b/mpcdf_remove.py new file mode 100644 index 0000000000000000000000000000000000000000..08af85eb0cd244f768144cf29a16c94286b815ed --- /dev/null +++ b/mpcdf_remove.py @@ -0,0 +1,47 @@ +#!/usr/bin/python2 +from __future__ import print_function +from functools import reduce + +import mpcdf_common + +import os +import osc +import osc.conf +import osc.core +import osc.cmdln + + +def do_mpcdf_remove(self, subcmd, opts, *args): + """${cmd_name}: Removes a package from all sub-projects of software: + + Usage: + osc ${cmd_name} [PACKAGE] + + ${cmd_option_list} + + """ + + if len(args) == 0: + if osc.core.is_package_dir(os.curdir): + package = osc.core.store_read_package(os.curdir) + else: + raise osc.oscerr.WrongArgs('Specify PACKAGE or run command in an osc checkout directory') + + elif len(args) == 1: + package, = args + else: + raise osc.oscerr.WrongArgs("Too many arguments") + + api_url = self.get_api_url() + + projects = filter(lambda s: s.startswith("software:") and not (s == "software:dist" or s == "software:images"), + osc.core.meta_get_project_list(api_url)) + + for project in projects: + print("Removing from", project) + osc.core.delete_package(api_url, project, package) + + print("\nThe package still exists in 'software', you can undo what you did with\n\n" + " osc mcpdf_push\n\n" + "To fully delete the package remove it also from 'software', and possibly your\n" + "home: project, using the web-inteface or 'osc rdelete'")