Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Allan McRae
69aa94c817 libmakepkg: add linting of BUILDENV and OPTIONS from makepkg.conf
Currently the options array from a PKGBUILD is linted, but the global
BUILDENV and OPTIONS are not.

Fixes #233.

Signed-off-by: Allan McRae <allan@archlinux.org>
2025-08-02 15:32:11 +10:00
2 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,57 @@
#!/bin/bash
#
# buildenv.sh - Check that the BUILDENV and OPTIONS arrays are valid
#
# Copyright (c) 2025 Pacman Development Team <pacman-dev@lists.archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n $LIBMAKEPKG_LINT_CONFIG_BUILDENV_SH ]] && return
LIBMAKEPKG_LINT_CONFIG_BUILDENV_SH=1
MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}
source "$MAKEPKG_LIBRARY/util/message.sh"
lint_config_functions+=('lint_buildenv')
lint_buildenv() {
local ret=0 kopt
local known_buildenv=(ccache check color distcc sign)
local known_option=(autodeps debug docs emptydirs libtool lto purge staticlibs strip zipman)
for i in "${BUILDENV[@]}"; do
for kopt in "${known_buildenv[@]}"; do
if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
continue 2
fi
done
error "$(gettext "%s array contains unknown option '%s'")" "BUILDENV" "$i"
ret=1
done
for i in "${OPTIONS[@]}"; do
for kopt in "${known_option[@]}"; do
if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
continue 2
fi
done
error "$(gettext "%s array contains unknown option '%s'")" "OPTIONS" "$i"
ret=1
done
}

View file

@ -1,6 +1,7 @@
libmakepkg_module = 'lint_config'
sources = [
'buildenv.sh.in',
'ext.sh.in',
'nproc.sh.in',
'packager.sh.in',