Skip to content

Commit

Permalink
do the checks for constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
ook37 committed Mar 30, 2024
1 parent b47c42f commit 4fc6e45
Showing 1 changed file with 26 additions and 39 deletions.
65 changes: 26 additions & 39 deletions misc/scripts/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,45 +210,32 @@ function lint_maintainer() {
return 0
}

function lint_makedepends() {
local ret=0 makedepend idx=0
if [[ -n ${makedepends[*]} ]]; then
for makedepend in "${makedepends[@]}"; do
if [[ -z ${makedepend} ]]; then
fancy_message error "'makedepends' index '${idx}' cannot be empty"
ret=1
fi
((idx++))
done
fi
return "${ret}"
}

function lint_depends() {
local ret=0 depend idx=0
if [[ -n ${depends[*]} ]]; then
for depend in "${depends[@]}"; do
if [[ -z ${depend} ]]; then
fancy_message error "'depends' index '${idx}' cannot be empty"
ret=1
fi
((idx++))
done
fi
return "${ret}"
function lint_pipe_check() {
perl -ne 'exit 1 unless /^(?:[^\s|:]+(?::[^\s|:]+)?\s\|\s)+[^\s|:]+(?::[^\s|:]+)?(?::\s[^|:]+)?(?<!\s)$/' <<< "$1"
return $?
}

function lint_pacdeps() {
local ret=0 pacdep idx=0
if [[ -n ${pacdeps[*]} ]]; then
for pacdep in "${pacdeps[@]}"; do
if [[ -z ${pacdep} ]]; then
fancy_message error "'pacdeps' index '${idx}' cannot be empty"
ret=1
fi
((idx++))
done
fi
function lint_deps() {
local dep_type dep_array ret=0 dep idx
for dep_type in "depends" "makedepends" "pacdeps"; do
idx=0
local -n dep_array="${dep_type}"
if [[ -n ${dep_array[*]} ]]; then
for dep in "${dep_array[@]}"; do
if [[ -z ${dep} ]]; then
fancy_message error "'${dep_type}' index '${idx}' cannot be empty"
ret=1
elif [[ ${dep} == *"|"* ]] && [[ ${dep_type} == "pacdeps" ]] || ! lint_pipe_check "${dep}"; then
fancy_message error "'${dep_type}' index '${idx}' is not formatted correctly"
ret=1
fi
((idx++))
done
fi
if ((ret == 1)); then
break
fi
done
return "${ret}"
}

Expand Down Expand Up @@ -292,7 +279,7 @@ function lint_optdepends() {
if [[ -z ${optdepend} ]]; then
fancy_message error "'optdepends' index '${idx}' cannot be empty"
ret=1
elif [[ $optdepend != *": "* ]]; then
elif [[ $optdepend != *": "* ]] || [[ ${dep} == *"|"* ]] && ! lint_pipe_check "${dep}"; then
fancy_message error "'optdepends' index '${idx}' is not formatted correctly"
ret=1
fi
Expand Down Expand Up @@ -554,7 +541,7 @@ function lint_priority() {
}

function checks() {
local ret=0 check linting_checks=(lint_pkgname lint_gives lint_pkgrel lint_epoch lint_version lint_source lint_pkgdesc lint_maintainer lint_makedepends lint_depends lint_pacdeps lint_ppa lint_optdepends lint_conflicts lint_breaks lint_replaces lint_hash lint_patch lint_provides lint_incompatible lint_arch lint_mask lint_priority)
local ret=0 check linting_checks=(lint_pkgname lint_gives lint_pkgrel lint_epoch lint_version lint_source lint_pkgdesc lint_maintainer lint_deps lint_ppa lint_optdepends lint_conflicts lint_breaks lint_replaces lint_hash lint_patch lint_provides lint_incompatible lint_arch lint_mask lint_priority)
for check in "${linting_checks[@]}"; do
"${check}" || ret=1
done
Expand Down

0 comments on commit 4fc6e45

Please sign in to comment.