makepkg - add check for valid options in PKGBUILD
This patch removes the code block in makepkg that checked for depreciated options in a PKGBUILD and provided a workaround. Unknown and depreciated options are upgraded to error conditions. Also, removed TODO regarding including install script if exists and $install is unset. That should never happen. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
da1c11cc30
commit
c1a5616c26
1 changed files with 21 additions and 20 deletions
|
@ -41,6 +41,8 @@ confdir='@sysconfdir@'
|
||||||
startdir="$PWD"
|
startdir="$PWD"
|
||||||
srcdir="$startdir/src"
|
srcdir="$startdir/src"
|
||||||
pkgdir="$startdir/pkg"
|
pkgdir="$startdir/pkg"
|
||||||
|
known_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'ccache' 'distcc' 'makeflags' 'force')
|
||||||
|
readonly -a known_options
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
ASROOT=0
|
ASROOT=0
|
||||||
|
@ -184,25 +186,6 @@ check_option() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# BEGIN DEPRECATED
|
|
||||||
# TODO: This code should be removed in the next release of makepkg.
|
|
||||||
local needle=$(echo $1 | tr [:upper:] [:lower:])
|
|
||||||
local opt
|
|
||||||
for opt in ${options[@]}; do
|
|
||||||
opt=$(echo $opt | tr [:upper:] [:lower:])
|
|
||||||
if [ "$opt" = "no$needle" ]; then
|
|
||||||
warning "$(gettext "Options beginning with 'no' will be deprecated in the next version of makepkg!")"
|
|
||||||
plain "$(gettext "Please replace 'no' with '!': %s -> %s.")" "no$needle" "!$needle"
|
|
||||||
echo 'n' # Disabled
|
|
||||||
return
|
|
||||||
elif [ "$opt" = "keepdocs" -a "$needle" = "docs" ]; then
|
|
||||||
warning "$(gettext "Option 'keepdocs' may not work as intended. Please replace with 'docs'.")"
|
|
||||||
echo 'y' # Enabled
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
# END DEPRECATED
|
|
||||||
|
|
||||||
# fall back to makepkg.conf options
|
# fall back to makepkg.conf options
|
||||||
ret=$(in_opt_array "$1" ${OPTIONS[@]})
|
ret=$(in_opt_array "$1" ${OPTIONS[@]})
|
||||||
if [ "$ret" != '?' ]; then
|
if [ "$ret" != '?' ]; then
|
||||||
|
@ -848,7 +831,6 @@ create_package() {
|
||||||
local comp_files=".PKGINFO"
|
local comp_files=".PKGINFO"
|
||||||
|
|
||||||
# check for an install script
|
# check for an install script
|
||||||
# TODO: should we include ${pkgname}.install if it exists and $install is unset?
|
|
||||||
if [ "$install" != "" ]; then
|
if [ "$install" != "" ]; then
|
||||||
msg2 "$(gettext "Adding install script...")"
|
msg2 "$(gettext "Adding install script...")"
|
||||||
cp "$startdir/$install" .INSTALL
|
cp "$startdir/$install" .INSTALL
|
||||||
|
@ -1345,6 +1327,25 @@ if [ "$install" -a ! -f "$install" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
valid_options=1
|
||||||
|
for opt in ${options[@]}; do
|
||||||
|
known=0
|
||||||
|
# check if option matches a known option or its inverse
|
||||||
|
for kopt in ${known_options[@]}; do
|
||||||
|
if [ "${opt}" = "${kopt}" -o "${opt}" = "!${kopt}" ]; then
|
||||||
|
known=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $known -eq 0 ]; then
|
||||||
|
error "$(gettext "options array contains unknown option '%s'")" "$opt"
|
||||||
|
valid_options=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $valid_options -eq 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
unset valid_options opt known kopt
|
||||||
|
|
||||||
# We need to run devel_update regardless of whether we are in the fakeroot
|
# We need to run devel_update regardless of whether we are in the fakeroot
|
||||||
# build process so that if the user runs makepkg --forcever manually, we
|
# build process so that if the user runs makepkg --forcever manually, we
|
||||||
# 1) output the correct pkgver, and 2) use the correct filename when
|
# 1) output the correct pkgver, and 2) use the correct filename when
|
||||||
|
|
Loading…
Add table
Reference in a new issue