mirror of
https://github.com/macports/mpbb.git
synced 2026-03-31 14:38:29 -07:00
77 lines
2.6 KiB
Bash
77 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4
|
|
|
|
# Note:
|
|
# This script is sourced by the mpbb wrapper script.
|
|
# Do not execute this directly!
|
|
|
|
print-info-usage() {
|
|
# "prog" is defined in mpbb-help.
|
|
# shellcheck disable=SC2154
|
|
cat <<EOF
|
|
usage: $prog [<global opts>] print-info [<port>]
|
|
|
|
Prints the macOS and Xcode versions and the version, revision, variants,
|
|
and last modified commit of the port if given.
|
|
|
|
Run \`$prog help' for global options and a list of other subcommands.
|
|
EOF
|
|
}
|
|
|
|
print-info() {
|
|
local port=${1-}
|
|
if [[ -n $port ]]; then
|
|
local portversion portrevision portvariants portdir portcommit
|
|
|
|
# $option_prefix is set in mpbb
|
|
# shellcheck disable=SC2154
|
|
if portversion=$("${option_prefix}/bin/port" info --index --line --version "$port"); then
|
|
printf "portversion=%s\n" "$portversion"
|
|
fi
|
|
|
|
# $option_prefix is set in mpbb
|
|
# shellcheck disable=SC2154
|
|
if portrevision=$("${option_prefix}/bin/port" info --index --line --revision "$port"); then
|
|
printf "portrevision=%s\n" "$portrevision"
|
|
fi
|
|
|
|
# $option_prefix is set in mpbb
|
|
# shellcheck disable=SC2154
|
|
if portvariants=$("${option_prefix}/bin/port-tclsh" tools/canonical-variants.tcl "$port"); then
|
|
printf "portvariants=%s\n" "$portvariants"
|
|
fi
|
|
|
|
# $option_prefix is set in mpbb
|
|
# shellcheck disable=SC2154
|
|
if portdir=$("${option_prefix}/bin/port" dir "$port"); then
|
|
if portcommit=$(git -C "$portdir" log -n 1 --pretty=format:%H .); then
|
|
printf "portcommit=%s\n" "$portcommit"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if command -v sw_vers >/dev/null; then
|
|
local macosversion macosbuild
|
|
|
|
if macosversion=$(sw_vers -productVersion); then
|
|
if macosbuild=$(sw_vers -buildVersion); then
|
|
printf "macosversion=%s (%s)\n" "$macosversion" "$macosbuild"
|
|
else
|
|
printf "macosversion=%s\n" "$macosversion"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if command -v xcodebuild >/dev/null; then
|
|
local xcodeversion xcodebuild
|
|
|
|
if xcodeversion=$(xcodebuild -version | sed -En 's,^Xcode (.*)$,\1,p'); then
|
|
if xcodebuild=$(xcodebuild -version | sed -En 's,^Build ?[Vv]ersion:? (.*)$,\1,p'); then
|
|
printf "xcodeversion=%s (%s)\n" "$xcodeversion" "$xcodebuild"
|
|
else
|
|
printf "xcodeversion=%s\n" "$xcodeversion"
|
|
fi
|
|
fi
|
|
fi
|
|
}
|