Compare commits

...

3 Commits

2 changed files with 30 additions and 8 deletions

View File

@ -3,10 +3,18 @@
tag_file="$(mktemp)"
trap 'rm "${tag_file}"' EXIT
DEBUG="${DEBUG:-0}"
log() {
if [ "${DEBUG}" -gt 0 ]; then
printf "$@"
fi
}
add_tag() {
for tag in "$@"; do
if ! has_tags "$tag"; then
echo "Adding detected tag: $tag"
log "Adding detected tag: $tag\n"
echo "${tag}" >> "${tag_file}"
fi
done
@ -14,17 +22,17 @@ add_tag() {
has_tags() {
for req in "$@"; do
printf "Checking for tag: $req... "
log "Checking for tag: $req... "
detected=0
while IFS= read -r line; do
if [ "$line" = "$req" ]; then
echo "yes"
log "yes\n"
detected=1
break
fi
done < "$tag_file"
if [ "$detected" -eq 0 ]; then
echo "no"
log "no\n"
return 1
fi
done
@ -32,12 +40,12 @@ has_tags() {
}
has_binary() {
printf "Checking for binary: $1... "
log "Checking for binary: $1... "
if ! command -v "$1" >/dev/null 2>&1; then
echo "no"
log "no\n"
return 1
fi
echo "yes"
log "yes\n"
return 0
}

View File

@ -11,7 +11,21 @@ pacman_install() {
}
yay_install() {
yay -S --noconfirm --needed "$@"
packages=""
for package in "$@"; do
if ! pacman -Q "${package}" >/dev/null 2>&1; then
packages="${packages} ${package}"
fi
done
if [ ! -z "${packages}" ]; then
yay -S --noconfirm --needed ${packages}
fi
for package in "$@"; do
if ! pacman -Q "${package}" >/dev/null 2>&1; then
return 1 # at least one of the packages has not been correctly installed!
fi
done
return 0
}
pacaur_install() {