Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
installer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
installer
Commits
1f4bbece
Commit
1f4bbece
authored
1 year ago
by
bjorn3
Browse files
Options
Downloads
Patches
Plain Diff
Introduce Config::from_file for parsing the config toml
parent
5cdec468
No related branches found
No related tags found
1 merge request
!29
Support including other config files from a config file
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/bin/installer.rs
+5
-18
5 additions, 18 deletions
src/bin/installer.rs
src/bin/installer_tui.rs
+1
-18
1 addition, 18 deletions
src/bin/installer_tui.rs
src/config/mod.rs
+20
-1
20 additions, 1 deletion
src/config/mod.rs
with
26 additions
and
37 deletions
src/bin/installer.rs
+
5
−
18
View file @
1f4bbece
...
@@ -3,13 +3,13 @@ extern crate redox_installer;
...
@@ -3,13 +3,13 @@ extern crate redox_installer;
extern
crate
serde
;
extern
crate
serde
;
extern
crate
toml
;
extern
crate
toml
;
use
std
::
io
::
{
Read
,
Write
}
;
use
std
::
io
::
Write
;
use
std
::
path
::
Path
;
use
std
::
path
::
Path
;
use
std
::{
env
,
fs
,
io
,
process
};
use
std
::{
env
,
fs
,
io
,
process
};
use
arg_parser
::
ArgParser
;
use
arg_parser
::
ArgParser
;
use
redox_installer
::
PackageConfig
;
use
redox_installer
::
{
Config
,
PackageConfig
}
;
fn
main
()
{
fn
main
()
{
let
stderr
=
io
::
stderr
();
let
stderr
=
io
::
stderr
();
...
@@ -27,24 +27,11 @@ fn main() {
...
@@ -27,24 +27,11 @@ fn main() {
// If not set on the command line or the filesystem config, then build packages from source.
// If not set on the command line or the filesystem config, then build packages from source.
let
repo_binary
=
parser
.found
(
"repo-binary"
);
let
repo_binary
=
parser
.found
(
"repo-binary"
);
let
mut
config_data
=
String
::
new
();
let
mut
config
=
if
let
Some
(
path
)
=
parser
.get_opt
(
"config"
)
{
let
mut
config
=
if
let
Some
(
path
)
=
parser
.get_opt
(
"config"
)
{
match
fs
::
File
::
open
(
&
path
)
{
match
Config
::
from_file
(
Path
::
new
(
&
path
))
{
Ok
(
mut
config_file
)
=>
match
config_file
.read_to_string
(
&
mut
config_data
)
{
Ok
(
config
)
=>
config
,
Ok
(
_
)
=>
match
toml
::
from_str
(
&
config_data
)
{
Ok
(
config
)
=>
config
,
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {}: failed to decode: {}"
,
path
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
},
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {}: failed to read: {}"
,
path
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
},
Err
(
err
)
=>
{
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {
}: failed to open: {}"
,
path
,
err
)
.unwrap
();
writeln!
(
stderr
,
"installer: {err
}"
)
.unwrap
();
process
::
exit
(
1
);
process
::
exit
(
1
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/bin/installer_tui.rs
+
1
−
18
View file @
1f4bbece
...
@@ -309,24 +309,7 @@ fn main() {
...
@@ -309,24 +309,7 @@ fn main() {
efi_partition_size
:
None
,
efi_partition_size
:
None
,
};
};
let
res
=
with_whole_disk
(
&
disk_path
,
&
disk_option
,
|
mount_path
|
->
Result
<
(),
failure
::
Error
>
{
let
res
=
with_whole_disk
(
&
disk_path
,
&
disk_option
,
|
mount_path
|
->
Result
<
(),
failure
::
Error
>
{
let
mut
config
:
Config
=
{
let
mut
config
:
Config
=
Config
::
from_file
(
&
root_path
.join
(
"filesystem.toml"
))
?
;
let
path
=
root_path
.join
(
"filesystem.toml"
);
match
fs
::
read_to_string
(
&
path
)
{
Ok
(
config_data
)
=>
{
match
toml
::
from_str
(
&
config_data
)
{
Ok
(
config
)
=>
{
config
},
Err
(
err
)
=>
{
return
Err
(
format_err!
(
"{}: failed to decode: {}"
,
path
.display
(),
err
));
}
}
},
Err
(
err
)
=>
{
return
Err
(
format_err!
(
"{}: failed to read: {}"
,
path
.display
(),
err
));
}
}
};
// Copy filesystem.toml, which is not packaged
// Copy filesystem.toml, which is not packaged
let
mut
files
=
vec!
[
let
mut
files
=
vec!
[
...
...
This diff is collapsed.
Click to expand it.
src/config/mod.rs
+
20
−
1
View file @
1f4bbece
use
std
::
collections
::
BTreeMap
;
use
std
::
collections
::
BTreeMap
;
use
std
::
fs
;
use
std
::
path
::
Path
;
pub
mod
general
;
pub
mod
file
;
pub
mod
file
;
pub
mod
general
;
pub
mod
package
;
pub
mod
package
;
pub
mod
user
;
pub
mod
user
;
...
@@ -15,3 +17,20 @@ pub struct Config {
...
@@ -15,3 +17,20 @@ pub struct Config {
#[serde(default)]
#[serde(default)]
pub
users
:
BTreeMap
<
String
,
user
::
UserConfig
>
,
pub
users
:
BTreeMap
<
String
,
user
::
UserConfig
>
,
}
}
impl
Config
{
pub
fn
from_file
(
path
:
&
Path
)
->
Result
<
Self
,
failure
::
Error
>
{
let
config
=
match
fs
::
read_to_string
(
&
path
)
{
Ok
(
config_data
)
=>
match
toml
::
from_str
(
&
config_data
)
{
Ok
(
config
)
=>
config
,
Err
(
err
)
=>
{
return
Err
(
format_err!
(
"{}: failed to decode: {}"
,
path
.display
(),
err
));
}
},
Err
(
err
)
=>
{
return
Err
(
format_err!
(
"{}: failed to read: {}"
,
path
.display
(),
err
));
}
};
Ok
(
config
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment