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
66b24d11
Commit
66b24d11
authored
Jul 28, 2018
by
SamwiseFilmore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Directories
parent
e58815f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
27 deletions
+37
-27
config/default.toml
config/default.toml
+7
-0
src/config/file.rs
src/config/file.rs
+14
-5
src/lib.rs
src/lib.rs
+16
-22
No files found.
config/default.toml
View file @
66b24d11
...
...
@@ -171,3 +171,10 @@ Welcome to Redox OS!
path
=
"/usr"
data
=
"/"
symlink
=
true
[[files]]
path
=
"/tmp"
data
=
""
directory
=
true
# 0o1777
mode
=
1023
src/config/file.rs
View file @
66b24d11
...
...
@@ -17,12 +17,14 @@ pub struct FileConfig {
pub
data
:
String
,
#[serde(default)]
pub
symlink
:
bool
,
#[serde(default)]
pub
directory
:
bool
,
pub
mode
:
Option
<
u32
>
,
pub
uid
:
Option
<
u32
>
,
pub
gid
:
Option
<
u32
>
}
// TODO: Rewrite
// TODO: Rewrite
impls
impl
FileConfig
{
pub
(
crate
)
fn
create
<
P
:
AsRef
<
Path
>>
(
self
,
prefix
:
P
)
->
Result
<
()
>
{
...
...
@@ -30,9 +32,12 @@ impl FileConfig {
let
target_file
=
prefix
.as_ref
()
.join
(
path
);
println!
(
"target file: {:?}"
,
target_file
);
if
let
Some
(
parent
)
=
target_file
.parent
()
{
if
self
.directory
{
println!
(
"Create directory {}"
,
target_file
.display
());
fs
::
create_dir_all
(
&
target_file
)
?
;
self
.apply_perms
(
&
target_file
)
?
;
return
Ok
(());
}
else
if
let
Some
(
parent
)
=
target_file
.parent
()
{
println!
(
"Create file parent {}"
,
parent
.display
());
fs
::
create_dir_all
(
parent
)
?
;
}
...
...
@@ -52,7 +57,11 @@ impl FileConfig {
fn
apply_perms
<
P
:
AsRef
<
Path
>>
(
&
self
,
target
:
P
)
->
Result
<
()
>
{
let
path
=
target
.as_ref
();
let
mode
=
self
.mode
.unwrap_or
(
0
o0755
);
let
mode
=
self
.mode
.unwrap_or_else
(||
if
self
.directory
{
0
o0755
}
else
{
0
o0644
});
let
uid
=
self
.uid
.unwrap_or
(
0
);
let
gid
=
self
.gid
.unwrap_or
(
0
);
...
...
src/lib.rs
View file @
66b24d11
...
...
@@ -22,7 +22,7 @@ use rand::{OsRng, Rng};
use
termion
::
input
::
TermRead
;
use
pkgutils
::{
Repo
,
Package
};
use
std
::
{
env
,
fs
}
;
use
std
::
env
;
use
std
::
io
::{
self
,
stderr
,
Write
};
use
std
::
path
::
Path
;
use
std
::
process
::{
self
,
Command
};
...
...
@@ -32,7 +32,6 @@ pub(crate) type Result<T> = std::result::Result<T, Error>;
const
REMOTE
:
&
'static
str
=
"https://static.redox-os.org/pkg"
;
const
TARGET
:
&
'static
str
=
"x86_64-unknown-redox"
;
const
SYSROOT
:
&
'static
str
=
"SYSROOT"
;
/// Converts a password to a serialized argon2rs hash, understandable
/// by redox_users. If the password is blank, the hash is blank.
...
...
@@ -121,17 +120,6 @@ fn install_packages<S: AsRef<str>>(config: &Config, dest: &str, cookbook: Option
}
pub
fn
install
<
P
:
AsRef
<
Path
>
,
S
:
AsRef
<
str
>>
(
config
:
Config
,
output_dir
:
P
,
cookbook
:
Option
<
S
>
)
->
Result
<
()
>
{
/// Creates a directory relative to the output directory
fn
create_dir_relative
<
P
:
AsRef
<
Path
>>
(
path
:
P
)
->
Result
<
()
>
{
let
root
=
env
::
var
(
SYSROOT
)
?
;
let
target_dir
=
Path
::
new
(
&
root
)
.join
(
path
.as_ref
());
println!
(
"Create directory {}"
,
target_dir
.display
());
fs
::
create_dir_all
(
&
target_dir
)
?
;
Ok
(())
}
let
mut
context
=
liner
::
Context
::
new
();
macro_rules!
prompt
{
...
...
@@ -151,10 +139,6 @@ pub fn install<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P, coo
let
output_dir
=
output_dir
.as_ref
();
// Using an env var here to communicate the root dir to the functions
// instead of passing it as a param
env
::
set_var
(
SYSROOT
,
output_dir
.as_os_str
());
println!
(
"Install {:#?} to {}"
,
config
,
output_dir
.display
());
// TODO: Mount disk if output is a file
...
...
@@ -201,7 +185,15 @@ pub fn install<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P, coo
println!
(
"
\t
Home: {}"
,
home
);
println!
(
"
\t
Shell: {}"
,
shell
);
create_dir_relative
(
home
.trim_matches
(
'/'
))
?
;
FileConfig
{
path
:
home
.clone
(),
data
:
String
::
new
(),
symlink
:
false
,
directory
:
true
,
mode
:
Some
(
0
o0700
),
uid
:
Some
(
uid
),
gid
:
Some
(
gid
)
}
.create
(
&
output_dir
)
?
;
let
password
=
hash_password
(
&
password
)
?
;
...
...
@@ -213,10 +205,12 @@ pub fn install<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P, coo
path
:
"/etc/passwd"
.to_string
(),
data
:
passwd
,
symlink
:
false
,
mode
:
Some
(
0
o755
),
uid
:
Some
(
0
),
gid
:
Some
(
0
)
}
.create
(
output_dir
)
?
;
directory
:
false
,
// Take defaults
mode
:
None
,
uid
:
None
,
gid
:
None
}
.create
(
&
output_dir
)
?
;
}
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