1#!/bin/bash 2# 3# provides.sh - Check the 'provides' array conforms to requirements. 4# 5# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org> 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <http://www.gnu.org/licenses/>. 19# 20 21[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH" ]] && return 22LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1 23 24LIBRARY=${LIBRARY:-'@libmakepkgdir@'} 25 26source "$LIBRARY/lint_pkgbuild/pkgname.sh" 27source "$LIBRARY/lint_pkgbuild/pkgver.sh" 28source "$LIBRARY/util/message.sh" 29source "$LIBRARY/util/pkgbuild.sh" 30 31 32lint_pkgbuild_functions+=('lint_provides') 33 34 35lint_provides() { 36 local provides_list provide name ver ret=0 37 38 get_pkgbuild_all_split_attributes provides provides_list 39 40 # this function requires extglob - save current status to restore later 41 local shellopts=$(shopt -p extglob) 42 shopt -s extglob 43 44 for provide in "${provides_list[@]}"; do 45 if [[ $provide == *['<>']* ]]; then 46 error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides" 47 ret=1 48 continue 49 fi 50 name=${provide%=*} 51 # remove optional epoch in version specifier 52 ver=${provide##$name=?(+([0-9]):)} 53 lint_one_pkgname provides "$name" || ret=1 54 if [[ $ver != $provide ]]; then 55 # remove optional pkgrel in version specifier 56 check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1 57 fi 58 done 59 60 eval "$shellopts" 61 62 return $ret 63} 64