@@ -85,15 +85,16 @@ if type apt-get > /dev/null 2>&1; then
8585elif type microdnf > /dev/null 2>&1 ; then
8686 PKG_MGR_CMD=microdnf
8787 INSTALL_CMD=" ${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0"
88- TIME_PIECE_PKG=" perl-Time-Piece"
8988elif type dnf > /dev/null 2>&1 ; then
9089 PKG_MGR_CMD=dnf
9190 INSTALL_CMD=" ${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0"
92- TIME_PIECE_PKG=" perl-Time-Piece"
9391else
9492 PKG_MGR_CMD=yum
9593 INSTALL_CMD=" ${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --noplugins --setopt=install_weak_deps=0"
96- TIME_PIECE_PKG=" perl-Time-Piece"
94+ fi
95+ # Set TIME_PIECE_PKG for RHEL-based systems (all except apt-get)
96+ if [ " ${PKG_MGR_CMD} " != " apt-get" ]; then
97+ TIME_PIECE_PKG=" perl-Time-Piece"
9798fi
9899# Install Time::Piece Perl module required by OpenSSL 3.0.18+ build system
99100install_time_piece () {
@@ -620,27 +621,43 @@ ensure_cosign() {
620621 return 0
621622}
622623
623- # Updated signature verification logic
624+ # Updated signature verification logic with proper version-specific handling
624625verify_python_signature () {
625626 local VERSION=" $1 "
626627 local major_version=$( echo " $VERSION " | cut -d. -f1)
627628 local minor_version=$( echo " $VERSION " | cut -d. -f2)
628629
629- # Use cosign for Python 3.14+ (when available)
630+ # Version-specific signature verification
630631 if [ " $major_version " -eq 3 ] && [ " $minor_version " -ge 14 ]; then
631632 echo " (*) Python 3.14+ detected. Attempting cosign verification..."
632633
633- # Try to install and use cosign
634+ # Try to install and use cosign for 3.14+
634635 if ensure_cosign; then
635636 echo " Using cosign to verify Python ${VERSION} signature..."
636- # Note: This is placeholder - actual cosign verification would need
637- # the proper sigstore bundle or signature files from python.org
638- echo " (*) Cosign verification not yet implemented for Python releases"
639- echo " (*) Falling back to GPG verification"
637+
638+ # Attempt actual COSIGN verification
639+ if perform_cosign_verification " ${VERSION} " ; then
640+ echo " (*) COSIGN verification successful - skipping GPG"
641+ return 0
642+ else
643+ echo " (*) COSIGN verification failed, falling back to GPG"
644+ perform_gpg_verification " ${VERSION} "
645+ fi
646+ else
647+ echo " (!) Failed to install cosign for Python 3.14+, falling back to GPG"
648+ perform_gpg_verification " ${VERSION} "
640649 fi
650+ else
651+ # Direct GPG verification for Python < 3.14
652+ echo " (*) Python < 3.14 detected. Using GPG signature verification..."
653+ perform_gpg_verification " ${VERSION} "
641654 fi
655+ }
656+
657+ # Extracted GPG verification logic to avoid duplication
658+ perform_gpg_verification () {
659+ local VERSION=" $1 "
642660
643- # Fall back to GPG verification
644661 echo " (*) Using GPG signature verification..."
645662 if [[ ${VERSION_CODENAME} = " centos7" ]] || [[ ${VERSION_CODENAME} = " rhel7" ]]; then
646663 receive_gpg_keys_centos7 PYTHON_SOURCE_GPG_KEYS
@@ -667,6 +684,43 @@ verify_python_signature() {
667684 return 0
668685}
669686
687+ # COSIGN signature verification logic
688+ perform_cosign_verification () {
689+ local VERSION=" $1 "
690+
691+ echo " (*) Attempting COSIGN verification for Python ${VERSION} ..."
692+
693+ # Check if COSIGN signature files exist (these don't exist yet for Python releases)
694+ local cosign_sig_url=" ${cpython_tgz_url} .sig"
695+ local cosign_cert_url=" ${cpython_tgz_url} .pem"
696+
697+ # Download COSIGN signature and certificate files
698+ if ! curl -sSL -o " /tmp/python-src/${cpython_tgz_filename} .sig" " ${cosign_sig_url} " ; then
699+ echo " (!) COSIGN signature file not available for Python ${VERSION} "
700+ return 1
701+ fi
702+
703+ if ! curl -sSL -o " /tmp/python-src/${cpython_tgz_filename} .pem" " ${cosign_cert_url} " ; then
704+ echo " (!) COSIGN certificate file not available for Python ${VERSION} "
705+ return 1
706+ fi
707+
708+ # Perform COSIGN verification
709+ if cosign verify-blob \
710+ --certificate " /tmp/python-src/${cpython_tgz_filename} .pem" \
711+ --signature " /tmp/python-src/${cpython_tgz_filename} .sig" \
712+ --certificate-identity-regexp=" .*" \
713+ --certificate-oidc-issuer-regexp=" .*" \
714+ " /tmp/python-src/${cpython_tgz_filename} " ; then
715+ echo " (*) COSIGN signature verification successful"
716+ return 0
717+ else
718+ echo " (!) COSIGN signature verification failed"
719+ return 1
720+ fi
721+ }
722+
723+
670724install_from_source () {
671725 VERSION=$1
672726 echo " (*) Building Python ${VERSION} from source..."
0 commit comments