Last active
February 6, 2026 11:12
-
-
Save dafvid/6995c28492b8b917947025f685760989 to your computer and use it in GitHub Desktop.
FreeBSD bump python pkg versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Usage: sh upgrade_python_packages.sh [FROM] [TO] | |
| # Default: 39 -> 311 | |
| # Example: sh upgrade_python_packages.sh 310 312 | |
| FROM=${1:-39} | |
| TO=${2:-311} | |
| for i in $(pkg query -g %n "py${FROM}-*"); do | |
| base="${i#py${FROM}-}" | |
| to_pkg="py${TO}-${base}" | |
| # Check if the TO version already exists | |
| if pkg info -e "$to_pkg" 2>/dev/null; then | |
| echo "$to_pkg already installed, removing $i" | |
| pkg delete "$i" | |
| else | |
| echo "Upgrading $i to $to_pkg" | |
| pkg set -n "${i}:${to_pkg}" | |
| fi | |
| done | |
| # Upgrade all the changed packages | |
| pkg upgrade $(pkg query -g %n "py${TO}-*") | |
| pkg delete python${FROM} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment