diff --git a/install/macos_packages/build_and_notarize.sh b/install/macos_packages/build_and_notarize.sh index 1900ed98c8f9..d3f12193e46b 100644 --- a/install/macos_packages/build_and_notarize.sh +++ b/install/macos_packages/build_and_notarize.sh @@ -2,30 +2,30 @@ set -euo pipefail -# Envrionmental variables that need to be set. These are sane defaults +# Environmental variables that need to be set. These are sane defaults # KEYCHAIN_ENTRY=AC_PASSWORD # Or whatever you picked for # RUNNER_TEMP=~/Library/Keychains/ # KEYCHAIN_FILENAME=login.keychain-db # # Environmental variables that can be set if needed. Else they will default to # values selected for the CI -# +# # The identifier for the application signing key. Can be a name or a fingerprint # APPLICATION_KEY_IDENT=E03290CABE09E9E42341C8FC82608E91241FAD4A # The identifier for the installer signing key. Can be a name or a fingerprint # INSTALLATION_KEY_IDENT=E525359D0B5AE97B7B6F5BB465FEC872C117D681 -usage(){ - echo "Builds, signs, and notarizes starship." - echo "Read readme.md in the script directory to see the assumptions the script makes." - echo "Usage: $0 [pkgname]" - echo " Example: $0 target/release/starship docs/ x64" - echo " Example: $0 target/debug/starship docs/ arm64 starship-1.2.1-arm64.pkg" - echo "" - echo "If no pkgname is provided, the package will be named starship--.pkg" +usage() { + echo "Builds, signs, and notarizes starship." + echo "Read readme.md in the script directory to see the assumptions the script makes." + echo "Usage: $0 [pkgname]" + echo " Example: $0 target/release/starship docs/ x64" + echo " Example: $0 target/debug/starship docs/ arm64 starship-1.2.1-arm64.pkg" + echo "" + echo "If no pkgname is provided, the package will be named starship--.pkg" } -script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" source "$script_dir/common.sh" if [[ -z ${KEYCHAIN_ENTRY+x} ]]; then @@ -56,8 +56,8 @@ if [[ -z ${INSTALLATION_KEY_IDENT+x} ]]; then fi if [[ -z ${3+x} ]]; then - usage - exit 1 + usage + exit 1 fi starship_binary="$1" @@ -112,4 +112,4 @@ if [ "$pkgname" = "" ]; then fi echo ">>>> Placing final output at $pkgname" -mv starship.pkg "$pkgname" \ No newline at end of file +mv starship.pkg "$pkgname" diff --git a/install/macos_packages/build_component_package.sh b/install/macos_packages/build_component_package.sh index 000c08f6650d..634f9f4d3fb4 100644 --- a/install/macos_packages/build_component_package.sh +++ b/install/macos_packages/build_component_package.sh @@ -8,7 +8,7 @@ set -euo pipefail # Usage: run this script, passing $1 to the repository path. The script assumes # it is being run from within a starship repository if $1 is not provided. -usage(){ +usage() { echo "Builds a component package for macOS." echo "Assumes that the following items already exist:" echo " - A starship binary which has already been notarized" @@ -17,10 +17,10 @@ usage(){ echo "Usage: $0 " } -script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" source "$script_dir/common.sh" -cleanup_server(){ +cleanup_server() { if [[ -n "${server_pid-}" ]]; then echo "Killing HTTP server ($server_pid) to clean up." kill "$server_pid" @@ -77,7 +77,7 @@ sleep 3 # on MacOS by default, but lucky for us, it does exist on GHActions runners. # Wget may return nonzero exit codes even if things were mostly fine (e.g. 404 for # some links on translated pages) so we simply ignore if it has a failure -wget --mirror --convert-links --adjust-extension --page-requisites --no-parent 127.0.0.1:8000 &> wget.log || true +wget --mirror --convert-links --adjust-extension --page-requisites --no-parent 127.0.0.1:8000 &>wget.log || true mkdir -p "$pkgdir/usr/local/share/doc/" mv 127.0.0.1:8000 "$pkgdir/usr/local/share/doc/starship" @@ -87,4 +87,4 @@ trap - INT # Build the component package version="$(starship_version "$starship_program_file")" -pkgbuild --identifier com.starshipprompt.starship --version "$version" --root $pkgdir starship-component.pkg \ No newline at end of file +pkgbuild --identifier com.starshipprompt.starship --version "$version" --root $pkgdir starship-component.pkg diff --git a/install/macos_packages/build_distribution_package.sh b/install/macos_packages/build_distribution_package.sh index 54b4ef89d9e2..4d3368c669e0 100644 --- a/install/macos_packages/build_distribution_package.sh +++ b/install/macos_packages/build_distribution_package.sh @@ -4,25 +4,25 @@ component_package="$1" resources="$2" arch="$3" -usage(){ - echo "Builds a distribution package for macOS." - echo "Assumes that the following items already exist:" - echo " - A starship component package" - echo " - Resources in a pkg_resources directory" - echo "Usage: $0 " - echo " where arch is one of \"arm64\" or \"x86_64\"" +usage() { + echo "Builds a distribution package for macOS." + echo "Assumes that the following items already exist:" + echo " - A starship component package" + echo " - Resources in a pkg_resources directory" + echo "Usage: $0 " + echo " where arch is one of \"arm64\" or \"x86_64\"" } -script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" source "$script_dir/common.sh" if [[ "$OSTYPE" != 'darwin'* ]]; then - error "This script only works on MacOS" + error "This script only works on MacOS" fi if [[ "${3-undefined}" = "undefined" ]]; then - usage - exit 1 + usage + exit 1 fi # Generate a distribution file with the appropriate architecture plists @@ -40,8 +40,7 @@ productbuild --synthesize --package starship-component.pkg --product "$archplist # search for a line that matches our opening tag and insert our desired lines after it # Solution taken from https://www.theunixschool.com/2012/06/insert-line-before-or-after-pattern.html -while read -r line -do +while read -r line; do echo "$line" if echo "$line" | grep -qF '' @@ -49,10 +48,10 @@ do echo '' echo '' fi -done < starship_raw.dist > starship.dist +done starship.dist # The above script does not correctly take care of the last line. Apply fixup. -echo '' >> starship.dist +echo '' >>starship.dist echo "Creating distribution package with following distribution file:" cat starship.dist @@ -64,4 +63,4 @@ echo "Component package is $component_package" productbuild --distribution starship.dist --resources "$resources" --package-path "$component_package" starship-unsigned.pkg # Clean up the distribution files -rm -- *.dist \ No newline at end of file +rm -- *.dist diff --git a/install/macos_packages/common.sh b/install/macos_packages/common.sh index 9a9c8503d171..f69d05d04dd4 100644 --- a/install/macos_packages/common.sh +++ b/install/macos_packages/common.sh @@ -1,17 +1,17 @@ #!/bin/bash -error(){ - echo "[ERROR]: $1" - exit 1 +error() { + echo "[ERROR]: $1" + exit 1 } -starship_version(){ +starship_version() { starship_program_file="$1" # Check if this is a relative path: if so, prepend './' to it if [ "$1" = "${1#/}" ]; then starship_program_file="./$starship_program_file" fi - if "$starship_program_file" -V 2>&1 > /dev/null; then + if "$starship_program_file" -V 2>&1 >/dev/null; then "$starship_program_file" -V | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' else # try to get this information from Cargo.toml diff --git a/install/macos_packages/readme.md b/install/macos_packages/readme.md index c56f84c33873..07cfac333e05 100644 --- a/install/macos_packages/readme.md +++ b/install/macos_packages/readme.md @@ -138,7 +138,7 @@ attempts, run xcrun notarytool history --keychain-profile "AC_PASSWORD" ``` -Find the `id` of the attempt you wish to view, then run one of these commmands: +Find the `id` of the attempt you wish to view, then run one of these commands: ``` xcrun notarytool info --keychain-profile "AC_PASSWORD"