Skip to content

Commit

Permalink
fix CI build failing due to latest bpf-linker commit
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin JEROME <[email protected]>
  • Loading branch information
qjerome committed Nov 10, 2023
1 parent 727d8e0 commit dda7754
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
18 changes: 14 additions & 4 deletions xtask/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ pub fn checkout<P: AsRef<Path>, S: AsRef<str>>(project: P, commit: S) -> Result<
Ok(())
}

pub fn clone<P: AsRef<Path>>(branch: &str, repo: &str, outdir: P) -> Result<(), anyhow::Error> {
pub fn clone<P: AsRef<Path>>(
branch: &str,
repo: &str,
outdir: P,
depth: u16,
) -> Result<(), anyhow::Error> {
let outdir = outdir.as_ref();

let status = std::process::Command::new("git")
.arg("clone")
.arg("--depth")
.arg("1")
.arg(depth.to_string())
.arg("--single-branch")
.arg("--branch")
.arg(branch)
Expand All @@ -85,13 +90,18 @@ pub fn clone<P: AsRef<Path>>(branch: &str, repo: &str, outdir: P) -> Result<(),
Ok(())
}

pub fn sync<P: AsRef<Path>>(branch: &str, repo: &str, outdir: P) -> Result<(), anyhow::Error> {
pub fn sync<P: AsRef<Path>>(
branch: &str,
repo: &str,
outdir: P,
depth: u16,
) -> Result<(), anyhow::Error> {
let outdir = outdir.as_ref();

if outdir.exists() {
// we attempt to git pull the last changes
return pull(repo, outdir);
}

clone(branch, repo, outdir)
clone(branch, repo, outdir, depth)
}
11 changes: 7 additions & 4 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ fn main() -> Result<(), anyhow::Error> {
// bpf-linker related variables
let linker_dir = bt_root.join("bpf-linker");
// linker branch supporting Debug Information (DI)
let linker_repo = "https://github.com/aya-rs/bpf-linker.git";
// it is here a fork of Aya's bpf-linker, it is the only way to be sure
// commit id is valid as Aya's repos are often rebased
let linker_repo = "https://github.com/0xrawsec/bpf-linker";
let linker_branch = "feature/fix-di";
// be carefull of rebased repository while taking commits
let linker_commit = git::last_commit_id(linker_repo, linker_branch)?;
let linker_commit = "ef91ad89c0ce8a66d998bde1e97526eb46501e36";

if opts.action_cache_key {
print!(
Expand All @@ -101,7 +103,7 @@ fn main() -> Result<(), anyhow::Error> {
let llvm_config = llvm_install.join("bin").join("llvm-config");
if !llvm_config.is_file() || opts.force_llvm_build {
println!("Synchronizing repo:{llvm_repo} branch:{llvm_branch}");
git::sync(llvm_branch, llvm_repo, &llvm_dir)?;
git::sync(llvm_branch, llvm_repo, &llvm_dir, 1)?;

println!("Building LLVM");
let llvm_builder = tools::LLVMBuilder::new(&llvm_dir, &llvm_install);
Expand Down Expand Up @@ -133,7 +135,8 @@ fn main() -> Result<(), anyhow::Error> {
}

println!("Synchronizing repo:{linker_repo} branch:{linker_branch}");
git::sync(linker_branch, linker_repo, &linker_dir)?;
// we should rarely need more than 10 commits back
git::sync(linker_branch, linker_repo, &linker_dir, 10)?;

println!("Checking out to commit: {linker_commit}");
git::checkout(&linker_dir, linker_commit)?;
Expand Down

0 comments on commit dda7754

Please sign in to comment.