Last active
April 18, 2026 01:10
-
-
Save mlt/93c66659c904984b132ab2db0a181f7b to your computer and use it in GitHub Desktop.
Place me in C:/msys64/usr/lib/aurutils
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 | |
| # Usage: | |
| # aur depends mingw-w64-ucrt-mcf-x86_64-some_package | tsort | tac | aur debuild | |
| ARGS=( "$@" ) | |
| if [ ! -t 0 ]; then | |
| readarray -t STDIN_LINES < /dev/stdin | |
| PACKAGES=( "${ARGS[@]}" "${STDIN_LINES[@]}" ) | |
| else | |
| PACKAGES=( "${ARGS[@]}" ) | |
| fi | |
| while IFS=: read -r key value; do | |
| case "$key" in | |
| repo) REPO_NAME="$value" ;; | |
| root) REPO_ROOT="$value" ;; | |
| esac | |
| done < <(aur repo) | |
| declare -A REPO_VERSIONS | |
| while read -r _ pkg ver _; do | |
| REPO_VERSIONS["$pkg"]="$ver" | |
| done < <(pacman -Sl "$REPO_NAME") | |
| declare -A MSYS_INSTALLED | |
| while read -r _ pkg _ inst; do | |
| MSYS_INSTALLED["$pkg"]="$inst" | |
| done < <(pacman -Sl "msys") | |
| for pkg in "${PACKAGES[@]}"; do | |
| if [[ -f "$MINGW_PACKAGES_EXTRA/$pkg/PKGBUILD" ]]; then | |
| cd "$MINGW_PACKAGES_EXTRA/$pkg" | |
| elif [[ -f "$MINGW_PACKAGES/$pkg/PKGBUILD" ]]; then | |
| cd "$MINGW_PACKAGES/$pkg" | |
| else | |
| echo "Skipping $pkg: PKGBUILD not found." | |
| continue | |
| fi | |
| LOCAL_VER=$(makepkg --printsrcinfo | grep -E '^\s*(pkgver|pkgrel|epoch) =' | sed 's/ //g' | awk -F= ' | |
| /epoch/{e=$2} /pkgver/{v=$2} /pkgrel/{r=$2} | |
| END {if(e) printf "%s:",e; printf "%s-%s",v,r}') | |
| REPO_VER=${REPO_VERSIONS["$MINGW_PACKAGE_PREFIX${pkg#mingw-w64}"]} | |
| if [[ -n "$REPO_VER" ]]; then | |
| RESULT=$(vercmp "$LOCAL_VER" "$REPO_VER") | |
| if [[ "$RESULT" -le 0 ]]; then | |
| echo "[$pkg] Up to date (Repo: $REPO_VER, Local: $LOCAL_VER). Skipping." | |
| continue | |
| fi | |
| echo "[$pkg] Update available ($REPO_VER -> $LOCAL_VER)." | |
| else | |
| if [[ "$pkg" != "mingw-w64-"* && -z "${MSYS_INSTALLED[$pkg]}" ]]; then | |
| echo "[$pkg] Installing from msys." | |
| pacman -S --noconfirm $pkg | |
| continue | |
| fi | |
| echo "[$pkg] Not found in repo. Initial build." | |
| fi | |
| echo -ne "\033]0;Building $pkg...\007" | |
| # -s is pointless for ${MSYSTEM} as we can't pass through --overwrite "*" all the way to pacman | |
| # but we could benefit from it while installing base msys packages | |
| # --sign | |
| aur-build -s -n -R --cleanbuild --margs --skippgpcheck --margs --nocheck || break | |
| # we aren't a build farm, there is a chance dependency is already installed, but old or mock, so update | |
| pacman -U $(makepkg-mingw --packagelist | sed -E "s#.+/#${REPO_ROOT}/#") --noconfirm --overwrite "*" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment