feat(contrib/fetchroots): track git revisions
Change-Id: I3af0a4486a8685191adc28210162661fae6cfc3c Reviewed-on: https://cl.snix.dev/c/snix/+/30290 Reviewed-by: Florian Klink <flokli@flokli.de> Tested-by: besadii
This commit is contained in:
parent
d108eecb24
commit
7b20d0dac1
4 changed files with 39 additions and 4 deletions
5
contrib/fetchroots/Cargo.lock
generated
5
contrib/fetchroots/Cargo.lock
generated
|
|
@ -917,9 +917,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "data-encoding"
|
name = "data-encoding"
|
||||||
version = "2.6.0"
|
version = "2.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "der"
|
name = "der"
|
||||||
|
|
@ -1099,6 +1099,7 @@ dependencies = [
|
||||||
"bytes-utils",
|
"bytes-utils",
|
||||||
"bzip2",
|
"bzip2",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"data-encoding",
|
||||||
"futures",
|
"futures",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"nix-compat",
|
"nix-compat",
|
||||||
|
|
|
||||||
|
|
@ -3099,9 +3099,9 @@ rec {
|
||||||
};
|
};
|
||||||
"data-encoding" = rec {
|
"data-encoding" = rec {
|
||||||
crateName = "data-encoding";
|
crateName = "data-encoding";
|
||||||
version = "2.6.0";
|
version = "2.8.0";
|
||||||
edition = "2018";
|
edition = "2018";
|
||||||
sha256 = "1qnn68n4vragxaxlkqcb1r28d3hhj43wch67lm4rpxlw89wnjmp8";
|
sha256 = "0470yf5ly1ibzmwygyjqg9ii9njbsha3xr5qj5dxyf2psbgpapsp";
|
||||||
libName = "data_encoding";
|
libName = "data_encoding";
|
||||||
authors = [
|
authors = [
|
||||||
"Julien Cretin <git@ia0.eu>"
|
"Julien Cretin <git@ia0.eu>"
|
||||||
|
|
@ -3721,6 +3721,10 @@ rec {
|
||||||
name = "chrono";
|
name = "chrono";
|
||||||
packageId = "chrono";
|
packageId = "chrono";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "data-encoding";
|
||||||
|
packageId = "data-encoding";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "futures";
|
name = "futures";
|
||||||
packageId = "futures";
|
packageId = "futures";
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ bytes = "1.5.0"
|
||||||
bytes-utils = "0.1.4"
|
bytes-utils = "0.1.4"
|
||||||
bzip2 = "0.4.4"
|
bzip2 = "0.4.4"
|
||||||
chrono = "0.4.34"
|
chrono = "0.4.34"
|
||||||
|
data-encoding = "2.8.0"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
indicatif = "0.17.8"
|
indicatif = "0.17.8"
|
||||||
nix-compat = { version = "0.1.0", path = "../../snix/nix-compat" }
|
nix-compat = { version = "0.1.0", path = "../../snix/nix-compat" }
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
//! The resulting Parquet has three columns:
|
//! The resulting Parquet has three columns:
|
||||||
//!
|
//!
|
||||||
//! * `key` (`String`): the release, eg `nixos/22.11-small/nixos-22.11.513.563dc6476b8`
|
//! * `key` (`String`): the release, eg `nixos/22.11-small/nixos-22.11.513.563dc6476b8`
|
||||||
|
//! * `git_rev` (`Binary`): the git revision hash of this release, if available
|
||||||
//! * `timestamp` (`DateTime`): the timestamp of the GC roots file for this release
|
//! * `timestamp` (`DateTime`): the timestamp of the GC roots file for this release
|
||||||
//! * `store_path_hash` (`List[Binary]`): hash part of the store paths rooted by this release
|
//! * `store_path_hash` (`List[Binary]`): hash part of the store paths rooted by this release
|
||||||
//!
|
//!
|
||||||
//! [^1]: some roots are truly ancient, and aren't compatible with Nix 1.x
|
//! [^1]: some roots are truly ancient, and aren't compatible with Nix 1.x
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use data_encoding::HEXLOWER;
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
fs::File,
|
fs::File,
|
||||||
|
|
@ -123,6 +125,31 @@ async fn main() {
|
||||||
js.spawn(async move {
|
js.spawn(async move {
|
||||||
let _permit = sem.acquire().await.unwrap();
|
let _permit = sem.acquire().await.unwrap();
|
||||||
|
|
||||||
|
// TODO(edef): learn whether there is a git-revision from the listings
|
||||||
|
let rev = s3
|
||||||
|
.get_object()
|
||||||
|
.bucket("nix-releases")
|
||||||
|
.key(format!("{root}/git-revision"))
|
||||||
|
.send()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let rev = match rev {
|
||||||
|
Ok(resp) => {
|
||||||
|
let hex = resp.body.collect().await.unwrap().to_vec();
|
||||||
|
let mut buf = [0; 20];
|
||||||
|
assert_eq!(HEXLOWER.decode_mut(&hex, &mut buf).unwrap(), buf.len());
|
||||||
|
Ok(Some(buf))
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
if e.as_service_error().is_some_and(|e| e.is_no_such_key()) {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Err(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let body = get_object(
|
let body = get_object(
|
||||||
s3.get_object()
|
s3.get_object()
|
||||||
.bucket("nix-releases")
|
.bucket("nix-releases")
|
||||||
|
|
@ -136,6 +163,7 @@ async fn main() {
|
||||||
let ph_array = block_in_place(|| meta.format.to_ph_array(body).rechunk());
|
let ph_array = block_in_place(|| meta.format.to_ph_array(body).rechunk());
|
||||||
df! {
|
df! {
|
||||||
"key" => [root],
|
"key" => [root],
|
||||||
|
"git_rev" => [rev.as_ref().map(|r| &r[..])],
|
||||||
"timestamp" => [meta.last_modified.naive_utc()],
|
"timestamp" => [meta.last_modified.naive_utc()],
|
||||||
"store_path_hash" => ph_array.into_series().implode().unwrap()
|
"store_path_hash" => ph_array.into_series().implode().unwrap()
|
||||||
}
|
}
|
||||||
|
|
@ -146,6 +174,7 @@ async fn main() {
|
||||||
let mut writer = ParquetWriter::new(File::create("roots.parquet").unwrap())
|
let mut writer = ParquetWriter::new(File::create("roots.parquet").unwrap())
|
||||||
.batched(&Schema::from_iter([
|
.batched(&Schema::from_iter([
|
||||||
Field::new("key", DataType::String),
|
Field::new("key", DataType::String),
|
||||||
|
Field::new("git_rev", DataType::Binary),
|
||||||
Field::new(
|
Field::new(
|
||||||
"timestamp",
|
"timestamp",
|
||||||
DataType::Datetime(TimeUnit::Milliseconds, None),
|
DataType::Datetime(TimeUnit::Milliseconds, None),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue