Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
installer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
installer
Commits
bb56cee6
Unverified
Commit
bb56cee6
authored
Apr 09, 2017
by
Ian Douglas Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let pkgutils handle downloading and extracting package
parent
4e9d22ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
59 deletions
+11
-59
Cargo.toml
Cargo.toml
+0
-1
install.rs
src/install.rs
+11
-58
No files found.
Cargo.toml
View file @
bb56cee6
...
...
@@ -16,7 +16,6 @@ pkgutils = { git = "https://github.com/redox-os/pkgutils.git" }
rand
=
"0.3"
serde
=
"0.8"
serde_derive
=
"0.8"
tar
=
{
git
=
"https://github.com/redox-os/tar-rs.git"
}
termion
=
"1.1"
toml
=
{
version
=
"0.2"
,
default-features
=
false
,
features
=
["serde"]
}
userutils
=
{
git
=
"https://github.com/redox-os/userutils.git"
}
src/install.rs
View file @
bb56cee6
extern
crate
liner
;
extern
crate
pkgutils
;
extern
crate
rand
;
extern
crate
tar
;
extern
crate
termion
;
extern
crate
userutils
;
use
self
::
rand
::
Rng
;
use
self
::
tar
::{
Archive
,
EntryType
};
use
self
::
termion
::
input
::
TermRead
;
use
self
::
pkgutils
::
Repo
;
use
std
::{
env
,
fs
};
use
std
::
io
::{
self
,
Read
,
Write
};
use
std
::
os
::
unix
::
fs
::
OpenOptionsExt
;
use
std
::
path
::
Path
;
use
std
::
io
::{
self
,
Write
};
use
std
::
str
::
FromStr
;
use
config
::
Config
;
const
REMOTE
:
&
'static
str
=
"https://static.redox-os.org/pkg"
;
const
TARGET
:
&
'static
str
=
"x86_64-unknown-redox"
;
fn
unwrap_or_prompt
<
T
:
FromStr
>
(
option
:
Option
<
T
>
,
context
:
&
mut
liner
::
Context
,
prompt
:
&
str
)
->
Result
<
T
,
String
>
{
match
option
{
None
=>
{
...
...
@@ -63,46 +63,6 @@ fn prompt_password(prompt: &str, confirm_prompt: &str) -> Result<String, String>
}
}
fn
extract_inner
<
T
:
Read
>
(
ar
:
&
mut
Archive
<
T
>
,
root
:
&
Path
)
->
io
::
Result
<
()
>
{
for
entry_result
in
try!
(
ar
.entries
())
{
let
mut
entry
=
try!
(
entry_result
);
match
entry
.header
()
.entry_type
()
{
EntryType
::
Regular
=>
{
let
mut
file
=
{
let
mut
path
=
root
.to_path_buf
();
path
.push
(
try!
(
entry
.path
()));
if
let
Some
(
parent
)
=
path
.parent
()
{
println!
(
"Extract file parent {}"
,
parent
.display
());
try!
(
fs
::
create_dir_all
(
parent
));
}
println!
(
"Extract file {}"
,
path
.display
());
try!
(
fs
::
OpenOptions
::
new
()
.read
(
true
)
.write
(
true
)
.truncate
(
true
)
.create
(
true
)
.mode
(
entry
.header
()
.mode
()
.unwrap_or
(
644
))
.open
(
path
)
)
};
try!
(
io
::
copy
(
&
mut
entry
,
&
mut
file
));
},
EntryType
::
Directory
=>
{
let
mut
path
=
root
.to_path_buf
();
path
.push
(
try!
(
entry
.path
()));
println!
(
"Extract directory {}"
,
path
.display
());
try!
(
fs
::
create_dir_all
(
path
));
},
other
=>
{
panic!
(
"Unsupported entry type {:?}"
,
other
);
}
}
}
Ok
(())
}
pub
fn
install
(
config
:
Config
)
->
Result
<
(),
String
>
{
println!
(
"Install {:#?}"
,
config
);
...
...
@@ -155,20 +115,13 @@ pub fn install(config: Config) -> Result<(), String> {
dir!
(
""
);
for
(
packagename
,
_
package
)
in
config
.packages
{
let
remote_path
=
format!
(
"{}/{}/{}.tar"
,
"https://static.redox-os.org/pkg"
,
"x86_64-unknown-redox"
,
packagename
);
let
local_path
=
format!
(
"pkg/{}.tar"
,
packagename
);
if
let
Some
(
parent
)
=
Path
::
new
(
&
local_path
)
.parent
()
{
println!
(
"Create package repository {}"
,
parent
.display
());
fs
::
create_dir_all
(
parent
)
.map_err
(|
err
|
format!
(
"failed to create package repository {}: {}"
,
parent
.display
(),
err
))
?
;
}
println!
(
"Download package {} to {}"
,
remote_path
,
local_path
);
pkgutils
::
download
(
&
remote_path
,
&
local_path
)
.map_err
(|
err
|
format!
(
"failed to download {} to {}: {}"
,
remote_path
,
local_path
,
err
))
?
;
let
mut
repo
=
Repo
::
new
(
TARGET
);
repo
.add_remote
(
REMOTE
);
repo
.set_dest
(
sysroot
.to_str
()
.unwrap
());
let
path
=
Path
::
new
(
&
local_path
);
println!
(
"Extract package {}"
,
path
.display
());
let
file
=
fs
::
File
::
open
(
&
path
)
.map_err
(|
err
|
format!
(
"failed to open {}: {}"
,
path
.display
(),
err
))
?
;
extract_inner
(
&
mut
Archive
::
new
(
file
),
&
sysroot
)
.map_err
(|
err
|
format!
(
"failed to extract {}: {}"
,
path
.display
(),
err
))
?
;
for
(
packagename
,
_
package
)
in
config
.packages
{
println!
(
"Installing package {}"
,
packagename
);
repo
.install
(
&
packagename
)
.unwrap
();
}
for
file
in
config
.files
{
...
...
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