Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
installer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
installer
Commits
a56ec333
Commit
a56ec333
authored
Jan 09, 2017
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sysroot config
parent
dd0a541b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
6 deletions
+49
-6
.gitignore
.gitignore
+1
-0
config/default.toml
config/default.toml
+9
-0
src/config/general.rs
src/config/general.rs
+2
-1
src/config/package.rs
src/config/package.rs
+3
-3
src/install.rs
src/install.rs
+34
-2
No files found.
.gitignore
View file @
a56ec333
Cargo.lock
sysroot
target
config/default.toml
View file @
a56ec333
...
...
@@ -7,7 +7,16 @@ prompt = false
# Package settings
[packages]
acid
=
{}
coreutils
=
{}
extrautils
=
{}
games
=
{}
ion
=
{}
netutils
=
{}
pkgutils
=
{}
orbutils
=
{}
smith
=
{}
userutils
=
{}
# User settings
[users.root]
...
...
src/config/general.rs
View file @
a56ec333
#[derive(Debug,
Default,
Deserialize)]
pub
struct
GeneralConfig
{
pub
prompt
:
bool
pub
prompt
:
bool
,
pub
sysroot
:
Option
<
String
>
}
src/config/package.rs
View file @
a56ec333
#[derive(Debug,
Default,
Deserialize)]
pub
struct
PackageConfig
{
pub
version
:
String
,
pub
git
:
String
,
pub
path
:
String
,
pub
version
:
Option
<
String
>
,
pub
git
:
Option
<
String
>
,
pub
path
:
Option
<
String
>
,
}
src/install.rs
View file @
a56ec333
...
...
@@ -6,7 +6,9 @@ extern crate userutils;
use
self
::
rand
::
Rng
;
use
self
::
termion
::
input
::
TermRead
;
use
std
::{
env
,
fs
};
use
std
::
io
::{
self
,
Write
};
use
std
::
path
::
Path
;
use
std
::
str
::
FromStr
;
use
config
::
Config
;
...
...
@@ -57,6 +59,19 @@ fn prompt_password(prompt: &str, confirm_prompt: &str) -> Result<String, String>
}
}
pub
fn
dir
(
path
:
&
Path
)
->
Result
<
(),
String
>
{
println!
(
"Create directory {}"
,
path
.display
());
fs
::
create_dir
(
path
)
.map_err
(|
err
|
format!
(
"failed to create {}: {}"
,
path
.display
(),
err
))
?
;
Ok
(())
}
pub
fn
file
(
path
:
&
Path
,
data
:
&
[
u8
])
->
Result
<
(),
String
>
{
println!
(
"Create file {}"
,
path
.display
());
let
mut
file
=
fs
::
File
::
create
(
path
)
.map_err
(|
err
|
format!
(
"failed to create {}: {}"
,
path
.display
(),
err
))
?
;
file
.write_all
(
data
)
.map_err
(|
err
|
format!
(
"failed to write {}: {}"
,
path
.display
(),
err
))
?
;
Ok
(())
}
pub
fn
install
(
config
:
Config
)
->
Result
<
(),
String
>
{
println!
(
"Install {:#?}"
,
config
);
...
...
@@ -77,6 +92,15 @@ pub fn install(config: Config) -> Result<(), String> {
})
}
let
sysroot
=
{
let
mut
wd
=
env
::
current_dir
()
.map_err
(|
err
|
format!
(
"failed to get current dir: {}"
,
err
))
?
;
let
path
=
prompt!
(
config
.general.sysroot
,
"sysroot"
.to_string
(),
"sysroot [sysroot]: "
)
?
;
wd
.push
(
path
);
wd
};
println!
(
"Using sysroot: {}"
,
sysroot
.display
());
let
mut
passwd
=
String
::
new
();
let
mut
next_uid
=
1000
;
...
...
@@ -101,7 +125,7 @@ pub fn install(config: Config) -> Result<(), String> {
let
home
=
prompt!
(
user
.home
,
format!
(
"/home/{}"
,
username
),
"{}: home [/home/{}]: "
,
username
,
username
)
?
;
let
shell
=
prompt!
(
user
.shell
,
"/bin/ion"
.to_string
(),
"{}: shell [/bin/ion]: "
,
username
)
?
;
println!
(
"
Creat
ing user {}:"
,
username
);
println!
(
"
Add
ing user {}:"
,
username
);
println!
(
"
\t
Password: {}"
,
password
);
println!
(
"
\t
UID: {}"
,
uid
);
println!
(
"
\t
GID: {}"
,
gid
);
...
...
@@ -112,7 +136,15 @@ pub fn install(config: Config) -> Result<(), String> {
passwd
.push_str
(
&
format!
(
"{};{};{};{};{};{};{}
\n
"
,
username
,
password
,
uid
,
gid
,
name
,
home
,
shell
));
}
print!
(
"/etc/passwd:
\n
{}"
,
passwd
);
dir
(
&
sysroot
)
?
;
let
mut
etc
=
sysroot
.clone
();
etc
.push
(
"etc"
);
dir
(
&
etc
)
?
;
let
mut
etc_passwd
=
etc
.clone
();
etc_passwd
.push
(
"passwd"
);
file
(
&
etc_passwd
,
passwd
.as_bytes
())
?
;
Ok
(())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment