summaryrefslogtreecommitdiffstats
path: root/scripts/libmakepkg/lint_pkgbuild
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/libmakepkg/lint_pkgbuild')
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/arch.sh.in64
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/backup.sh.in51
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/changelog.sh.in45
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/epoch.sh.in37
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/install.sh.in44
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in64
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/options.sh.in57
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/package_function.sh.in51
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in37
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in44
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in57
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in42
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in55
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/provides.sh.in62
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/source.sh.in39
-rw-r--r--scripts/libmakepkg/lint_pkgbuild/util.sh.in41
16 files changed, 790 insertions, 0 deletions
diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
new file mode 100644
index 00000000..547d5fc3
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# arch.sh - Check the 'arch' array conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_ARCH_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_ARCH_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+lint_pkgbuild_functions+=('lint_arch')
+
+
+lint_arch() {
+ local a name list
+
+ if [[ $arch == 'any' ]]; then
+ return 0
+ fi
+
+ for a in "${arch[@]}"; do
+ if [[ $a = *[![:alnum:]_]* ]]; then
+ error "$(gettext "%s contains invalid characters: '%s'")" \
+ 'arch' "${a//[[:alnum:]_]}"
+ ret=1
+ fi
+ done
+
+ if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then
+ error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
+ plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
+ plain "$(gettext "such as %s.")" "arch=('$CARCH')"
+ return 1
+ fi
+
+ for name in "${pkgname[@]}"; do
+ get_pkgbuild_attribute "$name" 'arch' 1 list
+ if [[ $list && $list != 'any' ]] && ! in_array $CARCH "${list[@]}"; then
+ if (( ! IGNOREARCH )); then
+ error "$(gettext "%s is not available for the '%s' architecture.")" "$name" "$CARCH"
+ ret=1
+ fi
+ fi
+ done
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/backup.sh.in b/scripts/libmakepkg/lint_pkgbuild/backup.sh.in
new file mode 100644
index 00000000..c128d338
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/backup.sh.in
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# backup.sh - Check the 'backup' array conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_BACKUP_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_BACKUP_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+lint_pkgbuild_functions+=('lint_backup')
+
+
+lint_backup() {
+ local list name backup_list ret=0
+
+ backup_list=("${backup[@]}")
+ for name in "${pkgname[@]}"; do
+ if extract_function_variable "package_$name" backup 1 list; then
+ backup_list+=("${list[@]}")
+ fi
+ done
+
+ for name in "${backup_list[@]}"; do
+ if [[ ${name:0:1} = "/" ]]; then
+ error "$(gettext "%s entry should not contain leading slash : %s")" "backup" "$name"
+ ret=1
+ fi
+ done
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in b/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in
new file mode 100644
index 00000000..2dac5dbf
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/changelog.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# changelog.sh - Check the files in the 'changelog' array exist.
+#
+# Copyright (c) 2014-2015 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_CHANGELOG_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_CHANGELOG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+source "$LIBRARY/lint_pkgbuild/util.sh"
+
+
+lint_pkgbuild_functions+=('lint_changelog')
+
+
+lint_changelog() {
+ local list name file changelog_list ret=0
+
+ changelog_list=("${changelog[@]}")
+ for name in "${pkgname[@]}"; do
+ if extract_function_variable "package_$name" changelog 0 file; then
+ changelog_list+=("$file")
+ fi
+ done
+
+ check_files_exist 'changelog' "${changelog_list[@]}"
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
new file mode 100644
index 00000000..93b51b84
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# epoch.sh - Check the 'epoch' variable conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_EPOCH_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_EPOCH_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_epoch')
+
+
+lint_epoch() {
+ if [[ $epoch != *([[:digit:]]) ]]; then
+ error "$(gettext "%s must be an integer, not %s.")" "epoch" "$epoch"
+ return 1
+ fi
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/install.sh.in b/scripts/libmakepkg/lint_pkgbuild/install.sh.in
new file mode 100644
index 00000000..21e0bfb7
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/install.sh.in
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# install.sh - Check the files in the 'install' array exist.
+#
+# Copyright (c) 2014-2015 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_INSTALL_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_INSTALL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+source "$LIBRARY/lint_pkgbuild/util.sh"
+
+
+lint_pkgbuild_functions+=('lint_install')
+
+
+lint_install() {
+ local list file name install_list ret=0
+
+ install_list=("${install[@]}")
+ for name in "${pkgname[@]}"; do
+ extract_function_variable "package_$name" install 0 file
+ install_list+=("$file")
+ done
+
+ check_files_exist 'install' "${install_list[@]}"
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
new file mode 100644
index 00000000..6e66e0d2
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# optdepends.sh - Check the 'optdepends' array conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_OPTDEPENDS_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+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
+
+ for a in "${arch[@]}"; do
+ if extract_function_variable "package_$name" "optdepends_$a" 1 list; then
+ optdepends_list+=("${list[@]}")
+ fi
+ done
+ done
+
+ 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
+ done
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/options.sh.in b/scripts/libmakepkg/lint_pkgbuild/options.sh.in
new file mode 100644
index 00000000..4423d26e
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/options.sh.in
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# options.sh - Check the 'options' array conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_OPTIONS_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_OPTIONS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+lint_pkgbuild_functions+=('lint_options')
+
+
+lint_options() {
+ local ret=0 list name kopt options_list
+
+ options_list=("${options[@]}")
+ for name in "${pkgname[@]}"; do
+ if extract_function_variable "package_$name" options 1 list; then
+ options_list+=("${list[@]}")
+ fi
+ done
+
+ for i in "${options_list[@]}"; do
+ # check if option matches a known option or its inverse
+ for kopt in "${packaging_options[@]}" "${build_options[@]}"; do
+ if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
+ # continue to the next $i
+ continue 2
+ fi
+ done
+
+ error "$(gettext "%s array contains unknown option '%s'")" "options" "$i"
+ ret=1
+ done
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
new file mode 100644
index 00000000..c2ed8370
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# package_function.sh - Check that required package functions exist.
+#
+# Copyright (c) 2014-2015 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_PACKAGE_FUNCTION_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+lint_pkgbuild_functions+=('lint_package_function')
+
+
+lint_package_function() {
+ local i ret=0
+
+ if (( ${#pkgname[@]} == 1 )); then
+ if have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
+ error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
+ ret=1
+ fi
+ else
+ for i in "${pkgname[@]}"; do
+ if ! have_function "package_$i"; then
+ error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
+ ret=1
+ fi
+ done
+ fi
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in
new file mode 100644
index 00000000..abb40e0c
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgbase.sh.in
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# pkgbase.sh - Check the 'pkgbase' variable conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_PKGBASE_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_pkgbase')
+
+
+lint_pkgbase() {
+ if [[ ${pkgbase:0:1} = "-" ]]; then
+ error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname"
+ return 1
+ fi
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in
new file mode 100644
index 00000000..26a8ac04
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/pkglist.sh.in
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# pkglist.sh - Check the packages selected to build exist.
+#
+# Copyright (c) 2014-2015 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_PKGLIST_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/util.sh"
+
+
+lint_pkgbuild_functions+=('lint_pkglist')
+
+
+lint_pkglist() {
+ local i ret=0
+
+ for i in "${PKGLIST[@]}"; do
+ if ! in_array "$i" "${pkgname[@]}"; then
+ error "$(gettext "Requested package %s is not provided in %s")" "$i" "$BUILDFILE"
+ ret=1
+ fi
+ done
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in
new file mode 100644
index 00000000..e5e2f269
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# pkgname.sh - Check the 'pkgname' variable conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_PKGNAME_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_pkgname')
+
+
+lint_pkgname() {
+ local ret=0 i
+
+ 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/pkgrel.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
new file mode 100644
index 00000000..371e6a1f
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# pkgrel.sh - Check the 'pkgrel' variable conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_PKGREL_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PKGREL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_pkgrel')
+
+
+lint_pkgrel() {
+ if [[ -z $pkgrel ]]; then
+ error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
+ return 1
+ fi
+
+ if [[ $pkgrel != +([0-9])?(.+([0-9])) ]]; then
+ error "$(gettext "%s must be a decimal, not %s.")" "pkgrel" "$pkgrel"
+ return 1
+ fi
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
new file mode 100644
index 00000000..d23f7043
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# pkgver.sh - Check the 'pkgver' variable conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_PKGVER_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_pkgver')
+
+
+validate_pkgver() {
+ if [[ $1 = *[[:space:]:-]* ]]; then
+ error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
+ return 1
+ fi
+}
+
+check_pkgver() {
+ if [[ -z ${pkgver} ]]; then
+ error "$(gettext "%s is not allowed to be empty.")" "pkgver"
+ return 1
+ fi
+
+ validate_pkgver "$pkgver"
+}
+
+lint_pkgver() {
+ if (( PKGVERFUNC )); then
+ # defer check to after getting version from pkgver function
+ return 0
+ fi
+
+ check_pkgver
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
new file mode 100644
index 00000000..668cf56c
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# provides.sh - Check the 'provides' array conforms to requirements.
+#
+# Copyright (c) 2014-2015 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_PROVIDES_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+
+lint_pkgbuild_functions+=('lint_provides')
+
+
+lint_provides() {
+ local a list name provides_list 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
+
+ for provide in "${provides_list[@]}"; do
+ if [[ $provide == *['<>']* ]]; then
+ error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides"
+ ret=1
+ fi
+ done
+
+ return $ret
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/source.sh.in b/scripts/libmakepkg/lint_pkgbuild/source.sh.in
new file mode 100644
index 00000000..c3272993
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/source.sh.in
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# source.sh - Check the 'source' array is not sparse.
+#
+# Copyright (c) 2014-2015 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_SOURCE_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_SOURCE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+lint_pkgbuild_functions+=('lint_source')
+
+
+lint_source() {
+ local idx=("${!source[@]}")
+
+ if (( ${#source[*]} > 0 && (idx[-1] + 1) != ${#source[*]} )); then
+ error "$(gettext "Sparse arrays are not allowed for source")"
+ return 1
+ fi
+}
diff --git a/scripts/libmakepkg/lint_pkgbuild/util.sh.in b/scripts/libmakepkg/lint_pkgbuild/util.sh.in
new file mode 100644
index 00000000..448abc8a
--- /dev/null
+++ b/scripts/libmakepkg/lint_pkgbuild/util.sh.in
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# util.sh - utility functions for pkgbuild linting.
+#
+# Copyright (c) 2014-2015 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_UTIL_SH" ]] && return
+LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+check_files_exist() {
+ local kind=$1 files=("${@:2}") file ret
+
+ for file in "${files[@]}"; do
+ if [[ $file && ! -f $file ]]; then
+ error "$(gettext "%s file (%s) does not exist or is not a regular file.")" \
+ "$kind" "$file"
+ ret=1
+ fi
+ done
+
+ return $ret
+}