-
-
Save lazka/87606c36f40c6d69ccf40c50c903c963 to your computer and use it in GitHub Desktop.
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/bash | |
| # Migrate installed MSYS2 MINGW64 packages to their UCRT64 equivalents. | |
| set -e | |
| from=mingw-w64-x86_64- | |
| to=mingw-w64-ucrt-x86_64- | |
| confirm() { read -rp "$1 [y/N] " a; [[ $a == [yY] ]]; } | |
| confirm "This will replace all installed ${from}* packages with their ${to}* equivalents. Continue?" || exit | |
| echo "Gathering package information..." | |
| declare -A avail installed explicit | |
| for p in $(pacman -Slq); do avail[$p]=1; done | |
| for p in $(pacman -Qq); do installed[$p]=1; done | |
| for p in $(pacman -Qqe); do explicit[$p]=1; done | |
| new=() asdeps=() migrated=() missing=() | |
| for pkg in $(pacman -Qq | grep "^$from"); do | |
| target=$to${pkg#"$from"} | |
| if [[ ${installed[$target]} ]]; then | |
| migrated+=("$pkg") | |
| elif [[ ${avail[$target]} ]]; then | |
| new+=("$target") | |
| if [[ ! ${explicit[$pkg]} ]]; then | |
| asdeps+=("$target") | |
| fi | |
| migrated+=("$pkg") | |
| else | |
| echo "WARNING: $target not found; $pkg will not be migrated" >&2 | |
| missing+=("$pkg") | |
| fi | |
| done | |
| if confirm "Install ${#new[@]} packages ($to)?" && { (( ${#new[@]} == 0 )) || pacman -S --noconfirm "${new[@]}"; }; then | |
| if (( ${#asdeps[@]} )); then | |
| pacman -D --asdeps "${asdeps[@]}" | |
| fi | |
| remove=("${migrated[@]}" "${missing[@]}") | |
| if (( ${#remove[@]} )) && confirm "Remove all ${#remove[@]} old packages ($from), including ${#missing[@]} packages with no ${to}* replacement?"; then | |
| pacman -Rn --noconfirm "${remove[@]}" | |
| fi | |
| fi |
Author
@lazka This script mostly worked for me. I think the "Also remove ${#missing[@]} old packages without a ${to}* replacement? and "Remove ${#migrated[@]} migrated old packages ($from)?" logic needs to be swapped? Otherwise I get errors of the type:
Remove 576 migrated old packages (mingw-w64-x86_64-)? [y/N] y
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing mingw-w64-x86_64-gcc-libs breaks dependency 'mingw-w64-x86_64-cc-libs' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-glib2 breaks dependency 'mingw-w64-x86_64-glib2' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-glib-networking breaks dependency 'mingw-w64-x86_64-glib-networking' required by mingw-w64-x86_64-libsoup :: removing mingw-w64-x86_64-libxml2 breaks dependency 'mingw-w64-x86_64-libxml2' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-libpsl breaks dependency 'mingw-w64-x86_64-libpsl' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-brotli breaks dependency 'mingw-w64-x86_64-brotli' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-sqlite3 breaks dependency 'mingw-w64-x86_64-sqlite3' required by mingw-w64-x86_64-libsoup
:: removing mingw-w64-x86_64-python breaks dependency 'mingw-w64-x86_64-python' required by mingw-w64-x86_64-python-pathlib2
:: removing mingw-w64-x86_64-python-scandir breaks dependency 'mingw-w64-x86_64-python-scandir' required by mingw-w64-x86_64-python-pathlib2
:: removing mingw-w64-x86_64-python breaks dependency 'mingw-w64-x86_64-python' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-python-cerberus breaks dependency 'mingw-w64-x86_64-python-cerberus' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-python-license-expression breaks dependency 'mingw-w64-x86_64-python-license-expression' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-python-packaging breaks dependency 'mingw-w64-x86_64-python-packaging' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-python-tomli breaks dependency 'mingw-w64-x86_64-python-tomli' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-python-tomli-w breaks dependency 'mingw-w64-x86_64-python-tomli-w' required by mingw-w64-x86_64-python-pdm-pep517
:: removing mingw-w64-x86_64-qt5-3d breaks dependency 'mingw-w64-x86_64-qt5-3d' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-activeqt breaks dependency 'mingw-w64-x86_64-qt5-activeqt' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-base breaks dependency 'mingw-w64-x86_64-qt5-base' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-charts breaks dependency 'mingw-w64-x86_64-qt5-charts' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-connectivity breaks dependency 'mingw-w64-x86_64-qt5-connectivity' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-datavis3d breaks dependency 'mingw-w64-x86_64-qt5-datavis3d' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-declarative breaks dependency 'mingw-w64-x86_64-qt5-declarative' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-gamepad breaks dependency 'mingw-w64-x86_64-qt5-gamepad' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-graphicaleffects breaks dependency 'mingw-w64-x86_64-qt5-graphicaleffects' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-imageformats breaks dependency 'mingw-w64-x86_64-qt5-imageformats' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-location breaks dependency 'mingw-w64-x86_64-qt5-location' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-lottie breaks dependency 'mingw-w64-x86_64-qt5-lottie' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-multimedia breaks dependency 'mingw-w64-x86_64-qt5-multimedia' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-networkauth breaks dependency 'mingw-w64-x86_64-qt5-networkauth' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-purchasing breaks dependency 'mingw-w64-x86_64-qt5-purchasing' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-quick3d breaks dependency 'mingw-w64-x86_64-qt5-quick3d' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-quickcontrols breaks dependency 'mingw-w64-x86_64-qt5-quickcontrols' required by mingw-w64-x86_64-qt5 :: removing mingw-w64-x86_64-qt5-quickcontrols2 breaks dependency 'mingw-w64-x86_64-qt5-quickcontrols2' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-quicktimeline breaks dependency 'mingw-w64-x86_64-qt5-quicktimeline' required by mingw-w64-x86_64-qt5 :: removing mingw-w64-x86_64-qt5-remoteobjects breaks dependency 'mingw-w64-x86_64-qt5-remoteobjects' required by mingw-w64-x86_64-qt5 :: removing mingw-w64-x86_64-qt5-script breaks dependency 'mingw-w64-x86_64-qt5-script' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-scxml breaks dependency 'mingw-w64-x86_64-qt5-scxml' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-sensors breaks dependency 'mingw-w64-x86_64-qt5-sensors' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-serialbus breaks dependency 'mingw-w64-x86_64-qt5-serialbus' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-serialport breaks dependency 'mingw-w64-x86_64-qt5-serialport' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-speech breaks dependency 'mingw-w64-x86_64-qt5-speech' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-svg breaks dependency 'mingw-w64-x86_64-qt5-svg' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-tools breaks dependency 'mingw-w64-x86_64-qt5-tools' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-translations breaks dependency 'mingw-w64-x86_64-qt5-translations' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-virtualkeyboard breaks dependency 'mingw-w64-x86_64-qt5-virtualkeyboard' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-webchannel breaks dependency 'mingw-w64-x86_64-qt5-webchannel' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-webglplugin breaks dependency 'mingw-w64-x86_64-qt5-webglplugin' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-websockets breaks dependency 'mingw-w64-x86_64-qt5-websockets' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-webview breaks dependency 'mingw-w64-x86_64-qt5-webview' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-winextras breaks dependency 'mingw-w64-x86_64-qt5-winextras' required by mingw-w64-x86_64-qt5
:: removing mingw-w64-x86_64-qt5-xmlpatterns breaks dependency 'mingw-w64-x86_64-qt5-xmlpatterns' required by mingw-w64-x86_64-qt5
These coincidentally seem to be the libraries that have no migrations:
This will replace all installed mingw-w64-x86_64-* packages with their mingw-w64-ucrt-x86_64-* equivalents. Continue? [y/N] y
Gathering package information...
WARNING: mingw-w64-ucrt-x86_64-libsoup not found; mingw-w64-x86_64-libsoup will not be migrated
WARNING: mingw-w64-ucrt-x86_64-python-pathlib2 not found; mingw-w64-x86_64-python-pathlib2 will not be migrated
WARNING: mingw-w64-ucrt-x86_64-python-pdm-pep517 not found; mingw-w64-x86_64-python-pdm-pep517 will not be migrated
WARNING: mingw-w64-ucrt-x86_64-qt5 not found; mingw-w64-x86_64-qt5 will not be migrated
Author
thanks! I've changed it to remove both in one go now.
I kept the deps around hoping you'd reply soon, so thanks for the quick reply :D. I can confirm the script works from start to end now :). Now to find all the latent references to msys64/bin on my system...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feedback welcome.