#!/bin/sh
# muOS unzip handles GOG installers but needs glibc 2.34; older bases (TrimUI) get busybox's.
dir="$(dirname "$0")"
"$dir/unzip.muos" -v >/dev/null 2>&1 && exec "$dir/unzip.muos" "$@"

# busybox has no -z; PortMaster.txt reads runtime zip comments with it.
if [ "$1" = "-z" ]; then
    exec "$dir/python3" -c 'import sys, zipfile
print("Archive:  " + sys.argv[1])
comment = zipfile.ZipFile(sys.argv[1]).comment.decode().rstrip("\n")
if comment: print(comment)' "$2"
fi

exec "$dir/../../bin64/busybox" unzip "$@"
