Forwarding log to frontend
Dependencies
- [2]
LIUJQXB7Allow merging two packages based on regular expressions of their name - [3]
5IT7CXFGDebugging the dependency resolution (Tarjan's SCC algorithm) - [4]
BDEVQIAUHandle cyclic Ubuntu dependencies - [5]
6BIW5YDCRust builder: compiling the crates - [6]
UWQB743KFirst working shell (with ocaml code) - [7]
SI454P2VDocumentation and cleanup - [8]
BQ4E3XLAForwarding stdout/stderr - [9]
R7J4254ZReorganisation of the frontend - [10]
ODUDDQRYAdding the OCaml interface - [11]
F2C3TLOIFetching URLs (server-side)
Change contents
- edit in src/main.rs at line 9
use tokio_util::sync::PollSender; - edit in src/main.rs at line 38
debug!("add_path"); - replacement in src/main.rs at line 41
let tmp_dir = tempfile::tempdir_in(store)?;debug!("store");let tmp_dir = tempfile::tempdir_in(store).unwrap();debug!("store {:?}", tmp_dir); - replacement in src/main.rs at line 46
debug!("loop"); - edit in src/main.rs at line 53
info!("Adding file {:?}", f.name); - edit in src/main.rs at line 62
info!("Adding file {:?}", d.name); - edit in src/main.rs at line 76
debug!("loop done"); - edit in src/main.rs at line 220
type UbuntuPackageStream = ResponseStream; - replacement in src/main.rs at line 225
) -> Result<tonic::Response<proto::DerivationReply>, tonic::Status> {) -> Result<tonic::Response<Self::UbuntuPackageStream>, tonic::Status> { - replacement in src/main.rs at line 245[2.294]→[2.294:380](∅→∅),[2.380]→[3.3465:3507](∅→∅),[3.3465]→[3.3465:3507](∅→∅),[3.3507]→[3.6135:6180](∅→∅),[3.6180]→[3.3538:3595](∅→∅),[3.3538]→[3.3538:3595](∅→∅),[3.3595]→[3.6181:6646](∅→∅)
let p = download_extract_deps(&index, &self.deb_client, &r.name, &link_extra).await.unwrap();info!("path {:?} {:#?}", r.name, p);Ok(tonic::Response::new(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(),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)), - replacement in src/main.rs at line 253
)),}))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/lib.rs at line 10
use futures::SinkExt; - edit in src/lib.rs at line 36
mod dummy_sink;use dummy_sink::*; - edit in src/lib.rs at line 93
/// Package not found#[error("Package not found: {pkg}")]PackageNotFound {/// The package name.pkg: String,}, - edit in src/lib.rs at line 311
std::fs::create_dir_all(store_path.as_ref()).unwrap(); - replacement in src/lib.rs at line 366
let p = extract::download_extract_deps(&index, self, pkg, &[])let p = extract::download_extract_deps(&index, self, pkg, &[], DummySink {}) - replacement in src/lib.rs at line 607
async fn download_url<'a>(&self, url: &str, sha256: &str) -> Result<(Downloaded, bool), Error> {async fn download_url<'a, S: futures::Sink<extract::Msg> + Unpin>(&self,url: &str,sha256: &str,mut tx: S,) -> Result<(Downloaded, bool), Error>whereS::Error: std::fmt::Debug,{ - edit in src/lib.rs at line 624
tx.send(extract::Msg::Downloading(url.to_string())).await.unwrap(); - edit in src/extract.rs at line 42
}/// Messages from the extractor.#[derive(Debug)]pub enum Msg {/// DownloadingDownloading(String),/// ResultOk(Packages),/// ErrorError(Error), - replacement in src/extract.rs at line 57
pub async fn download_extract_deps(pub async fn download_extract_deps<F: futures::Sink<Msg> + Clone + Send + Unpin + 'static>( - replacement in src/extract.rs at line 62
) -> Result<Packages, Error> {let pkg = multi_lookup(index, &package).await.unwrap();tx: F,) -> Result<Packages, Error>whereF::Error: std::fmt::Debug,{let Some(pkg) = multi_lookup(index, &package).await else {return Err(Error::PackageNotFound {pkg: package.to_string(),});}; - replacement in src/extract.rs at line 107
let rx = spawn_extract(client.clone(), &pkg).await;let rx = spawn_extract(client.clone(), &pkg, tx.clone()).await; - replacement in src/extract.rs at line 323
async fn spawn_extract<'a>(async fn spawn_extract<'a, S: futures::Sink<Msg> + Send + Unpin + 'static>( - replacement in src/extract.rs at line 326
) -> tokio::sync::oneshot::Receiver<Result<Downloaded, Error>> {log_tx: S,) -> tokio::sync::oneshot::Receiver<Result<Downloaded, Error>>whereS::Error: std::fmt::Debug,{ - replacement in src/extract.rs at line 337
let (mut task, _) = match client.download_url(&url, &sha256).await {let (mut task, _) = match client.download_url(&url, &sha256, log_tx).await { - file addition: dummy_sink.rs[3.15]
use std::convert::Infallible;use std::pin::Pin;#[derive(Clone, Copy)]pub struct DummySink {}impl<T> futures::Sink<T> for DummySink {type Error = Infallible;fn poll_ready(self: Pin<&mut Self>,_cx: &mut futures::task::Context<'_>,) -> futures::task::Poll<Result<(), Infallible>> {futures::task::Poll::Ready(Ok(()))}fn start_send(self: Pin<&mut Self>, _item: T) -> Result<(), Infallible> {Ok(())}fn poll_flush(self: Pin<&mut Self>,_cx: &mut futures::task::Context<'_>,) -> futures::task::Poll<Result<(), Infallible>> {futures::task::Poll::Ready(Ok(()))}fn poll_close(self: Pin<&mut Self>,_cx: &mut futures::task::Context<'_>,) -> futures::task::Poll<Result<(), Infallible>> {futures::task::Poll::Ready(Ok(()))}} - edit in elpe/lib/elpegrpc.proto at line 64
string loading = 5; - replacement in elpe/lib/elpegrpc.proto at line 95
rpc UbuntuPackage (UbuntuPackageRequest) returns (DerivationReply);rpc UbuntuPackage (UbuntuPackageRequest) returns (stream DerivationReply); - replacement in elpe/lib/elpe.ml at line 115
| `Error e -> failwith e| `Error e -> raise (DerivationError e) - edit in elpe/lib/derivation.ml at line 2
exception DerivationError of string - replacement in elpe/lib/derivation.ml at line 80
Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuPackage"~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 ()))()let 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 | Aarch64 - replacement in elpe/lib/derivation.ml at line 112
let ubuntu ?(release = "plucky") name =let ubuntu ?(release = "plucky") ?(arch = Amd64) name = - replacement in elpe/lib/derivation.ml at line 191
Printf.printf "%s" bufPrintf.printf "%s" buf;Stdlib.flush Stdlib.stdout - replacement in elpe/lib/derivation.ml at line 201
Printf.printf "%s" bufPrintf.eprintf "%s" buf;Stdlib.flush Stdlib.stderr