Skip to content

Switch to rustwide for sandboxing #407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9776e70
WIP rustwide
onur Aug 21, 2019
bbd19a5
temporarily switch to rustwide's git repository
pietroalbini Sep 11, 2019
8059fdc
correctly fetch rustwide's rustc version
pietroalbini Sep 11, 2019
c115545
move sandbox configuration to constants
pietroalbini Sep 11, 2019
4dd22ee
build docs with rustwide on different targets
pietroalbini Sep 11, 2019
0f037c3
use the cargo metadata cli instead of the library to resolve deps
pietroalbini Sep 11, 2019
844e2dc
remove last uses of the cargo library from rustwide
pietroalbini Sep 11, 2019
5965cc8
record the build log during rustwide builds
pietroalbini Sep 11, 2019
c004725
extract some code from chroot_builder into docbuilder
pietroalbini Sep 12, 2019
9d2b6b8
switch add_package to use cargo metadata
pietroalbini Sep 12, 2019
f23d0c1
replace chroot_builder with rustwide_builder
pietroalbini Sep 12, 2019
dcceaff
record the docsrs commit in rustwide builds
pietroalbini Sep 13, 2019
aa174e4
purge more rustwide stuff when it's not needed anymore
pietroalbini Sep 13, 2019
7137705
remove ignored and broken test
pietroalbini Sep 13, 2019
77372e2
remove outdated flags and environment variables
pietroalbini Sep 13, 2019
336fd5d
allow limits to be overridden and show them in the ui
pietroalbini Sep 13, 2019
6e7ab9f
make the rustwide workspace configurable via envvar
pietroalbini Sep 13, 2019
fd83121
show which environment variable is missing in the daemon
pietroalbini Sep 13, 2019
9e466a1
try to update to the latest nightly on every build
pietroalbini Sep 13, 2019
b9a2e28
compare parsed semver when adding a new version
pietroalbini Sep 16, 2019
c61f3a8
inline limits constants directly into the default impl
pietroalbini Sep 16, 2019
6043ff9
upgrade rustwide to 0.3.0
pietroalbini Sep 23, 2019
5027343
simplify option clone
pietroalbini Sep 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
*.css.map
.sass-cache
.vagrant
.rustwide
218 changes: 155 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ tokio = "0.1"
systemstat = "0.1.4"
prometheus = { version = "0.7.0", default-features = false }
lazy_static = "1.0.0"
rustwide = "0.3.0"
tempdir = "0.3"

# iron dependencies
iron = "0.5"
Expand All @@ -51,9 +53,6 @@ staticfile = { version = "0.4", features = [ "cache" ] }
version = "0.15"
features = [ "with-time", "with-rustc-serialize" ]

[dev-dependencies]
tempdir = "0.3"

[build-dependencies]
time = "0.1"
git2 = "0.9"
Expand Down
70 changes: 13 additions & 57 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ extern crate clap;
extern crate log;
extern crate env_logger;
extern crate time;
extern crate rustwide;


use std::env;
use std::path::PathBuf;

use clap::{Arg, App, SubCommand};
use cratesfyi::{DocBuilder, DocBuilderOptions, db};
use cratesfyi::utils::{build_doc, add_crate_to_queue};
use cratesfyi::{DocBuilder, RustwideBuilder, DocBuilderOptions, db};
use cratesfyi::utils::add_crate_to_queue;
use cratesfyi::start_web_server;
use cratesfyi::db::{add_path_into_database, connect_db};

Expand All @@ -23,20 +24,6 @@ pub fn main() {
let matches = App::new("cratesfyi")
.version(cratesfyi::BUILD_VERSION)
.about(env!("CARGO_PKG_DESCRIPTION"))
.subcommand(SubCommand::with_name("doc")
.about("Builds documentation of a crate")
.arg(Arg::with_name("CRATE_NAME")
.index(1)
.required(true)
.help("Crate name"))
.arg(Arg::with_name("CRATE_VERSION")
.index(2)
.required(false)
.help("Crate version"))
.arg(Arg::with_name("TARGET")
.index(3)
.required(false)
.help("The target platform to compile for")))
.subcommand(SubCommand::with_name("build")
.about("Builds documentation in a chroot environment")
.arg(Arg::with_name("PREFIX")
Expand All @@ -48,21 +35,6 @@ pub fn main() {
.long("destination")
.help("Sets destination path")
.takes_value(true))
.arg(Arg::with_name("CHROOT_PATH")
.short("c")
.long("chroot-path")
.help("Sets chroot path")
.takes_value(true))
.arg(Arg::with_name("CHROOT_USER")
.short("u")
.long("chroot-user")
.help("Sets chroot user name")
.takes_value(true))
.arg(Arg::with_name("CONTAINER_NAME")
.short("n")
.long("container-name")
.help("Sets name of the container")
.takes_value(true))
.arg(Arg::with_name("CRATES_IO_INDEX_PATH")
.long("crates-io-index-path")
.help("Sets crates.io-index path")
Expand Down Expand Up @@ -152,15 +124,7 @@ pub fn main() {



// doc subcommand
if let Some(matches) = matches.subcommand_matches("doc") {
let name = matches.value_of("CRATE_NAME").unwrap();
let version = matches.value_of("CRATE_VERSION");
let target = matches.value_of("TARGET");
if let Err(e) = build_doc(name, version, target) {
panic!("{:#?}", e);
}
} else if let Some(matches) = matches.subcommand_matches("build") {
if let Some(matches) = matches.subcommand_matches("build") {
let docbuilder_opts = {
let mut docbuilder_opts = if let Some(prefix) = matches.value_of("PREFIX") {
DocBuilderOptions::from_prefix(PathBuf::from(prefix))
Expand All @@ -175,18 +139,6 @@ pub fn main() {
docbuilder_opts.destination = PathBuf::from(destination);
}

if let Some(chroot_path) = matches.value_of("CHROOT_PATH") {
docbuilder_opts.chroot_path = PathBuf::from(chroot_path);
}

if let Some(chroot_user) = matches.value_of("CHROOT_USER") {
docbuilder_opts.chroot_user = chroot_user.to_string();
}

if let Some(container_name) = matches.value_of("CONTAINER_NAME") {
docbuilder_opts.container_name = container_name.to_string();
}

if let Some(crates_io_index_path) = matches.value_of("CRATES_IO_INDEX_PATH") {
docbuilder_opts.crates_io_index_path = PathBuf::from(crates_io_index_path);
}
Expand All @@ -204,16 +156,19 @@ pub fn main() {

if let Some(_) = matches.subcommand_matches("world") {
docbuilder.load_cache().expect("Failed to load cache");
docbuilder.build_world().expect("Failed to build world");
let mut builder = RustwideBuilder::init().unwrap();
builder.build_world(&mut docbuilder).expect("Failed to build world");
docbuilder.save_cache().expect("Failed to save cache");
} else if let Some(matches) = matches.subcommand_matches("crate") {
docbuilder.load_cache().expect("Failed to load cache");
docbuilder.build_package(matches.value_of("CRATE_NAME").unwrap(),
matches.value_of("CRATE_VERSION").unwrap())
let mut builder = RustwideBuilder::init().unwrap();
builder.build_package(&mut docbuilder, matches.value_of("CRATE_NAME").unwrap(),
matches.value_of("CRATE_VERSION").unwrap())
.expect("Building documentation failed");
docbuilder.save_cache().expect("Failed to save cache");
} else if let Some(_) = matches.subcommand_matches("add-essential-files") {
docbuilder.add_essential_files().expect("Failed to add essential files");
let builder = RustwideBuilder::init().unwrap();
builder.add_essential_files().expect("failed to add essential files");
} else if let Some(_) = matches.subcommand_matches("lock") {
docbuilder.lock().expect("Failed to lock");
} else if let Some(_) = matches.subcommand_matches("unlock") {
Expand Down Expand Up @@ -287,5 +242,6 @@ fn logger_init() {
record.args())
});
builder.parse(&env::var("RUST_LOG").unwrap_or("cratesfyi=info".to_owned()));
builder.init();

rustwide::logging::init_with(builder.build());
}
Loading