Skip to content
Snippets Groups Projects
Commit 7adff721 authored by Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne
Browse files

Add --config option for sysroot command


Signed-off-by: default avatarLouis-Francis Ratté-Boulianne <lfrb@collabora.com>

Differential Revision: https://phabricator.apertis.org/D4813
parent eeb923b4
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ade-sysroot \- Manage set of installed Apertis sysroots ...@@ -12,7 +12,7 @@ ade-sysroot \- Manage set of installed Apertis sysroots
.SH SYNOPSIS .SH SYNOPSIS
.sp .sp
.nf .nf
\fIade sysroot\fR [--path=<path>] \fIade sysroot\fR [--config=<config>] [--path=<path>]
\fIade sysroot list\fR \fIade sysroot list\fR
\fIade sysroot latest\fR \fIade sysroot latest\fR
\fIade sysroot latest\fR --distro=<distro> --release=<release> [--arch=<arch>] \fIade sysroot latest\fR --distro=<distro> --release=<release> [--arch=<arch>]
...@@ -55,10 +55,31 @@ get the sysroot information from that file\&. ...@@ -55,10 +55,31 @@ get the sysroot information from that file\&.
.SH OPTIONS .SH OPTIONS
.sp .sp
.PP .PP
\fI--path\fR \fI\-\-config\fR
.RS 4 .RS 4
Specify the installation path for sysroots\&. By default, the path is retrieved Specify the sysroot configuration file to use\&. By default, the XDG Base
from the sysroot configuration file or, if not existing, is /opt/sysroot\&. Directory specification is respected and \fBsysroot.conf\fR is searched for
inside the XDG configuration directories\&. The \fBgeneral\fR section contains
values applied for all sysroots, distribution-specific sections can override
these values\&.
.sp
Possible keys are:
.sp
.RS 4
\fIpath\fR Sysroots installation path\&.
.sp
\fIurl\fR Remote URL to retrieve sysroot version file\&.
.RE
.sp
The following variables can be used in the file: \fB%(distro)\fR,
\fB%(release)\fR and \fB%(arch)\fR\&.
.sp
.RE
.PP
\fI\-\-path\fR
.RS 4
Specify the installation path for sysroots\&. By default, the path is
/opt/sysroot\&.
.sp .sp
.SH COMMANDS .SH COMMANDS
.sp .sp
......
...@@ -343,9 +343,9 @@ class Ade: ...@@ -343,9 +343,9 @@ class Ade:
def validate_install_path(self): def validate_install_path(self):
if not self.path: if not self.path:
try: try:
config = configparser.ConfigParser() parser = configparser.ConfigParser()
config.read('/etc/sysroot.conf') parser.read(self.config)
self.path = config['general']['path'] self.path = parser['general']['path']
except: except:
self.path = '/opt/sysroot/' self.path = '/opt/sysroot/'
...@@ -354,23 +354,23 @@ class Ade: ...@@ -354,23 +354,23 @@ class Ade:
# XXX Allow project-specific config file to specify these info # XXX Allow project-specific config file to specify these info
if not self.distro: if not self.distro:
print("* No distribution specified, defaulting to host distribution") self.info("* No distribution specified, defaulting to host distribution")
self.distro, release = self.get_host_distro() self.distro, release = self.get_host_distro()
if not self.release: if not self.release:
print("* No release version specified, defaulting to host release version") self.info("* No release version specified, defaulting to host release version")
distro, self.release = self.get_host_distro() distro, self.release = self.get_host_distro()
if distro != self.distro: if distro != self.distro:
self.die("Mismatch between host distro and specified distro") self.die("Mismatch between host distro and specified distro")
if not self.arch: if not self.arch:
print("* No architecture specified, defaulting to 'armhf'") self.info("* No architecture specified, defaulting to 'armhf'")
self.arch = 'armhf' self.arch = 'armhf'
def parse_version_file(self, content): def parse_version_file(self, content):
try: try:
mod_content = "[sysroot]\n" + content mod_content = "[sysroot]\n" + content
config = configparser.ConfigParser() parser = configparser.ConfigParser()
config.read_string(mod_content) parser.read_string(mod_content)
return SysrootVersion(config['sysroot']['version'], config['sysroot']['url']) return SysrootVersion(parser['sysroot']['version'], parser['sysroot']['url'])
except configparser.ParsingError: except configparser.ParsingError:
self.die("Invalid syntax for sysroot version file") self.die("Invalid syntax for sysroot version file")
except KeyError as e: except KeyError as e:
...@@ -666,6 +666,7 @@ if __name__ == '__main__': ...@@ -666,6 +666,7 @@ if __name__ == '__main__':
# Sysroot parser # Sysroot parser
sysroot_parser = subparsers.add_parser('sysroot', help='Sysroot related commands') sysroot_parser = subparsers.add_parser('sysroot', help='Sysroot related commands')
sysroot_parser.add_argument('--config', help="Sysroot configuration file")
sysroot_parser.add_argument('--path', help="Sysroot installation directory") sysroot_parser.add_argument('--path', help="Sysroot installation directory")
sysroot_subparsers = sysroot_parser.add_subparsers(dest='subcommand') sysroot_subparsers = sysroot_parser.add_subparsers(dest='subcommand')
sysroot_subparsers.required = True sysroot_subparsers.required = True
......
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