Bootstrapping the Rust part
Dependencies
- [2]
F2C3TLOIFetching URLs (server-side) - [3]
RBGQQMWXContainer: cleanup after failure - [4]
AJLMC7UMForwarding log to frontend - [5]
A7YP2YT6Adding /tmp to containers - [6]
LTB4YNHFRust compilation works! - [7]
6BIW5YDCRust builder: compiling the crates - [8]
6MGFBMONDebug and cleanup - [9]
YJYXDY6ACapturing stdout/stderr for the derivations that ask - [10]
HX4TXY2DFixed-output derivations enable the network - [11]
BQ4E3XLAForwarding stdout/stderr - [12]
VAKO4QFFFormatting - [13]
SI454P2VDocumentation and cleanup - [14]
UWQB743KFirst working shell (with ocaml code) - [15]
BDEVQIAUHandle cyclic Ubuntu dependencies - [16]
R7J4254ZReorganisation of the frontend - [17]
LQBZJUGCAdding a basic Rust builder - [18]
LIUJQXB7Allow merging two packages based on regular expressions of their name - [19]
VWVW5VOICopying the sources in /src instead of / - [20]
ODUDDQRYAdding the OCaml interface - [*]
KOWYPLMXNix and config.toml
Change contents
- file addition: server.rs[7.15]
use elpe::extract::*;use elpe::*;use std::sync::Arc;use tokio::io::AsyncWriteExt;use tokio_stream::wrappers::ReceiverStream;use tokio_util::sync::PollSender;use tonic::codegen::tokio_stream::StreamExt;use tracing::*;pub struct Elpe {deb_client: elpe::Client,sender: tokio::sync::mpsc::UnboundedSender<(crate::container::BuildRequest,tokio::sync::mpsc::Sender<crate::container::Msg>,)>,t: Option<tokio::task::JoinHandle<Result<(), elpe::Error>>>,}pub mod proto {tonic::include_proto!("elpe");}impl Elpe {pub fn new(deb_client: elpe::Client,container_channel: elpe::container::ContainerChannel,) -> Self {let (sender, receiver) = tokio::sync::mpsc::unbounded_channel::<(crate::container::BuildRequest,tokio::sync::mpsc::Sender<crate::container::Msg>,)>();let t = tokio::spawn(crate::container::forward(receiver, container_channel));Elpe {deb_client,sender,t: Some(t),}}pub async fn serve(mut self, addr: std::net::SocketAddr) {let t = self.t.take().unwrap();tokio::select! {_ = tonic::transport::Server::builder().add_service(proto::elpe_server::ElpeServer::new(self)).serve(addr)=> {}_ = t => {}}}}use std::pin::Pin;type ResponseStream =Pin<Box<dyn tokio_stream::Stream<Item = Result<proto::DerivationReply, tonic::Status>> + Send>>;#[tonic::async_trait]impl proto::elpe_server::Elpe for Elpe {async fn add_path(&self,request: tonic::Request<tonic::Streaming<proto::AddPathRequest>>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {let mut r = request.into_inner();debug!("add_path");let mut current_file = None;let ref store = self.deb_client.store_path();debug!("store");let tmp_dir = tempfile::tempdir_in(store).unwrap();debug!("store {:?}", tmp_dir);let mut hasher = blake3::Hasher::new();debug!("loop");loop {trace!("waiting for next in stream");let Some(r) = r.next().await else { break };let r = r.unwrap();match r.request {Some(proto::add_path_request::Request::File(f)) => {info!("Adding file {:?}", f.name);hasher.update(b"\0f");hasher.update(f.name.as_bytes());hasher.update(b"\0");let p = tmp_dir.path().join(&f.name);tokio::fs::create_dir_all(p.parent().unwrap()).await?;current_file = Some(tokio::fs::File::create(&p).await?)}Some(proto::add_path_request::Request::Directory(d)) => {info!("Adding file {:?}", d.name);hasher.update(b"\0d");hasher.update(d.name.as_bytes());hasher.update(b"\0");let p = tmp_dir.path().join(&d.name);tokio::fs::create_dir_all(&p).await.unwrap();}Some(proto::add_path_request::Request::Contents(c)) => {hasher.update(&c.content);current_file.as_mut().unwrap().write_all(&c.content).await?;}None => break,}}debug!("loop done");let path = store.join(data_encoding::HEXLOWER.encode(hasher.finalize().as_bytes()));use tokio::io::ErrorKind;let new = tmp_dir.into_path();match tokio::fs::rename(&new, &path).await {Ok(()) => (),Err(e) if e.kind() == ErrorKind::DirectoryNotEmpty => (),Err(e) => {tokio::fs::remove_dir_all(&new).await?;return Err(e.into());}}info!("add_path extracted to {:?}", path);Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![path.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}type DerivationStream = ResponseStream;async fn derivation(&self,request: tonic::Request<proto::DerivationRequest>,) -> Result<tonic::Response<ResponseStream>, tonic::Status> {debug!("derivation request");let now = std::time::Instant::now();let r = request.into_inner();let (tx, rx) = tokio::sync::mpsc::channel(200);debug!("derivation request: {:?} {:?}", r.name, r.paths);self.sender.send((crate::container::BuildRequest {name: r.name.clone(),paths: r.paths,script: r.builder,target: r.target,output_hash: r.output_hash,},tx,)).unwrap();use crate::container::Msg;let output_stream = ReceiverStream::new(rx).map(|x| {Ok(match x {Msg::Ok(out) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: out.into_iter().map(|x| x.to_str().unwrap().to_string()).collect(),paths: Vec::new(),path_patterns: Vec::new(),},)),},Msg::Error(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Error(p)),},Msg::Stdout(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Stdout(p)),},Msg::Stderr(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Stderr(p)),},})});info!("request {:?}: {:?}", r.name, now.elapsed());Ok(tonic::Response::new(Box::pin(output_stream)))}async fn add_url(&self,request: tonic::Request<proto::AddUrlRequest>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {let r = request.into_inner();debug!("add_url request {:?}", r);let p = self.deb_client.http_download(&r.url,match r.hash_algorithm {0 => {let mut h = [0; 32];h.clone_from_slice(&r.hash);Hash::Blake3(h)}1 => {let mut h = [0; 32];h.clone_from_slice(&r.hash);Hash::Sha256(h)}2 => {let mut h = [0; 64];h.clone_from_slice(&r.hash);Hash::Sha512(h)}_ => unreachable!(),},).await.unwrap();Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![p.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}async fn ubuntu_release(&self,request: tonic::Request<proto::UbuntuReleaseRequest>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {debug!("ubuntu release {:?}", request);let now = std::time::Instant::now();let r = request.into_inner();let h = self.deb_client.in_release(r.release.clone()).await.unwrap();let arch = match r.arch {0 => "amd64",1 => "aarch64",_ => unreachable!(),};let p = self.deb_client.packages(&h, &r.repository, arch).await.unwrap();info!("ubuntu release request {:?}: {:?}",r.release,now.elapsed());Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![p.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}type UbuntuPackageStream = ResponseStream;async fn ubuntu_package(&self,request: tonic::Request<proto::UbuntuPackageRequest>,) -> Result<tonic::Response<Self::UbuntuPackageStream>, tonic::Status> {let now = std::time::Instant::now();let r = request.into_inner();let index: Result<Vec<_>, _> = r.index.into_iter().map(|index| deb::Index::open(&index)).collect();let index = index.unwrap();let link_extra: Vec<_> = r.link_extra.into_iter().map(|l| {(regex::Regex::new(&l.pkg).unwrap(),regex::Regex::new(&l.dep).unwrap(),)}).collect();let (tx, rx) = tokio::sync::mpsc::channel(200);use crate::extract::Msg;let output_stream = ReceiverStream::new(rx).map(|x| {Ok(match x {Msg::Downloading(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Loading(p)),},Msg::Ok(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: p.result.iter().rev().map(|x| x.to_str().unwrap().to_string()).collect(),paths: p.paths.into_iter().filter_map(Arc::into_inner).collect(),path_patterns: Vec::new(),},)),},Msg::Error(e) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Error(e.to_string())),},})});match download_extract_deps(&index,&self.deb_client,&r.name,&link_extra,PollSender::new(tx.clone()),).await{Ok(p) => {info!("path {:?} {:#?}", r.name, p);tx.send(Msg::Ok(p)).await.unwrap();}Err(e) => tx.send(Msg::Error(e)).await.unwrap(),}info!("ubuntu package request {:?}: {:?}", r.name, now.elapsed());Ok(tonic::Response::new(Box::pin(output_stream)))}} - edit in src/main.rs at line 2
use elpe::extract::*; - edit in src/main.rs at line 5[7.332]→[7.1421:1441](∅→∅),[7.1556]→[7.1421:1441](∅→∅),[7.1421]→[7.1421:1441](∅→∅),[7.1441]→[7.1557:1587](∅→∅),[7.1587]→[7.0:44](∅→∅),[7.44]→[4.0:34](∅→∅),[4.34]→[7.1587:1632](∅→∅),[7.44]→[7.1587:1632](∅→∅),[7.1587]→[7.1587:1632](∅→∅),[7.1632]→[7.1441:1457](∅→∅),[7.1441]→[7.1441:1457](∅→∅)
use std::sync::Arc;use tokio::io::AsyncWriteExt;use tokio_stream::wrappers::ReceiverStream;use tokio_util::sync::PollSender;use tonic::codegen::tokio_stream::StreamExt;use tracing::*; - edit in src/main.rs at line 6
pub mod proto {tonic::include_proto!("elpe");} - replacement in src/main.rs at line 7[7.1641]→[7.1641:1659](∅→∅),[7.1659]→[7.1633:1752](∅→∅),[7.1752]→[7.45:103](∅→∅),[7.103]→[7.1815:1823](∅→∅),[7.1815]→[7.1815:1823](∅→∅),[7.1823]→[7.1694:1696](∅→∅),[7.1694]→[7.1694:1696](∅→∅)
pub struct Elpe {deb_client: elpe::Client,sender: tokio::sync::mpsc::UnboundedSender<(crate::container::BuildRequest,tokio::sync::mpsc::Sender<crate::container::Msg>,)>,}mod server; - edit in src/main.rs at line 9[7.105]→[7.105:248](∅→∅),[7.248]→[7.1711:1775](∅→∅),[7.1711]→[7.1711:1775](∅→∅),[7.1775]→[7.1824:1847](∅→∅),[7.1847]→[7.1800:1815](∅→∅),[7.1800]→[7.1800:1815](∅→∅),[7.1815]→[7.1848:2038](∅→∅),[7.2038]→[4.35:63](∅→∅),[4.63]→[7.2038:2075](∅→∅),[7.2038]→[7.2038:2075](∅→∅),[7.2075]→[7.333:387](∅→∅),[7.387]→[4.64:188](∅→∅),[4.188]→[7.2179:2228](∅→∅),[7.2179]→[7.2179:2228](∅→∅),[7.2228]→[4.189:213](∅→∅),[4.213]→[7.2229:2482](∅→∅),[7.2001]→[7.2229:2482](∅→∅),[7.2482]→[4.214:269](∅→∅),[4.269]→[7.2482:2922](∅→∅),[7.2482]→[7.2482:2922](∅→∅),[7.2922]→[4.270:325](∅→∅),[4.325]→[7.2922:3477](∅→∅),[7.2922]→[7.2922:3477](∅→∅),[7.3477]→[4.326:355](∅→∅),[4.355]→[7.3477:4356](∅→∅),[7.3477]→[7.3477:4356](∅→∅),[7.4356]→[7.249:294](∅→∅),[7.294]→[7.4356:4456](∅→∅),[7.4356]→[7.4356:4456](∅→∅),[7.4456]→[7.295:361](∅→∅),[7.361]→[7.4530:4606](∅→∅),[7.4530]→[7.4530:4606](∅→∅),[7.4606]→[7.362:418](∅→∅),[7.418]→[7.4662:4898](∅→∅),[7.4662]→[7.4662:4898](∅→∅),[7.4898]→[7.0:48](∅→∅),[7.48]→[7.4898:4975](∅→∅),[7.4898]→[7.4898:4975](∅→∅),[7.4975]→[7.419:718](∅→∅),[7.718]→[2.0:204](∅→∅),[2.204]→[7.796:1519](∅→∅),[7.796]→[7.796:1519](∅→∅),[7.1519]→[7.2198:2205](∅→∅),[7.5566]→[7.2198:2205](∅→∅),[7.2198]→[7.2198:2205](∅→∅),[7.2205]→[2.205:1636](∅→∅),[2.1636]→[7.2205:2249](∅→∅),[7.2205]→[7.2205:2249](∅→∅),[7.2249]→[7.5567:5703](∅→∅),[7.5703]→[7.2371:2850](∅→∅),[7.2371]→[7.2371:2850](∅→∅),[7.2850]→[7.5704:5997](∅→∅),[7.5997]→[7.2932:2951](∅→∅),[7.2932]→[7.2932:2951](∅→∅),[7.2951]→[4.356:404](∅→∅),[4.404]→[7.2951:2995](∅→∅),[7.2951]→[7.2951:2995](∅→∅),[7.2995]→[7.5998:6060](∅→∅),[7.6060]→[4.405:482](∅→∅),[4.482]→[7.3117:3392](∅→∅),[7.6134]→[7.3117:3392](∅→∅),[7.3117]→[7.3117:3392](∅→∅),[7.3392]→[7.0:1](∅→∅),[7.1]→[7.0:294](∅→∅),[7.294]→[4.483:803](∅→∅),[4.803]→[7.6646:6665](∅→∅),[7.6646]→[7.6646:6665](∅→∅),[7.6665]→[4.804:2149](∅→∅),[4.2149]→[7.4845:4851](∅→∅),[7.4845]→[7.4845:4851](∅→∅),[7.4851]→[7.388:391](∅→∅)
use std::pin::Pin;type ResponseStream =Pin<Box<dyn tokio_stream::Stream<Item = Result<proto::DerivationReply, tonic::Status>> + Send>>;#[tonic::async_trait]impl proto::elpe_server::Elpe for Elpe {async fn add_path(&self,request: tonic::Request<tonic::Streaming<proto::AddPathRequest>>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {let mut r = request.into_inner();debug!("add_path");let mut current_file = None;let ref store = self.deb_client.store_path();debug!("store");let tmp_dir = tempfile::tempdir_in(store).unwrap();debug!("store {:?}", tmp_dir);let mut hasher = blake3::Hasher::new();debug!("loop");loop {trace!("waiting for next in stream");let Some(r) = r.next().await else { break };let r = r.unwrap();match r.request {Some(proto::add_path_request::Request::File(f)) => {info!("Adding file {:?}", f.name);hasher.update(b"\0f");hasher.update(f.name.as_bytes());hasher.update(b"\0");let p = tmp_dir.path().join(&f.name);tokio::fs::create_dir_all(p.parent().unwrap()).await?;current_file = Some(tokio::fs::File::create(&p).await?)}Some(proto::add_path_request::Request::Directory(d)) => {info!("Adding file {:?}", d.name);hasher.update(b"\0d");hasher.update(d.name.as_bytes());hasher.update(b"\0");let p = tmp_dir.path().join(&d.name);tokio::fs::create_dir_all(&p).await.unwrap();}Some(proto::add_path_request::Request::Contents(c)) => {hasher.update(&c.content);current_file.as_mut().unwrap().write_all(&c.content).await?;}None => break,}}debug!("loop done");let path = store.join(data_encoding::HEXLOWER.encode(hasher.finalize().as_bytes()));use tokio::io::ErrorKind;let new = tmp_dir.into_path();match tokio::fs::rename(&new, &path).await {Ok(()) => (),Err(e) if e.kind() == ErrorKind::DirectoryNotEmpty => (),Err(e) => {tokio::fs::remove_dir_all(&new).await?;return Err(e.into());}}info!("add_path extracted to {:?}", path);Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![path.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}type DerivationStream = ResponseStream;async fn derivation(&self,request: tonic::Request<proto::DerivationRequest>,) -> Result<tonic::Response<ResponseStream>, tonic::Status> {debug!("derivation request");let r = request.into_inner();let (tx, rx) = tokio::sync::mpsc::channel(200);self.sender.send((crate::container::BuildRequest {name: r.name,paths: r.paths,script: r.builder,target: r.target,output_hash: r.output_hash,},tx,)).unwrap();use crate::container::Msg;let output_stream = ReceiverStream::new(rx).map(|x| {Ok(match x {Msg::Ok(out) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: out.into_iter().map(|x| x.to_str().unwrap().to_string()).collect(),paths: Vec::new(),path_patterns: Vec::new(),},)),},Msg::Error(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Error(p)),},Msg::Stdout(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Stdout(p)),},Msg::Stderr(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Stderr(p)),},})});Ok(tonic::Response::new(Box::pin(output_stream)))}async fn add_url(&self,request: tonic::Request<proto::AddUrlRequest>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {let r = request.into_inner();debug!("add_url request {:?}", r);let p = self.deb_client.http_download(&r.url,match r.hash_algorithm {0 => {let mut h = [0; 32];h.clone_from_slice(&r.hash);Hash::Blake3(h)}1 => {let mut h = [0; 32];h.clone_from_slice(&r.hash);Hash::Sha256(h)}2 => {let mut h = [0; 64];h.clone_from_slice(&r.hash);Hash::Sha512(h)}_ => unreachable!(),},).await.unwrap();Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![p.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}async fn ubuntu_release(&self,request: tonic::Request<proto::UbuntuReleaseRequest>,) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {debug!("ubuntu release {:?}", request);let r = request.into_inner();let h = self.deb_client.in_release(r.release).await.unwrap();let arch = match r.arch {0 => "amd64",1 => "aarch64",_ => unreachable!(),};let p = self.deb_client.packages(&h, &r.repository, arch).await.unwrap();Ok(tonic::Response::new(proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: vec![p.to_str().unwrap().to_string()],paths: Vec::new(),path_patterns: Vec::new(),},)),}))}type UbuntuPackageStream = ResponseStream;async fn ubuntu_package(&self,request: tonic::Request<proto::UbuntuPackageRequest>,) -> Result<tonic::Response<Self::UbuntuPackageStream>, tonic::Status> {debug!("request {:?}", request);let r = request.into_inner();let index: Result<Vec<_>, _> = r.index.into_iter().map(|index| deb::Index::open(&index)).collect();let index = index.unwrap();let link_extra: Vec<_> = r.link_extra.into_iter().map(|l| {(regex::Regex::new(&l.pkg).unwrap(),regex::Regex::new(&l.dep).unwrap(),)}).collect();let (tx, rx) = tokio::sync::mpsc::channel(200);use crate::extract::Msg;let output_stream = ReceiverStream::new(rx).map(|x| {Ok(match x {Msg::Downloading(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Loading(p)),},Msg::Ok(p) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Ok(proto::DerivationResult {destdir: p.result.iter().rev().map(|x| x.to_str().unwrap().to_string()).collect(),paths: p.paths.into_iter().filter_map(Arc::into_inner).collect(),path_patterns: Vec::new(),},)),},Msg::Error(e) => proto::DerivationReply {result: Some(proto::derivation_reply::Result::Error(e.to_string())),},})});match download_extract_deps(&index,&self.deb_client,&r.name,&link_extra,PollSender::new(tx.clone()),).await{Ok(p) => {info!("path {:?} {:#?}", r.name, p);tx.send(Msg::Ok(p)).await.unwrap();}Err(e) => tx.send(Msg::Error(e)).await.unwrap(),}Ok(tonic::Response::new(Box::pin(output_stream)))}} - edit in src/main.rs at line 47[7.1043]→[7.1043:1044](∅→∅),[7.1044]→[7.7101:7219](∅→∅),[7.7101]→[7.7101:7219](∅→∅),[7.7219]→[7.1520:1582](∅→∅),[7.1582]→[7.7286:7300](∅→∅),[7.7286]→[7.7286:7300](∅→∅)
let (sender, receiver) = tokio::sync::mpsc::unbounded_channel::<(crate::container::BuildRequest,tokio::sync::mpsc::Sender<crate::container::Msg>,)>(); - replacement in src/main.rs at line 48
let t = tokio::spawn(crate::container::forward(receiver, container_channel));let elpe = server::Elpe::new(Client::new(&config.pgp_home, &config.store_path, &config.package_index),container_channel,); - edit in src/main.rs at line 53[7.8831]→[7.7388:7414](∅→∅),[7.7414]→[7.1045:1143](∅→∅),[7.1143]→[7.7502:7533](∅→∅),[7.7502]→[7.7502:7533](∅→∅),[7.7533]→[7.9063:9064](∅→∅),[7.9063]→[7.9063:9064](∅→∅)
let elpe = Elpe {deb_client: Client::new(&config.pgp_home, &config.store_path, &config.package_index),sender,}; - replacement in src/main.rs at line 54
tokio::select! {_ = tonic::transport::Server::builder().add_service(proto::elpe_server::ElpeServer::new(elpe)).serve(addr)=> {}_ = t => {}}elpe.serve(addr).await - edit in src/container.rs at line 5
use std::os::fd::OwnedFd; - replacement in src/container.rs at line 80
debug!("received process response {:?}", x);info!("received process response {:?}", x); - replacement in src/container.rs at line 86
chan.send(resp).await.unwrap_or(());chan.send(resp).await.unwrap(); - replacement in src/container.rs at line 90
chan.send(resp).await.unwrap_or(());chan.send(resp).await.unwrap(); - edit in src/container.rs at line 141
let mut n = 0; - replacement in src/container.rs at line 153
let (writer_out, mut reader_out) = tokio::net::unix::pipe::pipe().unwrap();let (writer_err, mut reader_err) = tokio::net::unix::pipe::pipe().unwrap();let m = n;n += 1; - edit in src/container.rs at line 156
let (reader_out, writer_out) = std::io::pipe().unwrap();let (reader_err, writer_err) = std::io::pipe().unwrap();let reader_out_fd = reader_out.as_raw_fd();let reader_err_fd = reader_err.as_raw_fd();let writer_out_fd = writer_out.as_raw_fd();let writer_err_fd = writer_err.as_raw_fd(); - replacement in src/container.rs at line 163
run_in_container(let writer_out_fd: OwnedFd = writer_out.into();let writer_err_fd: OwnedFd = writer_err.into();info!("run_in_container {}: {}", m, rec_msg.script);let result = run_in_container(m, - replacement in src/container.rs at line 171
writer_out.as_raw_fd(),writer_err.as_raw_fd(),reader_out_fd,writer_out_fd,reader_err_fd,writer_err_fd, - replacement in src/container.rs at line 176
.map_err(|e| format!("{:?}", e)).map_err(|e| format!("{:?}", e));info!("run_in_container {}: done", m);result - edit in src/container.rs at line 182
let mut reader_out =tokio::net::unix::pipe::Receiver::from_owned_fd(reader_out.into()).unwrap();let mut reader_err =tokio::net::unix::pipe::Receiver::from_owned_fd(reader_err.into()).unwrap(); - edit in src/container.rs at line 193
info!("waiting for run_in_container {} {:?} {:?}",m, stdout_closed, stderr_closed); - edit in src/container.rs at line 217
} else {stdout_closed = true - edit in src/container.rs at line 233
} else {stderr_closed = true - edit in src/container.rs at line 237
_ = tokio::time::sleep(std::time::Duration::from_secs(10)) => {info!("Still waiting for {}", m)} - replacement in src/container.rs at line 243
debug!("drv_process replying {:?}", v.len());info!("drv_process {} replying {:?}", m, v.len()); - edit in src/container.rs at line 246
info!("sent {}", m); - edit in src/container.rs at line 254
m: usize, - replacement in src/container.rs at line 258
stdout: RawFd,stderr: RawFd,stdout_r: RawFd,stdout: OwnedFd,stderr_r: RawFd,stderr: OwnedFd, - edit in src/container.rs at line 272
debug!("{}", r.script); - edit in src/container.rs at line 285
drop(stdout);drop(stderr); - edit in src/container.rs at line 297
info!("{} returning early", m); - edit in src/container.rs at line 321
info!("clone {}", m); - edit in src/container.rs at line 342
unsafe {if libc::close(stdout_r) != 0 {error!("couldn't close");return Err(std::io::Error::last_os_error().into());}if libc::close(stderr_r) != 0 {error!("couldn't close");return Err(std::io::Error::last_os_error().into());}} - replacement in src/container.rs at line 354
user, &r, &tmp_dir, &dest, &store, &tmp_store, &name, stdout, stderr,user,&r,&tmp_dir,&dest,&store,&tmp_store,&name,stdout.as_raw_fd(),stderr.as_raw_fd(), - replacement in src/container.rs at line 376
debug!("waitpid");drop(stdout);drop(stderr);info!("waitpid {}", m); - replacement in src/container.rs at line 381
info!("return status {:?}", status);info!("{} return status {:?}", m, status); - edit in src/container.rs at line 395
std::fs::remove_dir_all(&dest).unwrap_or(()); - replacement in src/container.rs at line 540
stdout: RawFd,stderr: RawFd,stdout_w: RawFd,stderr_w: RawFd, - replacement in src/container.rs at line 662
if libc::dup2(stdout, this_stdout) < 0 {if libc::dup2(stdout_w, this_stdout) < 0 { - replacement in src/container.rs at line 665
if libc::dup2(stderr, this_stderr) < 0 {if libc::dup2(stderr_w, this_stderr) < 0 { - edit in src/container.rs at line 668
// libc::dup2(stdout, 1);libc::dup2(stderr, 2); - edit in shell.nix at line 101[7.70][22.2728]
ocamlPackages.ppx_stringocamlPackages.ppx_blob - file addition: semantic_versions.ml[7.55449]
let of_string input =tryScanf.sscanf input "%u.%u.%u-%s" (fun v1 v2 v3 v4 -> (v1, v2, v3, Some v4))with _ -> Scanf.sscanf input "%u.%u.%u" (fun v1 v2 v3 -> (v1, v2, v3, None))let to_string (v1, v2, v3, v4) =match v4 with| None -> Printf.sprintf "%u.%u.%u" v1 v2 v3| Some s -> Printf.sprintf "%u.%u.%u-%s" v1 v2 v3 s - file addition: rust[7.55449]
- file move: rust.ml → rust.ml
- replacement in elpe/lib/rust/rust.ml at line 14
httphttp ~name:crate - replacement in elpe/lib/rust/rust.ml at line 30
method name = "rust"method name = "rust-unzip-" ^ pkg#name - replacement in elpe/lib/rust/rust.ml at line 39
("mkdir -p $DESTDIR; tar -xf " ^ List.hd zipped.destdir^ " -C $DESTDIR; cd $DESTDIR/*; echo -n \\{\\\"files\\\":\\{ \>.cargo-checksum.json\n\n=0\n\for f in $(find . -type f -printf '%P\\n'); do\n\if [[ $n -gt 0 ]]; then\n\echo -n , >>.cargo-checksum.json\n\fi\n\echo -n \\\"$f\\\":\\\"$(sha256sum $f | cut -d\" \" -f 1)\\\" >> \.cargo-checksum.json;\n\n=$((n+1))\n\done\n\echo -n \\},\\\"package\\\":\\\"" ^ hash^ "\\\"\\} >> .cargo-checksum.json")[%string{|mkdir -p $DESTDIRtar -xf %{List.hd zipped.destdir} -C $DESTDIRcd $DESTDIR/*echo -n \{\"files\":\{ >.cargo-checksum.jsonn=0for f in $(find . -type f -printf '%P\n'); doif [[ $n -gt 0 ]]; thenecho -n , >>.cargo-checksum.jsonfiecho -n \"$f\":\"$(sha256sum $f | cut -d" " -f 1)\" >> .cargo-checksum.jsonn=$((n+1))doneecho -n \},\"package\":\"%{hash}\"\} >> .cargo-checksum.json|}]method! install_phase = Lwt.return "" - edit in elpe/lib/rust/rust.ml at line 57
let extra_crate_dependencies name version =match (name, version) with| "openssl", _ | "openssl-sys", _ ->[ ubuntu "libssl-dev"; ubuntu "pkg-config" ]| _ -> [] - replacement in elpe/lib/rust/rust.ml at line 83[7.466]→[7.466:845](∅→∅),[7.845]→[6.1457:1525](∅→∅),[6.1525]→[7.895:1110](∅→∅),[7.895]→[7.895:1110](∅→∅)
Lwt.all(List.map(fun pkg ->trylet source = str_from_toml_table "source" pkg inlet checksum = str_from_toml_table "checksum" pkg inlet name = str_from_toml_table "name" pkg inlet version = str_from_toml_table "version" pkg inlet h = fetch_crate source checksum name version inlet drv = (unzip_checksum h checksum :> derivation) inlet* built = drv#build inn_packages := !n_packages + 1;Lwt.return (Some (name, version, source, drv, built))with Not_found -> Lwt.return None)packages)Lwt_list.map_s(fun pkg ->trylet source = str_from_toml_table "source" pkg inlet checksum = str_from_toml_table "checksum" pkg inlet name = str_from_toml_table "name" pkg inlet version = str_from_toml_table "version" pkg inlet h = fetch_crate source checksum name version inlet drv = (unzip_checksum h checksum :> derivation) inlet* built = drv#build inn_packages := !n_packages + 1;Lwt.return (Some (name, version, source, drv, built))with Not_found -> Lwt.return None)packages - replacement in elpe/lib/rust/rust.ml at line 123
let platform =match platform with Some s -> " --filter-platform " ^ s | None -> ""inlet platform = " --filter-platform " ^ platform in - replacement in elpe/lib/rust/rust.ml at line 126[7.1826]→[7.1826:1984](∅→∅),[7.1984]→[6.1783:1979](∅→∅),[6.1979]→[7.2128:2147](∅→∅),[7.2128]→[7.2128:2147](∅→∅),[7.2147]→[6.1980:2035](∅→∅),[6.2035]→[7.2147:2331](∅→∅),[7.2147]→[7.2147:2331](∅→∅)
List.fold_left(fun acc x ->match x with| Some (crate_name, version, _, _, built) ->let target =if Hashtbl.find_opt h crate_name = None then (Hashtbl.add h crate_name ();crate_name)else crate_name ^ "-" ^ versioninList.iter self#add_path built.destdir;acc ^ "ln -s " ^ List.hd built.destdir ^ "/" ^ crate_name ^ "-"^ version ^ " vendor/" ^ target ^ "\n"| None -> acc)"" packageslet package_list =List.fold_left(fun acc x ->match x with| Some (crate_name, version, _, _, built) ->let target =if Hashtbl.find_opt h crate_name = None then (Hashtbl.add h crate_name ();crate_name)else crate_name ^ "-" ^ versioninList.iter self#add_path built.destdir;["ln -s ";List.hd built.destdir;"/";crate_name;"-";version;" vendor/";target;"\n";]@ acc| None -> acc)[] packagesinString.concat "" package_list - replacement in elpe/lib/rust/rust.ml at line 156
"export HOME=/home/me\nmkdir -p $HOME\nexport PATH=" ^ List.hd rustc^ "/usr/lib/rust-" ^ rust_version ^ "/bin:" ^ List.hd cargo^ "/usr/lib/rust-" ^ rust_version^ "/bin:$PATH\nmkdir -p vendor .cargo\n" ^ packages^ "\n\cat <<EOF >> .cargo/config.toml\n\[source.crates-io]\n\replace-with = \"vendored-sources\"\n\n\[source.vendored-sources]\n\directory = \"vendor\"\n\EOF\n\cargo metadata --offline --format-version 1" ^ platform[%string{|export HOME=/home/memkdir -p $HOMEexport PATH=%{List.hd rustc}/usr/lib/rust-%{rust_version}/bin:%{List.hd cargo}/usr/lib/rust-%{rust_version}/bin:$PATHmkdir -p vendor .cargo%{packages}cat <<EOF >> .cargo/config.toml[source.crates-io]replace-with = "vendored-sources"[source.vendored-sources]directory = "vendor"EOFcargo metadata --offline --format-version 1 %{platform}|}] - replacement in elpe/lib/rust/rust.ml at line 178
type deps = { build_dependencies : string; dependencies : string }type deps = {build_dependencies : (string * string * string * bool * build_result) list;dependencies : (string * string * string * bool * build_result) list;transitive_build_dependencies : (string, build_result) Hashtbl.t;transitive_dependencies : (string, build_result) Hashtbl.t;} - replacement in elpe/lib/rust/rust.ml at line 187
class compiled_crate rust_version rustc cc platform package path deps features =class compiled_crate ~rust_version ~rustc ~cc ~host ~target ~package ~path~dependencies ~features ~opt_level ~is_top_level =let package_deps =let d = package |> member "dependencies" |> to_list inlet h = Hashtbl.create (List.length d) inList.iter (fun d -> Hashtbl.add h (d |> member "name" |> to_string) d) d;hin - edit in elpe/lib/rust/rust.ml at line 199
method semantic_version = Semantic_versions.of_string self#version - replacement in elpe/lib/rust/rust.ml at line 201
val target_platform = platformmethod targets = package |> member "targets" |> to_list - edit in elpe/lib/rust/rust.ml at line 208
let* deps = self#dependencies inlet dependencies =String.concat " "(List.map(fun (_, _, _, _, r) -> List.hd r.destdir)deps.dependencies)inlet build_dependencies =String.concat " "(List.map(fun (_, _, _, _, r) -> List.hd r.destdir)deps.build_dependencies)in - replacement in elpe/lib/rust/rust.ml at line 222
(s ^ "export HOME=/home/me\nmkdir -p $HOME\nexport PATH="^ List.hd rustc ^ "/usr/lib/rust-" ^ rust_version ^ "/bin:$PATH\n")[%string{|%{s}for i in %{dependencies} %{build_dependencies}; doif [[ -s $i/lib/env ]]; thensource $i/lib/envfidoneexport HOME=/home/memkdir -p $HOMEexport PATH=%{List.hd rustc}/usr/lib/rust-%{rust_version}/bin:$PATH|}] - replacement in elpe/lib/rust/rust.ml at line 242
(fun acc x -> acc ^ " --cfg 'feature=\"" ^ x ^ "\"'")(fun acc x -> [%string {|%{acc} --cfg 'feature="%{x}"'|}]) - replacement in elpe/lib/rust/rust.ml at line 272
method private compile_target setup platform target kind dependencies out =let initial_src_path = target |> member "src_path" |> to_string inmethod private compile_target setup target build_target kindtransitive_dependencies dependencies out =let initial_src_path = build_target |> member "src_path" |> to_string in - replacement in elpe/lib/rust/rust.ml at line 276
let name = target |> member "name" |> to_string inlet name = build_target |> member "name" |> to_string in - replacement in elpe/lib/rust/rust.ml at line 279
try " --edition=" ^ (target |> member "edition" |> to_string) ^ " "try" --edition=" ^ (build_target |> member "edition" |> to_string) ^ " " - replacement in elpe/lib/rust/rust.ml at line 285
let platform =match platform with Some p -> " --target " ^ p | None -> ""let dependencies_str =List.fold_left(fun acc (rename, name, h, is_proc_macro, b) ->acc ^ " --extern " ^ underscorize rename ^ "=" ^ List.hd b.destdir^ "/lib/lib" ^ underscorize name ^ "-" ^ h^if is_proc_macro then ".so"else if kind = "lib" then ".rmeta"else ".rlib")"" dependenciesinlet dependencies_str =Hashtbl.fold(fun _ v acc -> acc ^ " -L dependency=" ^ List.hd v.destdir ^ "/lib")transitive_dependencies dependencies_str - edit in elpe/lib/rust/rust.ml at line 303
let target = " --target " ^ Platform.triple target in - replacement in elpe/lib/rust/rust.ml at line 306
!setup ^ "rustc --crate-name " ^ under ^ edition ^ src_path ^ platform^ " --crate-type bin -C linker=gcc" ^ features_args ^ " -C metadata="^ hash ^ " --out-dir " ^ out ^ dependencies ^ " --cap-lints allow\n"[%string{|%{!setup}set -xrustc --crate-name %{under} %{edition} %{src_path} %{target} --crate-type bin -C linker=gcc $RUSTC_FLAGS %{features_args} -C metadata=%{hash} --out-dir %{out} %{dependencies_str} -L dependency=../lib --cap-lints allow{ set +x; } 2>/dev/null|}] - replacement in elpe/lib/rust/rust.ml at line 315
!setup ^ "rustc --crate-name " ^ under ^ edition ^ src_path^ " --crate-type " ^ kind ^ platform^ " --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2"^ features_args ^ " -C metadata=" ^ hash ^ " --out-dir " ^ out^ " -C extra-filename=-" ^ hash ^ dependencies^ " --cap-lints allow\n";[%string{|%{!setup}set -xrustc --crate-name %{under} %{edition} %{src_path} --crate-type %{kind} %{target} --emit=dep-info,metadata,link -C linker=gcc -C embed-bitcode=no -C debuginfo=2 $RUSTC_FLAGS %{if kind = "proc-macro" then " -C prefer-dynamic" else ""} %{features_args} -C metadata=%{hash} --out-dir %{out} -C extra-filename=-%{hash} %{dependencies_str} %{if kind = "proc-macro" then " --extern proc_macro" else ""} --cap-lints allow{ set +x; } 2>/dev/null|}]; - edit in elpe/lib/rust/rust.ml at line 325
val accumulated_deps : (string, compiled_crate) Hashtbl.t option ref =ref Nonemethod accumulated_deps =match !accumulated_deps with| Some acc -> Lwt.return acc| None ->let h = Hashtbl.create 256 inlet* _ =Lwt_list.iter_s(fun d ->let dd = Hashtbl.find package_deps d#name inlet is_build =dd |> member "kind" |> to_option to_string = Some "build"inHashtbl.add h d#name d;let* acc = d#accumulated_deps inLwt.return(if not is_build thenHashtbl.iter (fun k v -> Hashtbl.add h k v) accelse ()))dependenciesinaccumulated_deps := Some h;Lwt.return h - replacement in elpe/lib/rust/rust.ml at line 360
let package_deps =let d = package |> member "dependencies" |> to_list inlet h = Hashtbl.create (List.length d) inList.iter(fun d -> Hashtbl.add h (d |> member "name" |> to_string) d)d;hinlet de = ref "" inlet build_de = ref "" inlet de = ref [] inlet h = Hashtbl.create 256 inlet build_h = Hashtbl.create 256 inlet build_de = ref [] in - replacement in elpe/lib/rust/rust.ml at line 365
Lwt_list.map_pLwt_list.map_s - replacement in elpe/lib/rust/rust.ml at line 368
Lwt.return (x#name, x#hash, b))Lwt.return (x, x#name, x#hash, b))dependenciesinlet* _ =Lwt_list.iter_s(fun (x, x_name, x_hash, b) ->let d = Hashtbl.find package_deps x_name inlet is_build =d |> member "kind" |> to_option to_string = Some "build"inList.iter self#add_path b.destdir;let name =match d |> member "rename" |> to_option to_string with| Some rename -> rename| None -> x_nameinlet r, h = if is_build then (build_de, build_h) else (de, h) inlet* acc = x#accumulated_deps inlet* _ =Hashtbl.fold(fun name v acc ->if Hashtbl.find_opt h name = None then (let* _ = acc inlet* b = v#build inList.iter self#add_path b.destdir;Hashtbl.add h name b;Lwt.return ())else Lwt.return ())acc (Lwt.return ())inlet is_proc_macro =List.exists(fun t ->List.exists(fun k -> k = "proc-macro")(t |> member "kind" |> to_list |> filter_string))x#targetsinr := (name, x_name, x_hash, is_proc_macro, b) :: !r;Lwt.return ()) - edit in elpe/lib/rust/rust.ml at line 410
List.iter(fun (x_name, x_hash, b) ->let d = Hashtbl.find package_deps x_name inlet is_build =d |> member "kind" |> to_option to_string = Some "build"inList.iter self#add_path b.destdir;let name =match d |> member "rename" |> to_option to_string with| Some rename -> rename| None -> x_nameinlet r = if is_build then build_de else de inr :=!r ^ " -L dependency=target/deps --extern " ^ name ^ "="^ List.hd b.destdir ^ "/lib/lib" ^ x_name ^ "-" ^ x_hash^ ".rlib")deps; - replacement in elpe/lib/rust/rust.ml at line 411
let result = { build_dependencies = !build_de; dependencies = !de } inlet result ={build_dependencies = !build_de;transitive_build_dependencies = build_h;dependencies = !de;transitive_dependencies = h;}in - replacement in elpe/lib/rust/rust.ml at line 422
method! build_inputs = Lwt.return [ ubuntu "coreutils"; cc ]method! build_inputs =Lwt.return([ubuntu "coreutils";ubuntu "sed";ubuntu "gcc";ubuntu "grep";ubuntu "gawk";cc;]@ extra_crate_dependencies self#name self#version) - replacement in elpe/lib/rust/rust.ml at line 438
ref ("set -x\nmkdir -p target/build-" ^ hash ^ "\nexport RUSTC=rustc\n")ref ("mkdir -p target/build-" ^ hash ^ "\nexport RUSTC=rustc\n") - edit in elpe/lib/rust/rust.ml at line 448
let v0, v1, v2, v4 = self#semantic_version inlet name = self#name inlet version = self#version in - edit in elpe/lib/rust/rust.ml at line 452
setup :=!setup^ [%string{|export OUT_DIR=$DESTDIR/libexport CARGO_PKG_VERSION="%{version}"export CARGO_PKG_NAME="%{name}"export CARGO_PKG_VERSION_MAJOR=%{v0#Int}export CARGO_PKG_VERSION_MINOR=%{v1#Int}export CARGO_PKG_VERSION_PATCH=%{v2#Int}export CARGO_PKG_VERSION_PATCH=%{Option.value v4 ~default:""}export TARGET="%{Platform.triple target}"export HOST="%{Platform.triple host}"export OPT_LEVEL=%{opt_level}export CARGO_CFG_UNIX=1export CARGO_CFG_TARGET_ABI=""export CARGO_CFG_TARGET_OS=linuxexport CARGO_CFG_TARGET_ENDIAN="%{Platform.string_of_endianness (Platform.endianness target)}"export CARGO_CFG_TARGET_POINTER_WIDTH=%{(Platform.pointer_width target)#Int}export CARGO_CFG_TARGET_ENV="%{Platform.env target}"export CARGO_CFG_TARGET_ARCH="%{Platform.string_of_arch target.arch}"|}]; - replacement in elpe/lib/rust/rust.ml at line 487
(self#compile_target setup None target "bin"d.build_dependencies ("target/build-" ^ hash))(self#compile_target setup host target "bin"d.transitive_build_dependencies d.build_dependencies("target/build-" ^ hash)) - replacement in elpe/lib/rust/rust.ml at line 493
(true, None)(package |> member "targets" |> to_list)(true, None) self#targets - replacement in elpe/lib/rust/rust.ml at line 495
(* If there is a build script, call it. *)setup := !setup ^ "mkdir -p $OUT_DIR || true\n"; - replacement in elpe/lib/rust/rust.ml at line 500
setup := !setup ^ "target/build-" ^ hash ^ "/" ^ bs_name ^ "\n"setup :=!setup^ [%string{|CRATENAME=$(echo %{name} | sed -e "s/\(.*\)-sys$/\U\1/" -e "s/-/_/g")CRATEVERSION=$(echo %{version} | sed -e "s/[\.\+-]/_/g")|}]^ String.trim [%blob "run_build_script.sh"]^ [%string "<<< $(target/build-%{hash}/%{bs_name})\n"] - replacement in elpe/lib/rust/rust.ml at line 521
(fun target ->(fun build_target -> - replacement in elpe/lib/rust/rust.ml at line 524
if kind = "bin" thenif !has_bin then ()else (has_bin := true;setup := !setup ^ "mkdir -p $DESTDIR/bin\n")if kind = "bin" then if !has_bin then () else has_bin := true - replacement in elpe/lib/rust/rust.ml at line 526
else (has_lib := true;setup := !setup ^ "mkdir -p $DESTDIR/lib\n");else has_lib := true; - replacement in elpe/lib/rust/rust.ml at line 531
self#compile_target setup target_platform target kindd.dependencies "$DESTDIR/lib"self#compile_target setup target build_target kindd.transitive_dependencies d.dependencies "$OUT_DIR" - replacement in elpe/lib/rust/rust.ml at line 536
let _ =self#compile_target setup target_platform target kindd.dependencies "$DESTDIR/bin"in()if is_top_level thenlet _ =self#compile_target setup target build_target kindd.transitive_dependencies d.dependencies"$OUT_DIR/../bin"in()else () - replacement in elpe/lib/rust/rust.ml at line 545
(target |> member "kind" |> to_list |> filter_string))(package |> member "targets" |> to_list);(build_target |> member "kind" |> to_list |> filter_string))self#targets; - edit in elpe/lib/rust/rust.ml at line 548
method! install_phase =Lwt.return{|if [[ -s target/env ]]; thenmkdir -p $DESTDIR/libcp target/env $DESTDIR/libfi|} - replacement in elpe/lib/rust/rust.ml at line 559
let rust ?(rust_version = "1.84") ?(platform = None) src =let rec dfs nodes seen result n =match Hashtbl.find_opt seen n with| Some () -> result| None ->let _ = Hashtbl.add seen n () inlet node = Hashtbl.find nodes n inlet deps = node |> member "dependencies" |> to_list |> filter_string inlet result = List.fold_left (dfs nodes seen) result deps innode :: resultlet topo_sort n_nodes nodes =let h = Hashtbl.create n_nodes inlet nodes_list =List.fold_left(fun list node ->let id = node |> member "id" |> to_string inHashtbl.add h id node;id :: list)[] nodesinlet seen = Hashtbl.create n_nodes inList.fold_left (dfs h seen) [] nodes_listlet rust ?(rust_version = "1.84") ?(target = !Platform.target)?(host = !Platform.host) src = - edit in elpe/lib/rust/rust.ml at line 593
let cc = ubuntu "build-essential" in - replacement in elpe/lib/rust/rust.ml at line 595
new metadata rust_version cargo rustc platform src n_packages packagesnew metadatarust_version cargo rustc (Platform.triple target) src n_packages packages - replacement in elpe/lib/rust/rust.ml at line 609
let workspace_members =meta_json |> member "workspace_members" |> to_list |> filter_stringin - edit in elpe/lib/rust/rust.ml at line 627
- replacement in elpe/lib/rust/rust.ml at line 633
let is_top_level = List.exists (fun w -> w = name) workspace_members inlet cc = (cc :> derivation) in - replacement in elpe/lib/rust/rust.ml at line 637
rust_version rustc cc platform meta drv dependencies features~rust_version ~rustc ~cc ~target ~host ~package:meta ~path:drv~dependencies ~features ~opt_level:"3" ~is_top_level - replacement in elpe/lib/rust/rust.ml at line 641
nodes;(List.rev (topo_sort n_packages nodes)); - replacement in elpe/lib/rust/rust.ml at line 643
Lwt.return(List.map (Hashtbl.find resolved)(meta_json |> member "workspace_members" |> to_list |> filter_string))[7.4863]Lwt.return (List.map (Hashtbl.find resolved) workspace_members) - file addition: run_build_script.sh[0.15691]
while read cargo; doeval $(echo $cargo | sed -ne 's/cargo:rustc-link-arg=\(.*\)/RUSTC_FLAGS="-C link_arg=\1 $RUSTC_FLAGS"/p')eval $(echo $cargo | sed -ne 's/cargo:rustc-link-lib=\(.*\)/RUSTC_FLAGS="-l\1 $RUSTC_FLAGS"/p')eval $(echo $cargo | sed -ne 's/cargo:rustc-link-search=\(.*\)/RUSTC_FLAGS="-L\1 $RUSTC_FLAGS"/p')eval $(echo $cargo | sed -ne "s/cargo:rustc-cfg=\(.*\)/RUSTC_FLAGS='--cfg \1 $RUSTC_FLAGS'/p")eval $(echo $cargo | sed -ne 's/cargo:rustc-flags=\(.*\)/RUSTC_FLAGS="\1 $RUSTC_FLAGS"/p')echo $cargo | grep -P "^cargo:(?!:?(rustc-|warning=|rerun-if-changed=|rerun-if-env-changed))" \| gawk -F= "/^cargo::metadata=/ { gsub(/-/, \"_\", \$2); print \"export \" toupper(\"DEP_$(echo $CRATENAME)_\" \$2) \"=\" \"\\\"\"\$3\"\\\"\"; next }/^cargo:/ { sub(/^cargo::?/, \"\", \$1); gsub(/-/, \"_\", \$1); print \"export \" toupper(\"DEP_$(echo $CRATENAME)_\" \$1) \"=\" \"\\\"\"\$2\"\\\"\"; print \"export \" toupper(\"DEP_$(echo $CRATENAME)_$(echo $CRATEVERSION)_\" \$1) \"=\" \"\\\"\"\$2\"\\\"\"; next }" >> target/envdone - file addition: platform.ml[7.55449]
type arch = Amd64 | Aarch64type endianness = Little | Bigtype platform = { arch : arch; env : string }let default = { arch = Amd64; env = "gnu" }let endianness p = match p.arch with Amd64 | Aarch64 -> Littlelet env p = p.envlet string_of_endianness = function Little -> "little" | Big -> "big"let string_of_arch = function Amd64 -> "x86_64" | Aarch64 -> "aarch64"let pointer_width _ = 64let triple p =match p.arch with| Amd64 -> "x86_64-unknown-linux-gnu"| Aarch64 -> "aarch64-unknown-linux-gnu"let host = ref defaultlet target = ref default - edit in elpe/lib/elpegrpc.proto at line 73
enum Endianness {big = 0;little = 1;} - edit in elpe/lib/elpegrpc.proto at line 93
}message PlatformReply {Arch arch = 1;Endianness endianness = 2;int32 pointer_width = 3; - edit in elpe/lib/elpegrpc.proto at line 101
message Empty {} - edit in elpe/lib/elpegrpc.proto at line 104
rpc Handshake (Empty) returns (PlatformReply); - replacement in elpe/lib/elpe.ml at line 11
let rec walk_dir_rec encode f buf path path_name =let rec is_ignored ignored dir path current =match ignored with| [] -> current| (negated, dir_only, h) :: t ->is_ignored t dir path(if negated && current then not (Str.string_match h path 0)else if (dir_only && dir) || not dir_only thencurrent || Str.string_match h path 0else current)let is_ignored_dir ignored path = is_ignored ignored true path falselet is_ignored_file ignored path = is_ignored ignored false path falselet rec walk_dir_rec encode f buf ignored path path_name = - replacement in elpe/lib/elpe.ml at line 43
let req =AddPathRequest.make~request:(`Directory(AddPathRequest.Directory.make ~name:path_name~permissions:0o644 ()))()inlet enc = encode req |> Writer.contents inf (Some enc);walk_dir_rec encode f buf path path_nameif not (is_ignored_dir ignored path_name) then (let req =AddPathRequest.make~request:(`Directory(AddPathRequest.Directory.make ~name:path_name~permissions:0o644 ()))()inlet enc = encode req |> Writer.contents inf (Some enc);walk_dir_rec encode f buf ignored path path_name)else Lwt.return () - replacement in elpe/lib/elpe.ml at line 57
let* file = Lwt_unix.openfile path [ O_RDONLY ] 0 inlet ff =AddPathRequest.File.make ~name:path_name~length:stat.st_size ~permissions:0o644 ()inlet req = AddPathRequest.make ~request:(`File ff) () inlet enc = encode req |> Writer.contents inlet () = f (Some enc) inlet rec read_all n =let* r = Lwt_unix.read file buf 0 4096 inif r != 0 thenlet req =AddPathRequest.make~request:(`Contents(AddPathRequest.FileContents.make ~start:n~content:(Bytes.sub buf 0 r) ()))()inlet enc = encode req |> Writer.contents inlet () = f (Some enc) inread_all (n + r)else Lwt.return ()inread_all 0if not (is_ignored_file ignored path_name) thenlet* file = Lwt_unix.openfile path [ O_RDONLY ] 0 inlet ff =AddPathRequest.File.make ~name:path_name~length:stat.st_size ~permissions:0o644 ()inlet req = AddPathRequest.make ~request:(`File ff) () inlet enc = encode req |> Writer.contents inlet () = f (Some enc) inlet rec read_all n =let* r = Lwt_unix.read file buf 0 4096 inif r != 0 thenlet req =AddPathRequest.make~request:(`Contents(AddPathRequest.FileContents.make ~start:n~content:(Bytes.sub buf 0 r) ()))()inlet enc = encode req |> Writer.contents inlet () = f (Some enc) inread_all (n + r)else Lwt.return ()inread_all 0else Lwt.return () - replacement in elpe/lib/elpe.ml at line 92
let add_path connection path0 =let add_path connection ignored path0 = - replacement in elpe/lib/elpe.ml at line 104
let* _ = walk_dir_rec encode f buf path0 "" inlet* _ = walk_dir_rec encode f buf ignored path0 "" in - edit in elpe/lib/elpe.ml at line 118
let rec read_ignore ign =trylet line = input_line ign inlet rest = read_ignore ign inlet regexp = Str.regexp {|\(\\#\)\|\(^#\)\|\(^!\)\|\(\*\*\)\|\*|} inlet result = ref "" inlet i = ref 0 inlet negated = ref false inlet _ =trylet ended = ref false inwhile not !ended dolet next = Str.search_forward regexp line !i inlet _ =if next - !i > 0 thenresult := !result ^ Str.quote (String.sub line !i (next - !i))else ()inlet m = Str.matched_string line inlet _ =match m with| "!" -> negated := true| "#" -> ended := true| "**" -> result := !result ^ ".*"| "*" -> result := !result ^ "[^/]*"| "\\#" -> result := !result ^ "#"| m -> result := !result ^ Str.quote mini := next + String.length mdonewith Not_found ->result :=!result ^ Str.quote (String.sub line !i (String.length line - !i))inif String.length !result > 0 thenlet dir_only = !result.[String.length !result - 1] = '/' inlet result =if dir_only then String.sub !result 0 (String.length !result - 1)else !resultinif String.contains result '/' then(!negated, dir_only, Str.regexp result) :: restelse(!negated, dir_only, Str.regexp ({|\(\(.+/\)\|^\)|} ^ result)) :: restelse restwith End_of_file -> [] - edit in elpe/lib/elpe.ml at line 171
val cached = ref None - replacement in elpe/lib/elpe.ml at line 174[7.58910]→[7.58910:58998](∅→∅),[7.59300]→[7.59300:59309](∅→∅),[7.59309]→[7.280:313](∅→∅),[7.313]→[7.59399:59439](∅→∅),[7.59399]→[7.59399:59439](∅→∅),[7.59439]→[7.68948:68969](∅→∅),[7.7630]→[7.72562:72631](∅→∅),[7.72562]→[7.72562:72631](∅→∅),[7.72631]→[4.4737:4783](∅→∅),[4.4783]→[7.72662:72688](∅→∅),[7.72662]→[7.72662:72688](∅→∅)
let c =match !backend_conn with None -> failwith "no conn" | Some c -> cinlet* res = add_path c p inlet res, _ = Result.get_ok res inmatch res with| `Ok r -> Lwt.return { destdir = r.destdir; paths = r.paths }| `Error e -> raise (DerivationError e)| _ -> assert falsematch !cached with| None ->let c =match !backend_conn with None -> failwith "no conn" | Some c -> cinlet ignored =try read_ignore (open_in ".ignore") with Sys_error _ -> []inlet* res = add_path c ignored p inlet res, _ = Result.get_ok res inlet result =match res with| `Ok r -> { destdir = r.destdir; paths = r.paths }| `Error e -> raise (DerivationError e)| _ -> assert falseincached := Some result;Lwt.return result| Some cached -> Lwt.return cached - edit in elpe/lib/dune at line 1
(include_subdirs unqualified) - replacement in elpe/lib/dune at line 3
(name elpe)(public_name elpe)(modes byte)(libraries grpc-lwt lwt lwt.unix h2 h2-lwt-unix ocaml-protoc-plugin core yojson toml hex))(name elpe)(public_name elpe)(modes byte)(preprocess (pps ppx_blob ppx_string))(preprocessor_deps (file run_build_script.sh))(libraries grpc-lwt lwt lwt.unix h2 h2-lwt-unix ocaml-protoc-plugin core yojson toml hex)) - replacement in elpe/lib/dune at line 12[7.62517]→[7.62517:62611](∅→∅),[7.62611]→[7.72941:73010](∅→∅),[7.73010]→[7.62676:62691](∅→∅),[7.62676]→[7.62676:62691](∅→∅)
(targets elpegrpc.ml)(deps(:proto elpegrpc.proto))(action(runprotoc-I."--ocaml_out=annot=[@@deriving show { with_path = false }, eq]:."%{proto})))[7.62517](targets elpegrpc.ml)(deps(:proto elpegrpc.proto))(action(runprotoc-I."--ocaml_out=annot=[@@deriving show { with_path = false }, eq]:."%{proto}))) - edit in elpe/lib/derivation.ml at line 36
let ubuntu_releases = Hashtbl.create 8let ubuntu_release_lock = Lwt_mutex.create () - replacement in elpe/lib/derivation.ml at line 41
let req =Elpegrpc.Elpe.UbuntuReleaseRequest.make ~release ~arch ~repository ()inlet open Ocaml_protoc_plugin inlet encode, decode =Service.make_client_functions Elpegrpc.Elpe.Elpe.ubuntuReleaseinlet enc = encode req |> Writer.contents inClient.call ~service:"elpe.Elpe" ~rpc:"UbuntuRelease"~do_request:(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->failwith "Error"))~handler:(Client.Rpc.unary enc ~f:(fun decoder ->let+ decoder = decoder inmatch decoder with| Some decoder -> (Reader.create decoder |> decode |> function| Ok v -> v| Error e ->failwith(Printf.sprintf "Could not decode request: %s"(Result.show_error e)))| None -> Elpegrpc.Elpe.Elpe.Derivation.Response.make ()))()Lwt_mutex.with_lock ubuntu_release_lock (fun () ->match Hashtbl.find_opt ubuntu_releases (release, arch, repository) with| None ->let req =Elpegrpc.Elpe.UbuntuReleaseRequest.make ~release ~arch ~repository()inlet open Ocaml_protoc_plugin inlet encode, decode =Service.make_client_functions Elpegrpc.Elpe.Elpe.ubuntuReleaseinlet enc = encode req |> Writer.contents inlet* r =Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuRelease"~do_request:(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->failwith "Error"))~handler:(Client.Rpc.unary enc ~f:(fun decoder ->let+ decoder = decoder inmatch decoder with| Some decoder -> (Reader.create decoder |> decode |> function| Ok v -> v| Error e ->failwith(Printf.sprintf "Could not decode request: %s"(Result.show_error e)))| None -> Elpegrpc.Elpe.Elpe.Derivation.Response.make ()))()inHashtbl.add ubuntu_releases (release, arch, repository) r;Lwt.return r| Some x -> Lwt.return x) - edit in elpe/lib/derivation.ml at line 77
let ubuntu_packages = Hashtbl.create 64let ubuntu_packages_locks = Hashtbl.create 64 - replacement in elpe/lib/derivation.ml at line 81
let link_extra =List.map(fun (pkg, dep) -> Elpegrpc.Elpe.LinkExtra.make ~pkg ~dep ())link_extralet lock =try Hashtbl.find ubuntu_packages_locks (index, name)with Not_found ->let lock = Lwt_mutex.create () inHashtbl.add ubuntu_packages_locks (index, name) lock;lock - replacement in elpe/lib/derivation.ml at line 88[7.16710]→[7.16710:16799](∅→∅),[7.16799]→[7.2405:2579](∅→∅),[7.2405]→[7.2405:2579](∅→∅),[7.2579]→[4.4822:5909](∅→∅)
let req =Elpegrpc.Elpe.UbuntuPackageRequest.make ~index ~name ~link_extra ()inlet open Ocaml_protoc_plugin inlet encode, decode =Service.make_client_functions Elpegrpc.Elpe.Elpe.ubuntuPackageinlet enc = encode req |> Writer.contents inlet result = ref None inlet* x =Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuPackage"~do_request:(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->failwith "Error"))~handler:(Client.Rpc.server_streaming enc ~f:(fun responses ->Lwt_stream.iter_s(fun str ->Reader.create str |> decode |> function| Ok (`Ok v) ->result := Some v;Lwt.return ()| Ok (`Loading v) ->Printf.eprintf "Downloading %s\n" v;Stdlib.flush Stdlib.stderr;Lwt.return ()| Error e ->failwith(Printf.sprintf "Could not decode request: %s"(Result.show_error e))| _ -> Lwt.return ())responses))()inmatch x with| Ok _ -> Lwt.return (Ok (Option.get !result))| Error e -> Lwt.return (Error e)type arch = Amd64 | Aarch64Lwt_mutex.with_lock lock (fun () ->match Hashtbl.find_opt ubuntu_packages (index, name) with| Some x -> Lwt.return x| None ->let link_extra =List.map(fun (pkg, dep) -> Elpegrpc.Elpe.LinkExtra.make ~pkg ~dep ())link_extrainlet req =Elpegrpc.Elpe.UbuntuPackageRequest.make ~index ~name ~link_extra ()inlet open Ocaml_protoc_plugin inlet encode, decode =Service.make_client_functions Elpegrpc.Elpe.Elpe.ubuntuPackageinlet enc = encode req |> Writer.contents inlet result = ref None inlet* x =Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuPackage"~do_request:(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->failwith "Error"))~handler:(Client.Rpc.server_streaming enc ~f:(fun responses ->Lwt_stream.iter_s(fun str ->Reader.create str |> decode |> function| Ok (`Ok v) ->result := Some v;Lwt.return ()| Ok (`Loading v) ->Printf.eprintf "Downloading %s\n%!" v;Lwt.return ()| Error e ->failwith(Printf.sprintf "Could not decode request: %s"(Result.show_error e))| _ -> Lwt.return ())responses))()inlet result =match x with Ok _ -> Ok (Option.get !result) | Error e -> Error einHashtbl.add ubuntu_packages (index, name) result;Lwt.return result) - replacement in elpe/lib/derivation.ml at line 136
let ubuntu ?(release = "plucky") ?(arch = Amd64) name =let ubuntu ?(release = "plucky") ?(platform = !Platform.target) name = - replacement in elpe/lib/derivation.ml at line 157
match arch withmatch platform.arch with - replacement in elpe/lib/derivation.ml at line 215
Printf.printf "%s" buf;Stdlib.flush Stdlib.stdoutPrintf.printf "%s%!" buf - replacement in elpe/lib/derivation.ml at line 224
Printf.eprintf "%s" buf;Stdlib.flush Stdlib.stderrPrintf.eprintf "%s%!" buf - replacement in elpe/lib/derivation.ml at line 364
let http ~url ~hash_algorithm ~hash =let http ~name ~url ~hash_algorithm ~hash = - replacement in elpe/lib/derivation.ml at line 367
method name = "http"method name = "http" ^ if name = "" then "" else "-" ^ name - replacement in elpe/lib/derivation.ml at line 407
let unzip pkg =let unzip ?(name = "") pkg = - replacement in elpe/lib/derivation.ml at line 410
method name = "rust"method name = "unzip" ^ if name = "" then "" else "-" ^ name - replacement in elpe/lib/derivation.ml at line 414
Lwt.return[(ubuntu "libc6-dev" :> derivation);(ubuntu "coreutils" :> derivation);(ubuntu "tar" :> derivation);(ubuntu "gzip" :> derivation);]Lwt.return [ ubuntu "coreutils"; ubuntu "tar"; ubuntu "gzip" ] - edit in elpe/lib/derivation.ml at line 421[6.14511]
let cc =object (self)inherit std_derivationmethod name = "cc"method! build_inputs = Lwt.return [ ubuntu "coreutils"; ubuntu "gcc" ]method! unpack_phase = Lwt.return ""method! build_phase =let* gcc = (ubuntu "gcc")#build inList.iter self#add_path gcc.destdir;Lwt.return("mkdir -p $DESTDIR/usr/bin; ln -s " ^ List.hd gcc.destdir^ "/usr/bin/gcc $DESTDIR/usr/bin/cc")end - edit in default.nix at line 122
ocamlPackages.ppx_stringocamlPackages.ppx_blob