-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
mpbb-print-info
76 lines (63 loc) · 2.57 KB
/
mpbb-print-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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=$("$(readlink "${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
}