diff --git a/tests/data/duplicatedframeworks/category.py b/tests/data/duplicatedframeworks/category.py index f5becb2b..3e6a7c1a 100644 --- a/tests/data/duplicatedframeworks/category.py +++ b/tests/data/duplicatedframeworks/category.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/duplicatedframeworks/samecategory.py b/tests/data/duplicatedframeworks/samecategory.py index 33910dc8..6be898c2 100644 --- a/tests/data/duplicatedframeworks/samecategory.py +++ b/tests/data/duplicatedframeworks/samecategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkD(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/multipledefaultsframeworks/defaultframeworkformain.py b/tests/data/multipledefaultsframeworks/defaultframeworkformain.py index 003ccfbb..83e3e4d4 100644 --- a/tests/data/multipledefaultsframeworks/defaultframeworkformain.py +++ b/tests/data/multipledefaultsframeworks/defaultframeworkformain.py @@ -34,3 +34,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/multipledefaultsframeworks/twodefaultscategory.py b/tests/data/multipledefaultsframeworks/twodefaultscategory.py index 4cfec322..d7cd9d60 100644 --- a/tests/data/multipledefaultsframeworks/twodefaultscategory.py +++ b/tests/data/multipledefaultsframeworks/twodefaultscategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/overlayframeworks/duplicatedcategory.py b/tests/data/overlayframeworks/duplicatedcategory.py index 6bdb59ae..60a4c161 100644 --- a/tests/data/overlayframeworks/duplicatedcategory.py +++ b/tests/data/overlayframeworks/duplicatedcategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/overlayframeworks/duplicatedcategory2.py b/tests/data/overlayframeworks/duplicatedcategory2.py index da942a2b..59ad8598 100644 --- a/tests/data/overlayframeworks/duplicatedcategory2.py +++ b/tests/data/overlayframeworks/duplicatedcategory2.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/overlayframeworks/overlayframeworks.py b/tests/data/overlayframeworks/overlayframeworks.py index 7f45faca..c2b72f9f 100644 --- a/tests/data/overlayframeworks/overlayframeworks.py +++ b/tests/data/overlayframeworks/overlayframeworks.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/overlayframeworks/withcategory.py b/tests/data/overlayframeworks/withcategory.py index 7f45faca..c2b72f9f 100644 --- a/tests/data/overlayframeworks/withcategory.py +++ b/tests/data/overlayframeworks/withcategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/overlayframeworks/withcategory2.py b/tests/data/overlayframeworks/withcategory2.py index a59264a7..e3a4ab3b 100644 --- a/tests/data/overlayframeworks/withcategory2.py +++ b/tests/data/overlayframeworks/withcategory2.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/anotherothercategory.py b/tests/data/testframeworks/anotherothercategory.py index 9a13b805..19cb0a0a 100644 --- a/tests/data/testframeworks/anotherothercategory.py +++ b/tests/data/testframeworks/anotherothercategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return False @@ -58,6 +61,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return True diff --git a/tests/data/testframeworks/category_f.py b/tests/data/testframeworks/category_f.py index 183b4e9f..39a1014b 100644 --- a/tests/data/testframeworks/category_f.py +++ b/tests/data/testframeworks/category_f.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -55,6 +58,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkC(umake.frameworks.BaseFramework): @@ -67,3 +73,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/category_g.py b/tests/data/testframeworks/category_g.py index dd2b46e5..5e2c67a8 100644 --- a/tests/data/testframeworks/category_g.py +++ b/tests/data/testframeworks/category_g.py @@ -42,6 +42,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -54,3 +57,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/framework_for_removal.py b/tests/data/testframeworks/framework_for_removal.py index c322ea82..f010e5c9 100644 --- a/tests/data/testframeworks/framework_for_removal.py +++ b/tests/data/testframeworks/framework_for_removal.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkRinstalled(umake.frameworks.BaseFramework): @@ -54,6 +57,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return True @@ -72,6 +78,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return True diff --git a/tests/data/testframeworks/is_installable.py b/tests/data/testframeworks/is_installable.py index edf95831..e33da244 100644 --- a/tests/data/testframeworks/is_installable.py +++ b/tests/data/testframeworks/is_installable.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installable(self): return super().is_installable @@ -60,6 +63,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installable(self): """overridden to say True""" @@ -79,6 +85,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installable(self): """overridden to say False""" diff --git a/tests/data/testframeworks/oneframeworkcategory.py b/tests/data/testframeworks/oneframeworkcategory.py index a3cab683..0ff3e72c 100644 --- a/tests/data/testframeworks/oneframeworkcategory.py +++ b/tests/data/testframeworks/oneframeworkcategory.py @@ -40,3 +40,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/othercategory.py b/tests/data/testframeworks/othercategory.py index 7a9ce825..a17df3ae 100644 --- a/tests/data/testframeworks/othercategory.py +++ b/tests/data/testframeworks/othercategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return True @@ -58,6 +61,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installed(self): return True diff --git a/tests/data/testframeworks/restrictions.py b/tests/data/testframeworks/restrictions.py index e2dc452c..e22de1f7 100644 --- a/tests/data/testframeworks/restrictions.py +++ b/tests/data/testframeworks/restrictions.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -54,6 +57,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkC(umake.frameworks.BaseFramework): @@ -67,3 +73,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/uninstantiableframework.py b/tests/data/testframeworks/uninstantiableframework.py index ad0e39cf..fc3150b7 100644 --- a/tests/data/testframeworks/uninstantiableframework.py +++ b/tests/data/testframeworks/uninstantiableframework.py @@ -40,6 +40,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class InheritedFromUninstantiable(Uninstantiable): diff --git a/tests/data/testframeworks/withcategory.py b/tests/data/testframeworks/withcategory.py index e80a7426..2e90e842 100644 --- a/tests/data/testframeworks/withcategory.py +++ b/tests/data/testframeworks/withcategory.py @@ -41,6 +41,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkB(umake.frameworks.BaseFramework): @@ -53,3 +56,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/data/testframeworks/withoutcategory.py b/tests/data/testframeworks/withoutcategory.py index d858c261..5126ebf1 100644 --- a/tests/data/testframeworks/withoutcategory.py +++ b/tests/data/testframeworks/withoutcategory.py @@ -35,6 +35,9 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + def depends(self): + super().depends() + class FrameworkFreeB(umake.frameworks.BaseFramework): @@ -47,3 +50,6 @@ def setup(self, install_path=None, auto_accept_license=False): def remove(self): super().remove() + + def depends(self): + super().depends() diff --git a/tests/small/test_frameworks_loader.py b/tests/small/test_frameworks_loader.py index cfb853d2..ebea974c 100644 --- a/tests/small/test_frameworks_loader.py +++ b/tests/small/test_frameworks_loader.py @@ -297,6 +297,7 @@ def test_parse_category_and_framework_run_correct_framework(self): args.framework = "framework-b" args.accept_license = False args.remove = False + args.depends = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) @@ -312,12 +313,29 @@ def test_parse_no_framework_run_default_for_category(self): args.framework = None args.accept_license = False args.remove = False + args.depends = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-a"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + def test_parse_category_and_framework_list_dependencies(self): + """Parsing category will run default framework""" + args = Mock() + args.category = "category-a" + args.destdir = None + args.framework = "framework-b" + args.depends = True + args.accept_license = False + args.remove = False + with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "depends")\ + as depends_call: + self.CategoryHandler.categories[args.category].run_for(args) + self.assertTrue(depends_call.called) + depends_call.assert_called_with() + # self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + def test_parse_category_and_framework_run_correct_remove_framework(self): """Parsing category and framework with --remove run remove on right category and framework""" args = Mock() @@ -377,6 +395,7 @@ def test_parse_category_and_framework_cannot_install_not_installable_but_install args.framework = "framework-r-installed-not-installable" args.accept_license = False args.remove = False + args.depends = False self.assertRaises(BaseException, self.CategoryHandler.categories[args.category].run_for, args) def test_parse_category_and_framework_can_remove_not_installable_but_installed_framework(self): @@ -402,6 +421,7 @@ def test_parse_category_and_framework_get_accept_license_arg(self): args.framework = "framework-b" args.accept_license = True args.remove = False + args.depends = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) @@ -1289,6 +1309,9 @@ def setup(self): def remove(self): super().remove() + def depends(self): + super().depends() + @property def is_installable(self): return False diff --git a/umake/__init__.py b/umake/__init__.py index 13b5749e..83bb45af 100644 --- a/umake/__init__.py +++ b/umake/__init__.py @@ -132,6 +132,7 @@ def main(): parser.add_argument("-v", "--verbose", action="count", default=0, help=_("Increase output verbosity (2 levels)")) parser.add_argument('-r', '--remove', action="store_true", help=_("Remove specified framework if installed")) + parser.add_argument('-d', '--depends', action="store_true", help=_("List specified framework dependencies")) list_group = parser.add_argument_group("List frameworks").add_mutually_exclusive_group() list_group.add_argument('-l', '--list', action="store_true", help=_("List all frameworks")) diff --git a/umake/frameworks/__init__.py b/umake/frameworks/__init__.py index 4d825406..a4ee5442 100644 --- a/umake/frameworks/__init__.py +++ b/umake/frameworks/__init__.py @@ -263,6 +263,13 @@ def setup(self): # be a normal, kind user as we don't want normal files to be written as root switch_to_current_user() + @abc.abstractmethod + def depends(self): + """Method call to list depends for current framework""" + if not self.is_installable and not self.is_installed: + logger.error(_("Framework {} is not installable".format(self.name))) + UI.return_main_screen(status_code=2) + @abc.abstractmethod def remove(self): """Method call to remove the current framework""" @@ -302,7 +309,8 @@ def install_framework_parser(self, parser): help=_("Remove framework if installed")) this_framework_parser.add_argument('--dry-run', dest="dry_run", action="store_true", help=_("Fetch only the url, then exit.")) - + this_framework_parser.add_argument('-d', '--depends', action="store_true", + help=_("List dependencies")) if self.expect_license: this_framework_parser.add_argument('--accept-license', dest="accept_license", action="store_true", help=_("Accept license without prompting")) @@ -317,6 +325,12 @@ def run_for(self, args): logger.error(message) UI.return_main_screen(status_code=2) self.remove() + if args.depends: + if args.destdir: + message = "You can't specify a destination dir while listing framework dependencies" + logger.error(message) + UI.return_main_screen(status_code=2) + self.depends() else: install_path = None auto_accept_license = False diff --git a/umake/frameworks/baseinstaller.py b/umake/frameworks/baseinstaller.py index fd00199a..05599dea 100644 --- a/umake/frameworks/baseinstaller.py +++ b/umake/frameworks/baseinstaller.py @@ -122,6 +122,15 @@ def reinstall(self): self.confirm_path(self.arg_install_path) remove_framework_envs_from_user(self.name) + def depends(self): + """List necessary apt dependencies""" + if not self.need_root_access: + UI.display(DisplayMessage("Required packages are installed")) + else: + UI.display(DisplayMessage("Required packages will be installed")) + UI.display(DisplayMessage(' '.join(self.packages_requirements))) + UI.return_main_screen(status_code=0) + def remove(self): """Remove current framework if installed