.github: util.sh: allow explicit commit on clone_source

Add 4th parameter to clone_source() helper for checking out specific commit.
It will clone the given branch (but with full depth) and then checkout
the given commit.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-07 11:04:04 +02:00
committed by Enrico Weigelt
parent fc9bd6b175
commit 2aa982b9a8
2 changed files with 26 additions and 9 deletions

View File

@@ -5,26 +5,37 @@ clone_source() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
if [ ! -f $pkgname/.git/config ]; then
echo "need to clone $pkgname"
git clone $url $pkgname --branch=$ref --depth 1
if [ "$commit" ]; then
git clone $url $pkgname --branch=$ref
else
git clone $url $pkgname --branch=$ref --depth 1
fi
else
echo "already cloned $pkgname"
fi
if [ "$commit" ]; then
( cd $pkgname && git checkout -f "$commit" )
fi
}
build_meson() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
meson "$@" build -Dprefix=$X11_PREFIX
@@ -38,13 +49,15 @@ build_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
./autogen.sh --prefix=$X11_PREFIX
@@ -58,10 +71,12 @@ build_drv_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
clone_source "$pkgname" "$url" "$ref"
shift || true
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
./autogen.sh # --prefix=$X11_PREFIX
@@ -73,13 +88,15 @@ build_ac_xts() {
local pkgname="$1"
local url="$2"
local ref="$3"
local commit="$4"
shift
shift
shift
shift || true
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
clone_source "$pkgname" "$url" "$ref" "$commit"
(
cd $pkgname
CFLAGS='-fcommon'