index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in | 56 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in | 56 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/depends.sh.in | 56 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in | 56 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in | 28 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in | 19 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 53 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in | 10 | ||||
-rw-r--r-- | scripts/libmakepkg/lint_pkgbuild/provides.sh.in | 29 |
diff --git a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in new file mode 100644 index 00000000..5d15bfb2 --- /dev/null +++ b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in @@ -0,0 +1,56 @@ +#!/bin/bash +# +# checkdepends.sh - Check the 'checkdepends' array conforms to requirements. +# +# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@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_PKGBUILD_CHECKDEPENDS_SH" ]] && return +LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/lint_pkgbuild/pkgname.sh" +source "$LIBRARY/lint_pkgbuild/pkgver.sh" +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/pkgbuild.sh" + + +lint_pkgbuild_functions+=('lint_checkdepends') + + +lint_checkdepends() { + local checkdepends_list checkdepend name ver ret=0 + + get_pkgbuild_all_split_attributes checkdepends checkdepends_list + + # save our shell options and turn on extglob + local shellopts=$(shopt -p) + shopt -s extglob + + for checkdepend in "${checkdepends_list[@]}"; do + name=${checkdepend%%@(<|>|=|>=|<=)*} + ver=${checkdepend#*@(<|>|=|>=|<=)} + lint_one_pkgname checkdepends "$name" || ret=1 + if [[ $ver != $checkdepend ]]; then + check_pkgver "$ver" checkdepends || ret=1 + fi + done + + eval "$shellopts" + + return $ret +} diff --git a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in new file mode 100644 index 00000000..d81e9784 --- /dev/null +++ b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in @@ -0,0 +1,56 @@ +#!/bin/bash +# +# conflicts.sh - Check the 'conflicts' array conforms to requirements. +# +# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@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_PKGBUILD_CONFLICTS_SH" ]] && return +LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/lint_pkgbuild/pkgname.sh" +source "$LIBRARY/lint_pkgbuild/pkgver.sh" +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/pkgbuild.sh" + + +lint_pkgbuild_functions+=('lint_conflicts') + + +lint_conflicts() { + local conflicts_list conflict name ver ret=0 + + get_pkgbuild_all_split_attributes conflicts conflicts_list + + # save our shell options and turn on extglob + local shellopts=$(shopt -p) + shopt -s extglob + + for conflict in "${conflicts_list[@]}"; do + name=${conflict%%@(<|>|=|>=|<=)*} + ver=${conflict#*@(<|>|=|>=|<=)} + lint_one_pkgname conflicts "$name" || ret=1 + if [[ $ver != $conflict ]]; then + check_pkgver "$ver" conflicts || ret=1 + fi + done + + eval "$shellopts" + + return $ret +} diff --git a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in new file mode 100644 index 00000000..f17bc545 --- /dev/null +++ b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in @@ -0,0 +1,56 @@ +#!/bin/bash +# +# depends.sh - Check the 'depends' array conforms to requirements. +# +# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@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_PKGBUILD_DEPENDS_SH" ]] && return +LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/lint_pkgbuild/pkgname.sh" +source "$LIBRARY/lint_pkgbuild/pkgver.sh" +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/pkgbuild.sh" + + +lint_pkgbuild_functions+=('lint_depends') + + +lint_depends() { + local depends_list depend name ver ret=0 + + get_pkgbuild_all_split_attributes depends depends_list + + # save our shell options and turn on extglob + local shellopts=$(shopt -p) + shopt -s extglob + + for depend in "${depends_list[@]}"; do + name=${depend%%@(<|>|=|>=|<=)*} + ver=${depend#*@(<|>|=|>=|<=)} + lint_one_pkgname depends "$name" || ret=1 + if [[ $ver != $depend ]]; then + check_pkgver "$ver" depends || ret=1 + fi + done + + eval "$shellopts" + + return $ret +} diff --git a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in new file mode 100644 index 00000000..1d0762fb --- /dev/null +++ b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in @@ -0,0 +1,56 @@ +#!/bin/bash +# +# makedepends.sh - Check the 'makedepends' array conforms to requirements. +# +# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@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_PKGBUILD_MAKEDEPENDS_SH" ]] && return +LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/lint_pkgbuild/pkgname.sh" +source "$LIBRARY/lint_pkgbuild/pkgver.sh" +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/pkgbuild.sh" + + +lint_pkgbuild_functions+=('lint_makedepends') + + +lint_makedepends() { + local makedepends_list makedepend name ver ret=0 + + get_pkgbuild_all_split_attributes makedepends makedepends_list + + # save our shell options and turn on extglob + local shellopts=$(shopt -p) + shopt -s extglob + + for makedepend in "${makedepends_list[@]}"; do + name=${makedepend%%@(<|>|=|>=|<=)*} + ver=${makedepend#*@(<|>|=|>=|<=)} + lint_one_pkgname makedepends "$name" || ret=1 + if [[ $ver != $makedepend ]]; then + check_pkgver "$ver" makedepends || ret=1 + fi + done + + eval "$shellopts" + + return $ret +} diff --git a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in index 7758334c..87e561cb 100644 --- a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in @@ -33,31 +33,13 @@ lint_pkgbuild_functions+=('lint_optdepends') lint_optdepends() { local a list name optdepends_list ret=0 - optdepends_list=("${optdepends[@]}") - for a in "${arch[@]}"; do - array_build list "optdepends_$a" - optdepends_list+=("${list[@]}") - done - - for name in "${pkgname[@]}"; do - if extract_function_variable "package_$name" optdepends 1 list; then - optdepends_list+=("${list[@]}") - fi + local optdepends_list optdepend name ret=0 - for a in "${arch[@]}"; do - if extract_function_variable "package_$name" "optdepends_$a" 1 list; then - optdepends_list+=("${list[@]}") - fi - done - done + get_pkgbuild_all_split_attributes optdepends optdepends_list - for name in "${optdepends_list[@]}"; do - local pkg=${name%%:[[:space:]]*} - # the '-' character _must_ be first or last in the character range - if [[ $pkg != +([-[:alnum:]><=.+_:]) ]]; then - error "$(gettext "Invalid syntax for %s: '%s'")" "optdepend" "$name" - ret=1 - fi + for optdepend in "${optdepends_list[@]}"; do + name=${optdepend%%:[[:space:]]*} + lint_one_pkgname optdepends "$name" || ret=1 done return $ret diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in index b2f7af04..b012b226 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in @@ -23,6 +23,7 @@ LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} +source "$LIBRARY/lint_pkgbuild/pkgname.sh" source "$LIBRARY/util/message.sh" @@ -30,21 +31,9 @@ lint_pkgbuild_functions+=('lint_pkgbase') lint_pkgbase() { - local ret=0 - - if [[ ${pkgbase:0:1} = "-" ]]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" - return 1 - fi - if [[ ${pkgbase:0:1} = "." ]]; then - error "$(gettext "%s is not allowed to start with a dot.")" "pkgbase" - ret=1 - fi - if [[ $pkgbase = *[^[:alnum:]+_.@-]* ]]; then - error "$(gettext "%s contains invalid characters: '%s'")" \ - 'pkgbase' "${i//[[:alnum:]+_.@-]}" - ret=1 + if [[ -z $pkgbase ]]; then + return 0 fi - return $ret + lint_one_pkgname "pkgbase" "$pkgbase" } diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index 4024253e..d51c6313 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -29,34 +29,43 @@ source "$LIBRARY/util/message.sh" lint_pkgbuild_functions+=('lint_pkgname') +lint_one_pkgname() { + local type=$1 name=$2 ret=0 + + + if [[ -z $name ]]; then + error "$(gettext "%s is not allowed to be empty.")" "$type" + ret=1 + continue + fi + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "$type" + ret=1 + fi + if [[ ${name:0:1} = "." ]]; then + error "$(gettext "%s is not allowed to start with a dot.")" "$type" + ret=1 + fi + if [[ $name = *[^[:alnum:]+_.@-]* ]]; then + error "$(gettext "%s contains invalid characters: '%s'")" \ + "$type" "${name//[[:alnum:]+_.@-]}" + ret=1 + fi + + return $ret +} + lint_pkgname() { local ret=0 i if [[ -z ${pkgname[@]} ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" - return 1 + ret=1 + else + for i in "${pkgname[@]}"; do + lint_one_pkgname "pkgname" "$i" || ret=1 + done fi - for i in "${pkgname[@]}"; do - if [[ -z $i ]]; then - error "$(gettext "%s is not allowed to be empty.")" "pkgname" - ret=1 - continue - fi - if [[ ${i:0:1} = "-" ]]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" - ret=1 - fi - if [[ ${i:0:1} = "." ]]; then - error "$(gettext "%s is not allowed to start with a dot.")" "pkgname" - ret=1 - fi - if [[ $i = *[^[:alnum:]+_.@-]* ]]; then - error "$(gettext "%s contains invalid characters: '%s'")" \ - 'pkgname' "${i//[[:alnum:]+_.@-]}" - ret=1 - fi - done - return $ret } diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in index b9e2e439..c105212b 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in @@ -30,13 +30,15 @@ lint_pkgbuild_functions+=('lint_pkgver') check_pkgver() { - if [[ -z $1 ]]; then - error "$(gettext "%s is not allowed to be empty.")" "pkgver" + local ver=$1 type=$2 + + if [[ -z $ver ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgver${type:+ in $type}" return 1 fi - if [[ $1 = *[[:space:]/:-]* ]]; then - error "$(gettext "%s is not allowed to contain colons, forward slashes, hyphens or whitespace.")" "pkgver" + if [[ $ver = *[[:space:]/:-]* ]]; then + error "$(gettext "%s is not allowed to contain colons, forward slashes, hyphens or whitespace.")" "pkgver${type:+ in $type}" return 1 fi } diff --git a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in index c2407dc0..7500a88a 100644 --- a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in @@ -23,6 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} +source "$LIBRARY/lint_pkgbuild/pkgname.sh" +source "$LIBRARY/lint_pkgbuild/pkgver.sh" source "$LIBRARY/util/message.sh" source "$LIBRARY/util/pkgbuild.sh" @@ -31,30 +33,21 @@ lint_pkgbuild_functions+=('lint_provides') lint_provides() { - local a list name provides_list ret=0 + local provides_list provide name ver ret=0 - provides_list=("${provides[@]}") - for a in "${arch[@]}"; do - array_build list "provides_$a" - provides_list+=("${list[@]}") - done - - for name in "${pkgname[@]}"; do - if extract_function_variable "package_$name" provides 1 list; then - provides_list+=("${list[@]}") - fi - - for a in "${arch[@]}"; do - if extract_function_variable "package_$name" "provides_$a" 1 list; then - provides_list+=("${list[@]}") - fi - done - done + get_pkgbuild_all_split_attributes provides provides_list for provide in "${provides_list[@]}"; do if [[ $provide == *['<>']* ]]; then error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides" ret=1 + continue + fi + name=${provide%%=*} + ver=${provide#*=} + lint_one_pkgname provides "$name" || ret=1 + if [[ $ver != $provide ]]; then + check_pkgver "$ver" provides || ret=1 fi done |