mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 04:57:59 -05:00
makepkg: use globs in place of regex
We seem to enjoy using bash regex capabilities, but never referencing the result with BASH_REMATCH. Replace almost all regexes with equivalent globs which are faster and functionally equivalent in these cases. This enables the extglob shopt. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
8d0ff3d7dc
commit
0e79802c0a
@ -81,6 +81,8 @@ FORCE_VER=""
|
|||||||
|
|
||||||
PACMAN_OPTS=
|
PACMAN_OPTS=
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
### SUBROUTINES ###
|
### SUBROUTINES ###
|
||||||
|
|
||||||
plain() {
|
plain() {
|
||||||
@ -341,7 +343,7 @@ in_array() {
|
|||||||
source_has_signatures(){
|
source_has_signatures(){
|
||||||
local file
|
local file
|
||||||
for file in "${source[@]}"; do
|
for file in "${source[@]}"; do
|
||||||
if [[ $file =~ \.(sig|asc)$ ]]; then
|
if [[ $file = *.@(sig|asc) ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -420,7 +422,7 @@ download_file() {
|
|||||||
run_pacman() {
|
run_pacman() {
|
||||||
local cmd
|
local cmd
|
||||||
printf -v cmd "%q " "$PACMAN" $PACMAN_OPTS "$@"
|
printf -v cmd "%q " "$PACMAN" $PACMAN_OPTS "$@"
|
||||||
if (( ! ASROOT )) && [[ ! $1 =~ ^-(T|Qq)$ ]]; then
|
if (( ! ASROOT )) && [[ ! $1 = -@(T|Qq) ]]; then
|
||||||
if type -p sudo >/dev/null; then
|
if type -p sudo >/dev/null; then
|
||||||
cmd="sudo $cmd"
|
cmd="sudo $cmd"
|
||||||
else
|
else
|
||||||
@ -709,7 +711,7 @@ check_pgpsigs() {
|
|||||||
|
|
||||||
for file in "${source[@]}"; do
|
for file in "${source[@]}"; do
|
||||||
file="$(get_filename "$file")"
|
file="$(get_filename "$file")"
|
||||||
if [[ ! $file =~ \.(sig|asc)$ ]]; then
|
if [[ ! $file = *.@(sig|asc) ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1449,7 +1451,7 @@ check_sanity() {
|
|||||||
awk -F'=' '/^[[:space:]]*pkgver=/ { $1=""; print $0 }' "$BUILDFILE" |
|
awk -F'=' '/^[[:space:]]*pkgver=/ { $1=""; print $0 }' "$BUILDFILE" |
|
||||||
while read -r i; do
|
while read -r i; do
|
||||||
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
||||||
if [[ $i =~ [[:space:]:-] ]]; then
|
if [[ $i = *[[:space:]:-]* ]]; then
|
||||||
error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
|
error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -1458,7 +1460,7 @@ check_sanity() {
|
|||||||
awk -F'=' '/^[[:space:]]*pkgrel=/ { $1=""; print $0 }' "$BUILDFILE" |
|
awk -F'=' '/^[[:space:]]*pkgrel=/ { $1=""; print $0 }' "$BUILDFILE" |
|
||||||
while read -r i; do
|
while read -r i; do
|
||||||
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
||||||
if [[ $i =~ [[:space:]-] ]]; then
|
if [[ $i = *[[:space:]-]* ]]; then
|
||||||
error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
|
error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -1467,7 +1469,7 @@ check_sanity() {
|
|||||||
awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" |
|
awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" |
|
||||||
while read -r i; do
|
while read -r i; do
|
||||||
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
|
||||||
if [[ ! $i =~ ^[0-9]*$ ]]; then
|
if [[ $i != *([[:digit:]]) ]]; then
|
||||||
error "$(gettext "%s must be an integer.")" "epoch"
|
error "$(gettext "%s must be an integer.")" "epoch"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -1524,7 +1526,7 @@ check_sanity() {
|
|||||||
sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//')
|
sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//')
|
||||||
for i in "${optdepends_list[@]}"; do
|
for i in "${optdepends_list[@]}"; do
|
||||||
local pkg=${i%%:*}
|
local pkg=${i%%:*}
|
||||||
if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]+$ ]]; then
|
if [[ $pkg != +([[:alnum:]><=.+_-]) ]]; then
|
||||||
error "$(gettext "Invalid syntax for %s : '%s'")" "optdepend" "$i"
|
error "$(gettext "Invalid syntax for %s : '%s'")" "optdepend" "$i"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user