@@ -19,6 +19,8 @@ INSTALL_SENTINEL=${INSTALLSENTINEL:-false}
1919INSTALL_TFSEC=${INSTALLTFSEC:- false}
2020INSTALL_TERRAFORM_DOCS=${INSTALLTERRAFORMDOCS:- false}
2121CUSTOM_DOWNLOAD_SERVER=" ${CUSTOMDOWNLOADSERVER:- " " } "
22+ # This is because ubuntu noble and debian trixie don't support the old format of GPG keys and validation
23+ NEW_GPG_CODENAMES=" trixie noble"
2224
2325TERRAFORM_SHA256=" ${TERRAFORM_SHA256:- " automatic" } "
2426TFLINT_SHA256=" ${TFLINT_SHA256:- " automatic" } "
@@ -50,13 +52,11 @@ if [ "$(id -u)" -ne 0 ]; then
5052 exit 1
5153fi
5254
53- # Detect Ubuntu Noble and use new repo setup, else use legacy GPG logic
54- IS_NOBLE=0
55- if grep -qi ' ubuntu' /etc/os-release; then
56- . /etc/os-release
57- if [[ " $VERSION_CODENAME " == " noble" ]]; then
58- IS_NOBLE=1
59- fi
55+ # Detect Ubuntu Noble or Debian Trixie and use new repo setup, else use legacy GPG logic
56+ IS_GPG_NEW=0
57+ . /etc/os-release
58+ if [[ " ${NEW_GPG_CODENAMES} " == * " ${VERSION_CODENAME} " * ]]; then
59+ IS_GPG_NEW=1
6060fi
6161
6262# Get the list of GPG key servers that are reachable
@@ -112,7 +112,7 @@ receive_gpg_keys() {
112112 chmod 700 ${GNUPGHOME}
113113
114114 # Special handling for HashiCorp GPG key on Ubuntu Noble
115- if [ " $IS_NOBLE " -eq 1 ] && [ " $keys " = " $TERRAFORM_GPG_KEY " ]; then
115+ if [ " $IS_GPG_NEW " -eq 1 ] && [ " $keys " = " $TERRAFORM_GPG_KEY " ]; then
116116 echo " (*) Ubuntu Noble detected, using Keybase for HashiCorp GPG key import...."
117117 curl -fsSL https://keybase.io/hashicorp/pgp_keys.asc | gpg --import
118118 if ! gpg --list-keys " ${TERRAFORM_GPG_KEY} " > /dev/null 2>&1 ; then
@@ -400,7 +400,7 @@ verify_signature() {
400400
401401 receive_gpg_keys " $gpg_key "
402402 verify_result=$?
403- if [ $verify_result -ne 0 ] && [ " $IS_NOBLE " -eq 1 ]; then
403+ if [ $verify_result -ne 0 ] && [ " $IS_GPG_NEW " -eq 1 ]; then
404404 echo " Skipping the gpg key validation for ubuntu noble as unable to import the key."
405405 return 1
406406 fi
429429if [ " ${TERRAFORM_SHA256} " != " dev-mode" ]; then
430430 if [ " ${TERRAFORM_SHA256} " = " automatic" ]; then
431431 # For Ubuntu Noble, try GPG verification but continue if it fails
432- if [ " $IS_NOBLE " -eq 1 ]; then
432+ if [ " $IS_GPG_NEW " -eq 1 ]; then
433433 echo " (*) Ubuntu Noble detected - attempting GPG verification with fallback..."
434434 set +e
435435 sha256sums_url=" ${HASHICORP_RELEASES_URL} /terraform/${TERRAFORM_VERSION} /terraform_${TERRAFORM_VERSION} _SHA256SUMS"
@@ -543,7 +543,7 @@ if [ "${INSTALL_SENTINEL}" = "true" ]; then
543543 if [ " ${SENTINEL_SHA256} " != " dev-mode" ]; then
544544 if [ " ${SENTINEL_SHA256} " = " automatic" ]; then
545545 # For Ubuntu Noble, try GPG verification but continue if it fails
546- if [ " $IS_NOBLE " -eq 1 ]; then
546+ if [ " $IS_GPG_NEW " -eq 1 ]; then
547547 echo " (*) Ubuntu Noble detected - attempting Sentinel GPG verification with fallback..."
548548 set +e
549549 sha256sums_url=" ${sentinel_releases_url} /${SENTINEL_VERSION} /sentinel_${SENTINEL_VERSION} _SHA256SUMS"
0 commit comments