2
0
MasterPassword/platform-darwin/Scripts/updatePlist

57 lines
1.9 KiB
Plaintext
Raw Normal View History

2014-11-02 15:27:02 +00:00
#!/usr/bin/env bash
cd "${BASH_SOURCE%/*}"
source ./bashlib
2018-06-05 18:44:54 +00:00
trap 'echo >&2 "ERROR: $?: $BASH_COMMAND"' ERR
set -e
2014-11-02 15:27:02 +00:00
cd ..
export PATH+=:/usr/libexec
addPlistWithKey() {
local key=$1 type=$2 value=$3 plist=${4:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
PlistBuddy -c "Delete :'$key'" "$plist" 2>/dev/null || true
PlistBuddy -c "Add :'$key' '$type' '$value'" "$plist"
}
setPlistWithKey() {
local key=$1 value=$2 plist=${3:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
PlistBuddy -c "Set :'$key' '$value'" "$plist"
}
getPlistWithKey() {
local key=$1 plist=${2:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
PlistBuddy -c "Print :'$key'" "$plist"
}
setSettingWithTitle() {
local i title=$1 value=$2 plist=${3:-"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Settings.bundle/Root.plist"}
for (( i=0; 1; ++i )); do
PlistBuddy -c "Print :PreferenceSpecifiers:$i" "$plist" &>/dev/null || break
inf "Checking preference specifier $i"
[[ $(PlistBuddy -c "Print :PreferenceSpecifiers:$i:Title" "$plist" 2>/dev/null) = $title ]] || continue
inf "Correct title, setting value."
PlistBuddy -c "Set :PreferenceSpecifiers:$i:DefaultValue $value" "$plist"
break
done
}
2017-04-14 04:43:34 +00:00
case $PLATFORM_NAME in
macosx) platform=mac ;;
2017-04-14 17:08:23 +00:00
iphone*) platform=ios ;;
2017-04-14 04:43:34 +00:00
*) ftl 'ERROR: Unknown platform: %s.' "$PLATFORM_NAME"; exit 1 ;;
esac
description=$(git describe --always --dirty --long --match "*-$platform*")
2017-04-14 04:43:34 +00:00
version=${description%-g*} build=${version##*-} version=${version%-$build}
version=${version//-$platform/} version=${version//-/.} commit=${description##*-g}
2014-11-02 15:27:02 +00:00
addPlistWithKey GITDescription string "$description"
2017-04-01 04:43:44 +00:00
setPlistWithKey CFBundleVersion "$(hr "${version%%.*}" 14).${version#*.}"
setPlistWithKey CFBundleShortVersionString "$version"
2014-11-02 15:27:02 +00:00
setSettingWithTitle "Build" "$commit"
setSettingWithTitle "Version" "$version"
setSettingWithTitle "Copyright" "$(getPlistWithKey NSHumanReadableCopyright)"