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
a82a5771
Commit
a82a5771
authored
7 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Change format of installer arguments
parent
a7b16dcb
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+29
-1
29 additions, 1 deletion
Cargo.lock
Cargo.toml
+2
-1
2 additions, 1 deletion
Cargo.toml
src/bin/installer.rs
+66
-36
66 additions, 36 deletions
src/bin/installer.rs
src/config/general.rs
+1
-2
1 addition, 2 deletions
src/config/general.rs
src/install.rs
+11
-12
11 additions, 12 deletions
src/install.rs
with
109 additions
and
52 deletions
Cargo.lock
+
29
−
1
View file @
a82a5771
[root]
name = "redox_installer"
version = "0.
1
.0"
version = "0.
2
.0"
dependencies = [
"clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)",
"liner 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pkgutils 0.1.1 (git+https://github.com/redox-os/pkgutils.git)",
"rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
@@ -18,6 +19,11 @@ name = "adler32"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ansi_term"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "arg_parser"
version = "0.1.0"
...
...
@@ -32,6 +38,16 @@ dependencies = [
"scoped_threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "atty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "base64"
version = "0.6.0"
...
...
@@ -74,7 +90,11 @@ name = "clap"
version = "2.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
@@ -504,6 +524,11 @@ dependencies = [
"typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strsim"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.10.8"
...
...
@@ -731,8 +756,10 @@ dependencies = [
[metadata]
"checksum adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6cbd0b9af8587c72beadc9f72d35b9fbb070982c9e6203e46e93f10df25f8f45"
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
"checksum arg_parser 0.1.0 (git+https://github.com/redox-os/arg-parser.git)" = "<none>"
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392"
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
...
...
@@ -793,6 +820,7 @@ dependencies = [
"checksum serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58"
"checksum spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4deb3c2455c73779e6d3eebceae9599fc70957e54c69fe88f93aa48e62f432"
"checksum static-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6da6a96247d4b372d3ed90dec2c129ab57c934359ac4c6adbaa5871cd0737437"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
2
−
1
View file @
a82a5771
[package]
name
=
"redox_installer"
version
=
"0.
1
.0"
version
=
"0.
2
.0"
[[bin]]
name
=
"redox_installer"
...
...
@@ -11,6 +11,7 @@ name = "redox_installer"
path
=
"src/lib.rs"
[dependencies]
clap
=
"2.26"
liner
=
"0.1"
pkgutils
=
{
git
=
"https://github.com/redox-os/pkgutils.git"
}
rand
=
"0.3"
...
...
This diff is collapsed.
Click to expand it.
src/bin/installer.rs
+
66
−
36
View file @
a82a5771
#![deny(warnings)]
extern
crate
clap
;
extern
crate
redox_installer
;
extern
crate
serde
;
extern
crate
toml
;
use
std
::
{
env
,
process
}
;
use
std
::
process
;
use
std
::
fs
::
File
;
use
std
::
io
::{
self
,
Read
,
Write
};
use
std
::
path
::
Path
;
use
clap
::{
App
,
Arg
};
fn
main
()
{
let
stderr
=
io
::
stderr
();
let
mut
stderr
=
stderr
.lock
();
let
mut
configs
=
vec!
[];
let
mut
cookbook
=
None
;
let
mut
list_packages
=
false
;
for
arg
in
env
::
args
()
.skip
(
1
)
{
if
arg
.starts_with
(
"--cookbook="
)
{
let
path
=
arg
.splitn
(
2
,
"--cookbook="
)
.nth
(
1
)
.unwrap
()
.to_string
();
if
!
Path
::
new
(
&
path
)
.is_dir
()
{
writeln!
(
stderr
,
"installer: {}: cookbook not found"
,
arg
)
.unwrap
();
process
::
exit
(
1
);
}
cookbook
=
Some
(
path
);
continue
;
}
if
arg
==
"--list-packages"
{
list_packages
=
true
;
continue
;
}
let
matches
=
App
::
new
(
"redox_installer"
)
.arg
(
Arg
::
with_name
(
"cookbook"
)
.help
(
"Path of cookbook"
)
.short
(
"b"
)
.long
(
"cookbook"
)
.takes_value
(
true
)
.value_name
(
"FOLDER"
)
)
.arg
(
Arg
::
with_name
(
"config"
)
.help
(
"Configuration file"
)
.short
(
"c"
)
.long
(
"config"
)
.takes_value
(
true
)
.value_name
(
"FILE"
)
)
.arg
(
Arg
::
with_name
(
"list-packages"
)
.help
(
"List packages"
)
.short
(
"l"
)
.long
(
"list-packages"
)
)
.arg
(
Arg
::
with_name
(
"output"
)
.help
(
"Output folder or device"
)
.index
(
1
)
.value_name
(
"OUTPUT"
)
)
.get_matches
();
match
File
::
open
(
&
arg
)
{
let
config
=
if
let
Some
(
path
)
=
matches
.value_of
(
"config"
)
{
match
File
::
open
(
path
)
{
Ok
(
mut
config_file
)
=>
{
let
mut
config_data
=
String
::
new
();
match
config_file
.read_to_string
(
&
mut
config_data
)
{
...
...
@@ -44,46 +59,61 @@ fn main() {
let
mut
decoder
=
toml
::
Decoder
::
new
(
toml
::
Value
::
Table
(
parsed
));
match
serde
::
Deserialize
::
deserialize
(
&
mut
decoder
)
{
Ok
(
config
)
=>
{
config
s
.push
(
config
);
config
},
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {}: failed to decode: {}"
,
arg
,
err
)
.unwrap
();
writeln!
(
stderr
,
"installer: {}: failed to decode: {}"
,
path
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
}
},
None
=>
{
for
error
in
parser
.errors
{
writeln!
(
stderr
,
"installer: {}: failed to parse: {}"
,
arg
,
error
)
.unwrap
();
writeln!
(
stderr
,
"installer: {}: failed to parse: {}"
,
path
,
error
)
.unwrap
();
}
process
::
exit
(
1
);
}
}
},
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {}: failed to read: {}"
,
arg
,
err
)
.unwrap
();
writeln!
(
stderr
,
"installer: {}: failed to read: {}"
,
path
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
}
},
Err
(
err
)
=>
{
writeln!
(
stderr
,
"installer: {}: failed to open: {}"
,
arg
,
err
)
.unwrap
();
writeln!
(
stderr
,
"installer: {}: failed to open: {}"
,
path
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
}
}
}
else
{
redox_installer
::
Config
::
default
()
};
if
configs
.is_empty
()
{
configs
.push
(
redox_installer
::
Config
::
default
());
}
let
cookbook
=
if
let
Some
(
path
)
=
matches
.value_of
(
"cookbook"
)
{
if
!
Path
::
new
(
&
path
)
.is_dir
()
{
writeln!
(
stderr
,
"installer: {}: cookbook not found"
,
path
)
.unwrap
();
process
::
exit
(
1
);
}
for
config
in
configs
{
if
list_packages
{
for
(
packagename
,
_package
)
in
&
config
.packages
{
println!
(
"{}"
,
packagename
);
Some
(
path
)
}
else
{
None
};
if
matches
.is_present
(
"list-packages"
)
{
for
(
packagename
,
_package
)
in
&
config
.packages
{
println!
(
"{}"
,
packagename
);
}
}
else
{
if
let
Some
(
path
)
=
matches
.value_of
(
"output"
)
{
if
let
Err
(
err
)
=
redox_installer
::
install
(
config
,
path
,
cookbook
)
{
writeln!
(
stderr
,
"installer: failed to install: {}"
,
err
)
.unwrap
();
process
::
exit
(
1
);
}
}
else
if
let
Err
(
err
)
=
redox_installer
::
install
(
config
,
cookbook
.as_ref
()
.map
(
String
::
as_ref
))
{
writeln!
(
stderr
,
"installer:
failed to install: {}"
,
err
)
.unwrap
();
}
else
{
writeln!
(
stderr
,
"installer:
output or list-packages not found"
)
.unwrap
();
process
::
exit
(
1
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/config/general.rs
+
1
−
2
View file @
a82a5771
#[derive(Debug,
Default,
Deserialize)]
pub
struct
GeneralConfig
{
pub
prompt
:
bool
,
pub
sysroot
:
Option
<
String
>
pub
prompt
:
bool
}
This diff is collapsed.
Click to expand it.
src/install.rs
+
11
−
12
View file @
a82a5771
...
...
@@ -9,12 +9,13 @@ use self::termion::input::TermRead;
use
self
::
pkgutils
::{
Repo
,
Package
};
use
std
::{
env
,
fs
};
use
std
::
ffi
::
OsStr
;
use
std
::
io
::{
self
,
stderr
,
Write
};
use
std
::
str
::
FromStr
;
use
std
::
process
::{
self
,
Command
};
use
std
::
os
::
unix
::
fs
::
symlink
;
use
std
::
os
::
unix
::
ffi
::
OsStrExt
;
use
std
::
ffi
::
OsStr
;
use
std
::
os
::
unix
::
fs
::
symlink
;
use
std
::
path
::
Path
;
use
std
::
process
::{
self
,
Command
};
use
std
::
str
::
FromStr
;
use
config
::
Config
;
...
...
@@ -100,8 +101,10 @@ fn install_packages(config: &Config, dest: &str, cookbook: Option<&str>) {
}
}
pub
fn
install
(
config
:
Config
,
cookbook
:
Option
<&
str
>
)
->
Result
<
(),
String
>
{
println!
(
"Install {:#?}"
,
config
);
pub
fn
install
<
P
:
AsRef
<
Path
>>
(
config
:
Config
,
output
:
P
,
cookbook
:
Option
<&
str
>
)
->
Result
<
(),
String
>
{
let
output
=
output
.as_ref
();
println!
(
"Install {:#?} to {}"
,
config
,
output
.display
());
let
mut
context
=
liner
::
Context
::
new
();
...
...
@@ -120,12 +123,8 @@ pub fn install(config: Config, cookbook: Option<&str>) -> 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
.clone
(),
"sysroot"
.to_string
(),
"sysroot [sysroot]: "
)
?
;
wd
.push
(
path
);
wd
};
// TODO: Mount disk if output is a file
let
sysroot
=
output
.to_owned
();
macro_rules!
dir
{
(
$path:expr
)
=>
{{
...
...
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