scx-upstream/meson-scripts/fetch_bpftool
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

15 lines
266 B
Bash

#!/bin/bash
URL=https://github.com/libbpf/bpftool.git
cd $1
rm -rf bpftool
git clone --depth=1 ${URL}
cd bpftool
git fetch --depth=1 origin $2 || {
echo "commit $2 does not exists in ${URL}"
exit 1
}
git checkout $2
git submodule update --init --recursive