Check for existence of packer-io command before setting PACKER_BIN

In older versions of arch linux, the hashicorp packer package (and
binary) was named packer-io to avoid clashing with a pre-existing AUR
helper called packer. Recently, the AUR helper package was renamed to
packer-aur and the old packer-io (and corresponding binary) was
renamed to packer.

https://www.archlinux.org/packages/community/x86_64/packer/

Previously, the wrapacker script would unconditionally set PACKER_BIN
to "packer-io" if the file /etc/arch-release existed. We now instead
the check for the existence of a packer-io command, and fall back to
the default "packer" in case that doesn't exist.
This commit is contained in:
Mike Appleby 2018-10-30 16:43:35 -06:00
parent 1e25ccf7c6
commit e54e34cda1

View file

@ -17,8 +17,8 @@
# country codes supported by https://www.archlinux.org/mirrorlist/
readonly VALID_COUNTRIES=(AT AU BD BE BG BR BY CA CH CL CN CO CZ DE DK EC ES FR GB GR HR HU ID IE IL IN IR IS IT JP KR KZ LT LU LV MK NC NL NO NZ PH PL PT RO RS RU SE SG SK TR TW UA US VN ZA)
# use the correct binary if running from arch linux
if [[ -f /etc/arch-release ]]; then
if command -v packer-io > /dev/null 2>&1; then
# Older arch linux versions called the packer binary packer-io.
readonly PACKER_BIN='packer-io'
else
readonly PACKER_BIN='packer'