Commit 5303301d authored by Jeremy Soller's avatar Jeremy Soller

Download packages from repo

parent 9125d089
Cargo.lock
pkg
sysroot
target
......@@ -12,6 +12,7 @@ path = "src/lib.rs"
[dependencies]
liner = "0.1"
pkgutils = { git = "https://github.com/redox-os/pkgutils.git" }
rand = "0.3"
serde = "0.8"
serde_derive = "0.8"
......
#![deny(warnings)]
extern crate redox_installer;
extern crate serde;
extern crate toml;
......
extern crate liner;
extern crate pkgutils;
extern crate rand;
extern crate tar;
extern crate termion;
......@@ -11,7 +12,7 @@ use self::termion::input::TermRead;
use std::{env, fs};
use std::io::{self, Read, Write};
use std::os::unix::fs::OpenOptionsExt;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::str::FromStr;
use config::Config;
......@@ -147,19 +148,22 @@ pub fn install(config: Config) -> Result<(), String> {
}};
}
macro_rules! pkg {
($path:expr) => {{
let path = PathBuf::from($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))?;
}};
}
dir!("");
for (packagename, _package) in config.packages {
pkg!(&format!("../cookbook/repo/x86_64-unknown-redox/{}.tar", packagename));
let remote_path = format!("{}/{}.tar", pkgutils::REPO_REMOTE, $name);
let local_path = format!("pkg/{}.tar", $name);
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 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 file in config.files {
......
#![deny(warnings)]
#[macro_use]
extern crate serde_derive;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment