Skip to content
Snippets Groups Projects
Commit fc74db6f authored by Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Committed by Guillaume Desmottes
Browse files

Add info command to retrieve information about an ADE object


For now, it only supports retrieving information about an
installed sysroot, but it could be extended to retrieve
information about devices, projects, bundles, etc.

Signed-off-by: default avatarLouis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: default avatarGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D5226
parent df0fb3c6
No related branches found
No related tags found
No related merge requests found
.TH ADE\-INFO 1 09/12/2016 0.1612.0 Apertis\ Development\ Tools\ Manual
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH NAME
ade-info \- Print information about an entity
.SH SYNOPSIS
.sp
.nf
\fIade info\fR --sysroot <sysroot>
.fi
.sp
.SH DESCRIPTION
.sp
Retrieve information about a sysroot or another ADE object\&.
.sp
.SH OPTIONS
.sp
.PP
\fI\-\-sysroot\fR
.RS 4
Return installed version and path of given sysroot (e.g. apertis-16.12-armhf)\&.
.sp
.RE
.SH SEE ALSO
ade(1)
.SH COPYRIGHT
Copyright (c) 2016 Collabora Ltd.
......@@ -12,7 +12,7 @@ ade \- Apertis Development Environment
.SH SYNOPSIS
.sp
.nf
\fIade sysroot\fR
\fIade\fR [--format=<format>] <command> [<args>]
.fi
.sp
.SH DESCRIPTION
......@@ -38,12 +38,22 @@ Sets the output format of the tool\&.
.SH COMMANDS
.sp
.PP
\fIinfo\fR
.RS 4
Print information about an entity\&.
.sp
See \fBade-info(1)\fR
.sp
.RE
.PP
\fIsysroot\fR
.RS 4
Manages the set of installed sysroots needed for cross-compilation\&.
.sp
See \fBade-sysroot(1)\fR
.sp
.RE
.sp
.SH SEE ALSO
ade-sysroot(1)
......
......@@ -136,6 +136,13 @@ class SysrootVersion:
raise ValueError("'url'")
self.url = url
def from_id(string):
p = re.compile("^\s*(\w*)-(\d\d\.\d\d)-(\w*)\s*$")
m = p.match(string.lower())
if not m:
raise ValueError
return SysrootVersion(m.groups()[0], m.groups()[1], m.groups()[2])
def from_string(string):
p = re.compile("^\s*(\w*)\s*(\d\d\.\d\d) (\d{8,8})\.(\d+)\s*(\w*)\s*$")
m = p.match(string)
......@@ -477,6 +484,9 @@ class Ade:
self.file = None
self.dest = None
self.target = None
self.sysroot = None
self.sysroot_version = None
self.distro = None
self.release = None
......@@ -524,6 +534,27 @@ class Ade:
def get_sysroot_manager(self):
return SysrootManager(self.path, self.url, self.user, self.password, config=self.config)
def get_target(self):
if self.target:
return self.target
if self.sysroot:
try:
version = SysrootVersion.from_id(self.sysroot)
self.target = self.get_sysroot_manager().get_installed(version)
if not self.target:
self.die("No sysroot currently installed for {0}{1}{2}" \
.format(Colors.OKBLUE, version.get_name(), Colors.ENDC))
except ValueError:
self.die("Invalid sysroot tag format")
except InvalidSysrootError:
self.die("Invalid sysroot installed for {0}{1}{2}" \
.format(Colors.OKBLUE, version.get_name(), Colors.ENDC))
else:
self.die("No target (sysroot) specified")
return self.target
def do_sysroot_list(self):
manager = self.get_sysroot_manager()
versions = manager.get_versions()
......@@ -709,6 +740,16 @@ class Ade:
self.info("* Sysroot for {0}{1}{2} has been uninstalled" \
.format(Colors.OKBLUE, self.sysroot_version.get_name(), Colors.ENDC))
def do_info(self):
target = self.get_target()
if isinstance(target, Sysroot):
self.info("* Sysroot version {0}{1}{2} is installed at '{3}'"
.format(Colors.WARNING, self.target.version, Colors.ENDC, self.target.path))
if self.format == 'parseable':
print("SysrootVersion:{0}".format(self.target.version.get_tag()))
print("SysrootPath:{0}".format(self.target.path))
def info(self, message):
if self.format == 'friendly':
print(message)
......@@ -721,7 +762,9 @@ class Ade:
if self.format != 'friendly':
Colors.disable()
self.find_configuration()
method = 'do_' + self.command.replace('-', '_') + '_' + self.subcommand.replace('-', '_')
method = 'do_' + self.command.replace('-', '_')
if self.subcommand:
method += '_' + self.subcommand.replace('-', '_')
getattr(self, method)()
......@@ -733,6 +776,11 @@ if __name__ == '__main__':
subparsers = root_parser.add_subparsers(dest='command')
subparsers.required = True
# Info parser
info_parser = subparsers.add_parser('info', help="Retrieve information about an object")
group = info_parser.add_mutually_exclusive_group()
group.add_argument('--sysroot', help="Use sysroot as target (e.g. apertis-16.12-armhf)")
# Sysroot parser
sysroot_parser = subparsers.add_parser('sysroot', help='Sysroot related commands')
sysroot_parser.add_argument('--config', help="Sysroot configuration file")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment