Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MacPorts support #440

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions tools/osxcross-macports
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ PUBKEYRMD160="d3a22f5be7184d6575afcc1be6fdb82fd25562e8"
PUBKEYSHA1="214baa965af76ff71187e6c1ac91c559547f48ab"

PLATFORM=$(uname -s)
ARCH="x86_64"
ARCH="$(uname -m)"
ARCH="${ARCH/aarch64/arm64}"

TAR="tar"
if command -v bsdtar >/dev/null; then
TAR="bsdtar"
fi

if [ -z "$BASHPID" ]; then
BASHPID=$(sh -c 'echo $PPID')
Expand Down Expand Up @@ -275,6 +281,19 @@ verifyFileIntegrity()
set -e
}

logPkgCandidates() {
local context="$1"
shift
local pkgs="$@"
local count=$(echo "$pkgs" | wc -w)
local list_pkgs=""
if [ $count -lt 5 ]; then
list_pkgs=$(echo "$pkgs")
fi

verboseMsg " ${context}: ${count} packages left.. ${list_pkgs}"
}

getPkgUrl()
{
local pkgname="$1"
Expand All @@ -292,7 +311,7 @@ getPkgUrl()

pkgs=$(getFileStdout "$MIRROR/$pkgname/?C=M;O=A" | \
grep -o -E 'href="([^"#]+)"' | \
cut -d'"' -f2 | grep '.tbz2$')
cut -d'"' -f2 | grep '.tbz2$' | uniq)

local ec=$?

Expand All @@ -309,32 +328,19 @@ getPkgUrl()
verboseMsg " $p"
done

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
if [ -z "$pkg" ]; then
pkg=$(echo "$pkgs" | grep "any" | grep $ARCH | uniq | tail -n1)
fi
if [ -z "$pkg" ]; then
pkg=$(echo "$pkgs" | grep "any" | grep "noarch" | uniq | tail -n1)
fi
local step1=$(echo "$pkgs" | grep "$pkgname-$pkgversion")
logPkgCandidates "step1" $step1
local step2=$(echo "$step1" | egrep "\.(${OSXVERSION}|darwin_any|any_any)\.")
logPkgCandidates "step2" $step2
local step3=$(echo "$step2" | egrep "\.(${ARCH}|noarch)\.")
logPkgCandidates "step3" $step3
local pkg=$(echo "$step3" | uniq | tail -n1)

verboseMsg " selected: $pkg"

if [ -z "$pkg" ]; then
verboseMsg -n " "
errorMsg "no suitable version found for $OSXVERSION"
errorMsg "no suitable version found for $OSXVERSION on $ARCH"
return
fi

Expand Down Expand Up @@ -406,7 +412,7 @@ installPkg()
echo "installing $pkgname ..."
verboseMsg " extracting $pkgfile ..."

bzip2 -dc "$CACHE/$pkgfile" | tar xf -
bzip2 -dc "$CACHE/$pkgfile" | ${TAR} xf -

if [ -d opt/local ]; then
verboseMsg " fixing permissions ..."
Expand Down Expand Up @@ -612,7 +618,7 @@ main()
elif [ $opt == "-32" -o $opt == "--i386" ]; then
ARCH="i386"
elif [ $opt == "-universal" -o $opt == "--universal" ]; then
ARCH="i386-x86_64"
ARCH="arm64-x86_64"
elif [ $opt == "-arm64" -o $opt == "--arm64" ]; then
ARCH="arm64"
elif [ $opt == "-sm" -o $opt == "--select-mirror" ]; then
Expand Down