From 6e9db457081ba3a3b57f88034e42cd898b5518df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= <lfrb@collabora.com> Date: Thu, 10 Nov 2016 14:31:19 -0500 Subject: [PATCH] Add 'installed' command to show currently installed sysroot version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Differential Revision: https://phabricator.apertis.org/D5208 --- doc/man/ade-sysroot.1 | 11 +++++++++++ tests/Makefile | 2 +- tests/{test-list => test-installed} | 17 +++++++++++++++-- tools/ade | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) rename tests/{test-list => test-installed} (60%) diff --git a/doc/man/ade-sysroot.1 b/doc/man/ade-sysroot.1 index 240a888..5a02c60 100644 --- a/doc/man/ade-sysroot.1 +++ b/doc/man/ade-sysroot.1 @@ -14,6 +14,8 @@ ade-sysroot \- Manage set of installed Apertis sysroots .nf \fIade sysroot\fR [--config=<config>] [--path=<path>] \fIade sysroot list\fR +\fIade sysroot installed\fR +\fIade sysroot installed\fR --distro=<distro> --release=<release> [--arch=<arch>] \fIade sysroot latest\fR \fIade sysroot latest\fR --distro=<distro> --release=<release> [--arch=<arch>] \fIade sysroot latest\fR --url=<url> @@ -90,6 +92,15 @@ Shows a list of the currently installed sysroots\&. .sp .RE .PP +\fIinstalled\fR +.RS 4 +Retrieves the currently installed version of a sysroot\&. +.sp +See \fBSYSROOT SELECTION\fR for details about how the target sysroot +is selected\&. +.sp +.RE +.PP \fIlatest\fR .RS 4 Retrieves the latest available version for a sysroot\&. diff --git a/tests/Makefile b/tests/Makefile index 714b37b..9751499 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -21,7 +21,7 @@ short = $(firstword $(subst _, $(space), $(1))) sedrule = 's/@DISTRO@/$(call distro,$(1))/; s/@RELEASE@/$(call release,$(1))/; s/@ARCH@/$(call arch,$(1))/; s/@BUILD@/$(call build,$(1))/' TESTS = \ - test-list \ + test-installed \ test-latest \ test-download \ test-verify \ diff --git a/tests/test-list b/tests/test-installed similarity index 60% rename from tests/test-list rename to tests/test-installed index 2ca38fe..93db32c 100755 --- a/tests/test-list +++ b/tests/test-installed @@ -12,9 +12,13 @@ import os from test_util import should_succeed, should_fail, split_elements -from test_util import BASE_TAG, BASE_INSTALL, LATEST_SYSROOTS +from test_util import BASE_INSTALL, BASE_TAG, LATEST_SYSROOTS # Utility functions +def check_sysroot(result, sysroot): + expected = BASE_TAG.format(*sysroot) + return result['InstalledVersion'] == expected + def check_list(result, expected_sysroots): result_sysroots = split_elements(result['InstalledSysroots']) if len(expected_sysroots) != len(result_sysroots): @@ -27,10 +31,19 @@ def check_list(result, expected_sysroots): return False return True +# Test "ade installed" usage +for sysroot in LATEST_SYSROOTS: + params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]] + should_succeed('installed', *params, path=BASE_INSTALL, + check=lambda x: check_sysroot(x, sysroot)) + # Test "ade list" usage should_succeed('list', path=BASE_INSTALL, check=lambda x: check_list(x, LATEST_SYSROOTS)) # Empty directory -should_succeed('list', path=os.path.join(BASE_INSTALL, 'missing'), +should_succeed('installed', '--distro', 'eraroj', '--release', '16.09', + path=os.path.join(os.getcwd(), 'missing'), + check=lambda x: not x) +should_succeed('list', path=os.path.join(os.getcwd(), 'missing'), check=lambda x: check_list(x, [])) diff --git a/tools/ade b/tools/ade index 91b5e55..0aa3fd1 100755 --- a/tools/ade +++ b/tools/ade @@ -505,6 +505,18 @@ class Ade: l = [version.get_tag() for version in versions] print('InstalledSysroots:' + ';'.join(l)) + def do_sysroot_installed(self): + self.validate_install_path() + self.validate_sysroot_id() + version = self.get_installed_version() + if version: + self.info("* Retrieved current version: {0}{1}{2}".format(Colors.WARNING, version, Colors.ENDC)) + if self.format == 'parseable': + print('InstalledVersion:' + version.get_tag()) + else: + self.info("* Sysroot {0}{1} {2} ({3}){4} is not currently installed" + .format(Colors.OKBLUE, self.distro, self.release, self.arch, Colors.ENDC)) + def do_sysroot_latest(self): self.validate_sysroot_id() self.validate_url() @@ -689,6 +701,8 @@ if __name__ == '__main__': # Sysroot subcommands parser = sysroot_subparsers.add_parser('list', help='List all installed sysroots') + parser = sysroot_subparsers.add_parser('installed', help='Retrieve version of currently installed sysroot', + parents=[sysroot_id_parser]) parser = sysroot_subparsers.add_parser('latest', help='Retrieve version of latest available sysroot', parents=[sysroot_id_parser, sysroot_url_parser]) parser = sysroot_subparsers.add_parser('download', help='Download latest sysroot archive', -- GitLab