just pretend this makes sense
This commit is contained in:
parent
3de397f4be
commit
1a536ce296
20
ofborg/Cargo.lock
generated
20
ofborg/Cargo.lock
generated
|
@ -8,6 +8,7 @@ dependencies = [
|
|||
"serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -308,6 +309,11 @@ dependencies = [
|
|||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.80"
|
||||
|
@ -400,6 +406,18 @@ dependencies = [
|
|||
"rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "2.2.0"
|
||||
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.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.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 = "thread-id"
|
||||
version = "2.0.0"
|
||||
|
@ -519,6 +537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum pnacl-build-helper 1.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dfbe13ee77c06fb633d71c72438bd983286bb3521863a753ade8e951c7efb090"
|
||||
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
|
||||
"checksum rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "61efcbcd9fa8d8fbb07c84e34a8af18a1ff177b449689ad38a6e9457ecc7b2ae"
|
||||
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
|
||||
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
|
||||
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
|
||||
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
|
||||
|
@ -530,6 +549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"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"
|
||||
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
|
||||
"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0"
|
||||
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
|
||||
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
|
||||
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||
|
|
|
@ -9,4 +9,5 @@ md5 = "0.3.5"
|
|||
fs2 = "0.4.2"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_json = "1.0"
|
||||
tempfile = "2.2.0"
|
|
@ -17,6 +17,7 @@ use ofborg::config;
|
|||
use ofborg::checkout;
|
||||
use ofborg::worker;
|
||||
use ofborg::message::buildjob;
|
||||
use ofborg::nix;
|
||||
|
||||
fn main() {
|
||||
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
|
||||
|
@ -90,18 +91,13 @@ impl worker::SimpleWorker for BuildWorker {
|
|||
None => { String::from("origin/master") }
|
||||
};
|
||||
|
||||
let refpath = co.checkout_ref(target_branch.as_ref());
|
||||
let refpath = co.checkout_ref(target_branch.as_ref()).unwrap();
|
||||
co.fetch_pr(job.pr.number).unwrap();
|
||||
co.merge_commit(job.pr.head_sha.as_ref()).unwrap();
|
||||
|
||||
match refpath {
|
||||
Ok(path) => {
|
||||
println!("Got path: {:?}", path);
|
||||
}
|
||||
Err(wat) => {
|
||||
println!("Failed to do a checkout of ref : {:?}", wat);
|
||||
}
|
||||
}
|
||||
println!("Got path: {:?}", refpath);
|
||||
|
||||
let cmd = nix::safely_build_attrs_cmd(refpath, job.attrs);
|
||||
|
||||
return Ok(())
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ extern crate serde_derive;
|
|||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
|
||||
extern crate tempfile;
|
||||
extern crate amqp;
|
||||
extern crate fs2;
|
||||
extern crate md5;
|
||||
|
@ -13,6 +14,7 @@ pub mod clone;
|
|||
pub mod worker;
|
||||
pub mod config;
|
||||
pub mod message;
|
||||
pub mod nix;
|
||||
|
||||
pub mod ofborg {
|
||||
pub use config;
|
||||
|
@ -21,5 +23,5 @@ pub mod ofborg {
|
|||
pub use clone;
|
||||
pub use worker;
|
||||
pub use message;
|
||||
|
||||
pub use nix;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use serde_json;
|
|||
pub struct BuildJob {
|
||||
pub repo: Repo,
|
||||
pub pr: Pr,
|
||||
pub attrs: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn from(data: &Vec<u8>) -> Result<BuildJob, serde_json::error::Error> {
|
||||
|
|
48
ofborg/src/nix.rs
Normal file
48
ofborg/src/nix.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
use std::path::Path;
|
||||
use std::ffi::OsString;
|
||||
use std::process::{Command,Stdio};
|
||||
use tempfile::tempfile;
|
||||
use std::fs::File;
|
||||
|
||||
pub fn safely_build_attrs(nixpkgs: &Path, attrs: Vec<String>) -> Result<File,File> {
|
||||
let mut nixpath = OsString::new();
|
||||
nixpath.push("nixpkgs=");
|
||||
nixpath.push(nixpkgs.as_os_str());
|
||||
|
||||
let stdout = tempfile().unwrap();
|
||||
let stderr = stdout.try_clone().unwrap();
|
||||
let reader = stderr.try_clone().unwrap();
|
||||
|
||||
let mut cmd = Command::new("nix-build")
|
||||
.env_clear()
|
||||
.current_dir(nixpkgs)
|
||||
.stdout(Stdio::from(stdout))
|
||||
.stderr(Stdio::from(stderr))
|
||||
.env("NIX_PATH", nixpath);
|
||||
|
||||
for attr in attrs {
|
||||
cmd.arg("-A");
|
||||
cmd.arg(attr);
|
||||
}
|
||||
|
||||
let stat = cmd
|
||||
.status()
|
||||
.unwrap();
|
||||
|
||||
|
||||
return Ok(reader);
|
||||
}
|
||||
|
||||
/*
|
||||
$attrs = array_intersperse(array_values((array)$body->attrs), '-A');
|
||||
var_dump($attrs);
|
||||
|
||||
$fillers = implode(" ", array_fill(0, count($attrs), '%s'));
|
||||
|
||||
$cmd = 'NIX_PATH=nixpkgs=%s nix-build --no-out-link --argstr system %s --option restrict-eval true --keep-going . ' . $fillers;
|
||||
$args = $attrs;
|
||||
array_unshift($args, NIX_SYSTEM);
|
||||
array_unshift($args, $pname);
|
||||
|
||||
|
||||
*/
|
|
@ -1,5 +1,12 @@
|
|||
let
|
||||
pkgs = import <nixpkgs> {};
|
||||
p = import <nixpkgs> {};
|
||||
pkgs = import (p.fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs-channels";
|
||||
rev = "cfafd6f5a819472911eaf2650b50a62f0c143e3e";
|
||||
sha256 = "10xgiyh4hbwwiy8qg70ma1f27nd717aflksk9fx3ci8bmxmqbkkn";
|
||||
}) {};
|
||||
|
||||
|
||||
inherit (pkgs) stdenv;
|
||||
|
||||
|
|
Loading…
Reference in a new issue