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
7d5baf79
Commit
7d5baf79
authored
Jan 09, 2017
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Macros
parent
a56ec333
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
src/install/mod.rs
src/install/mod.rs
+25
-24
No files found.
src/install.rs
→
src/install
/mod
.rs
View file @
7d5baf79
...
...
@@ -8,7 +8,6 @@ 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
;
...
...
@@ -59,19 +58,6 @@ 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
);
...
...
@@ -99,7 +85,28 @@ pub fn install(config: Config) -> Result<(), String> {
wd
};
println!
(
"Using sysroot: {}"
,
sysroot
.display
());
macro_rules!
dir
{
(
$path:expr
)
=>
{{
let
mut
path
=
sysroot
.clone
();
path
.push
(
$path
);
println!
(
"Create directory {}"
,
path
.display
());
fs
::
create_dir
(
&
path
)
.map_err
(|
err
|
format!
(
"failed to create {}: {}"
,
path
.display
(),
err
))
?
;
}};
}
macro_rules!
file
{
(
$path:expr
,
$data:expr
)
=>
{{
let
mut
path
=
sysroot
.clone
();
path
.push
(
$path
);
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
))
?
;
}};
}
dir!
(
""
);
dir!
(
"etc"
);
dir!
(
"home"
);
let
mut
passwd
=
String
::
new
();
...
...
@@ -133,18 +140,12 @@ pub fn install(config: Config) -> Result<(), String> {
println!
(
"
\t
Home: {}"
,
home
);
println!
(
"
\t
Shell: {}"
,
shell
);
dir!
(
home
.trim_matches
(
'/'
));
passwd
.push_str
(
&
format!
(
"{};{};{};{};{};{};{}
\n
"
,
username
,
password
,
uid
,
gid
,
name
,
home
,
shell
));
}
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
())
?
;
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