scx-upstream/meson-scripts/fetch_libbpf
Andrea Righi 273728fd2b meson: check if commit exists in remote git repos
When fetching external git repositories (libbpf and bpftool) we don't
check if the target commit exists.

This can leads to issues such as #400, because we may silently use HEAD,
instead of the specified commit.

Prevent this by returning an error when the target SHA1 cannot be found.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
2024-06-28 15:16:56 +02:00

20 lines
370 B
Bash

#!/bin/bash
URL=https://github.com/libbpf/libbpf.git
unset CDPATH
cd $1
rm -rf libbpf
git clone --depth=1 ${URL}
cd libbpf
git fetch --depth=1 origin $2 || {
echo "commit $2 does not exists in ${URL}"
exit 1
}
git checkout $2
# This is needed because we haven't built libbpf yet
# and this is where the headers will end up
mkdir src/usr
mkdir src/usr/include