build-package.sh: add hook to prevent execution of sudo

Do not let privileged commands appear in build.sh. Any environment
configuration should be done by scripts like setup-ubuntu.sh. Execution
of arbitrary sudo commands could mess up host system, in case if not
building package in Docker container or VM.
This commit is contained in:
Leonid Pliushch 2021-07-07 23:27:54 +03:00
parent 69ccc66639
commit 90e2de6fcc
No known key found for this signature in database
GPG Key ID: 45F2964132545795
1 changed files with 6 additions and 0 deletions

View File

@ -244,6 +244,12 @@ if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
export TERMUX_ARCH
fi
# Special hook to prevent use of "sudo" inside package build scripts.
# build-package.sh shouldn't perform any privileged operations.
sudo() {
termux_error_exit "Do not use 'sudo' inside build scripts. Build environment should be configured through ./scripts/setup-ubuntu.sh."
}
_show_usage() {
echo "Usage: ./build-package.sh [options] PACKAGE_1 PACKAGE_2 ..."
echo