SCRIPTS: build-vtest: allow to set a TMPDIR and a DESTDIR
Some checks are pending
Contrib / build (push) Waiting to run
alpine/musl / gcc (push) Waiting to run
VTest / Generate Build Matrix (push) Waiting to run
VTest / (push) Blocked by required conditions
Windows / Windows, gcc, all features (push) Waiting to run

Implement a way to set a destination directory using DESTDIR, and a tmp
directory using TMPDIR.

By default:

- DESTDIR is ../vtest like it was done previously
- TMPDIR  is mktemp -d

Only the vtest binary is copied in DESTDIR.

Example:

	TMPDIR=/dev/shm/ DESTDIR=/home/user/.local/bin/ ./scripts/build-vtest.sh
This commit is contained in:
William Lallemand 2026-02-12 18:48:09 +01:00
parent d13164e105
commit f47b800ac3

View file

@ -1,10 +1,12 @@
#!/bin/sh
DESTDIR=${DESTDIR:-${PWD}/../vtest/}
TMPDIR=${TMPDIR:-$(mktemp -d)}
set -eux
curl -fsSL https://github.com/vtest/VTest2/archive/main.tar.gz -o VTest.tar.gz
mkdir ../vtest
tar xvf VTest.tar.gz -C ../vtest --strip-components=1
curl -fsSL https://github.com/vtest/VTest2/archive/main.tar.gz -o "${TMPDIR}/VTest.tar.gz"
mkdir -p "${TMPDIR}/vtest"
tar xvf ${TMPDIR}/VTest.tar.gz -C "${TMPDIR}/vtest" --strip-components=1
# Special flags due to: https://github.com/vtest/VTest/issues/12
# Note: do not use "make -C ../vtest", otherwise MAKEFLAGS contains "w"
@ -13,7 +15,7 @@ tar xvf VTest.tar.gz -C ../vtest --strip-components=1
# MFLAGS works on BSD but misses variable definitions on GNU Make.
# Better just avoid the -C and do the cd ourselves then.
cd ../vtest
cd "${TMPDIR}/vtest"
set +e
CPUS=${CPUS:-$(nproc 2>/dev/null)}
@ -28,3 +30,6 @@ if test -f /opt/homebrew/include/pcre2.h; then
else
make -j${CPUS} FLAGS="-O2 -s -Wall"
fi
mkdir -p "${DESTDIR}"
cp "${TMPDIR}/vtest/vtest" "${DESTDIR}"