From 532b955de3670da22de7148754ec14966c8d2803 Mon Sep 17 00:00:00 2001 From: mite-user Date: Sun, 19 Sep 2021 14:51:07 +0300 Subject: [PATCH] osxcross-macports: add package version check --- tools/osxcross-macports | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/osxcross-macports b/tools/osxcross-macports index 9648dd5..eb24d99 100755 --- a/tools/osxcross-macports +++ b/tools/osxcross-macports @@ -274,11 +274,18 @@ verifyFileIntegrity() getPkgUrl() { local pkgname="$1" + local pkgversion local pkgs local pkg set +e + local pkg_info_url="https://ports.macports.org" + pkg_info_url+="/api/v1/ports/$pkgname/?format=json" + pkgversion=$(getFileStdout "$pkg_info_url" | \ + grep -o -E '"version":"[^"]+"' | \ + cut -d'"' -f4) + pkgs=$(getFileStdout "$MIRROR/$pkgname/?C=M;O=A" | \ grep -o -E 'href="([^"#]+)"' | \ cut -d'"' -f2 | grep '.tbz2$') @@ -298,7 +305,17 @@ getPkgUrl() verboseMsg " $p" done - local pkg=$(echo "$pkgs" | grep $OSXVERSION | grep $ARCH | uniq | tail -n1) + local pkg=$(echo "$pkgs" | \ + grep "$pkgname-$pkgversion" | grep $OSXVERSION | grep $ARCH | \ + uniq | tail -n1) + if [ -z "$pkg" ]; then + pkg=$(echo "$pkgs" | \ + grep "$pkgname-$pkgversion" | grep $OSXVERSION | grep "noarch" | \ + uniq | tail -n1) + fi + if [ -z "$pkg" ]; then + pkg=$(echo "$pkgs" | grep $OSXVERSION | grep $ARCH | uniq | tail -n1) + fi if [ -z "$pkg" ]; then pkg=$(echo "$pkgs" | grep $OSXVERSION | grep "noarch" | uniq | tail -n1) fi