sanity check for optdepends syntax

only allow optdepends like:
pkgname: description

some (real) examples of invalid optdepends:
 'tcl, python and/or ruby: to use corresponding binding'
 'xorg-fonts-75dpi : X bitmap fonts needed for the interface'
 'ruby-htmlentities (AUR): for one provider named Deastore'
 'xpdf - for pdf'

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
[Allan: rebase off de39a1f6 and adjust man page]
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Xavier Chantry 2009-08-30 22:05:46 +02:00 committed by Dan McGee
parent 5dbd00faf7
commit 0845b2f13c
2 changed files with 9 additions and 1 deletions

View file

@ -144,7 +144,7 @@ name. The syntax is: `source=('filename::url')`.
base functionality, but may be necessary to make full use of the contents
of this package. optdepends are currently for informational purposes only
and are not utilized by pacman during dependency resolution. The format
should be similar to the following:
for specifying optdepends is:
optdepends=('fakeroot: for makepkg usage as normal user')

View file

@ -1180,6 +1180,14 @@ check_sanity() {
fi
done
local optdepend
for optdepend in "${optdepends[@]}"; do
pkg=${optdepend%%:*}
if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then
error "$(gettext "Invalid syntax for optdepend : '%s'")" "$optdepend"
fi
done
if [ "$install" -a ! -f "$install" ]; then
error "$(gettext "Install scriptlet (%s) does not exist.")" "$install"
return 1