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
.SH SYNOPSIS
.sp
.nf
\fIade sysroot\fR [--path=<path>]
\fIade sysroot\fR [--config=<config>] [--path=<path>]
\fIade sysroot list\fR
\fIade sysroot latest\fR
\fIade sysroot latest\fR --distro=<distro> --release=<release> [--arch=<arch>]
......@@ -55,10 +55,31 @@ get the sysroot information from that file\&.
.SH OPTIONS
.sp
.PP
\fI--path\fR
\fI\-\-config\fR
.RS 4
Specify the installation path for sysroots\&. By default, the path is retrieved
from the sysroot configuration file or, if not existing, is /opt/sysroot\&.
Specify the sysroot configuration file to use\&. By default, the XDG Base
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
.SH COMMANDS
.sp
......
......@@ -343,9 +343,9 @@ class Ade:
def validate_install_path(self):
if not self.path:
try:
config = configparser.ConfigParser()
config.read('/etc/sysroot.conf')
self.path = config['general']['path']
parser = configparser.ConfigParser()
parser.read(self.config)
self.path = parser['general']['path']
except:
self.path = '/opt/sysroot/'
......@@ -354,23 +354,23 @@ class Ade:
# XXX Allow project-specific config file to specify these info
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()
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()
if distro != self.distro:
self.die("Mismatch between host distro and specified distro")
if not self.arch:
print("* No architecture specified, defaulting to 'armhf'")
self.info("* No architecture specified, defaulting to 'armhf'")
self.arch = 'armhf'
def parse_version_file(self, content):
try:
mod_content = "[sysroot]\n" + content
config = configparser.ConfigParser()
config.read_string(mod_content)
return SysrootVersion(config['sysroot']['version'], config['sysroot']['url'])
parser = configparser.ConfigParser()
parser.read_string(mod_content)
return SysrootVersion(parser['sysroot']['version'], parser['sysroot']['url'])
except configparser.ParsingError:
self.die("Invalid syntax for sysroot version file")
except KeyError as e:
......@@ -666,6 +666,7 @@ if __name__ == '__main__':
# Sysroot parser
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_subparsers = sysroot_parser.add_subparsers(dest='subcommand')
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