cd into root of mas project at beginning of every bash script.

Partial #638

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-11-15 23:21:37 -05:00
parent 33559bff9a
commit 6b1903cde9
No known key found for this signature in database
12 changed files with 88 additions and 5 deletions

View file

@ -14,7 +14,14 @@
# Variables # Variables
# #
BUILD_DIR="${PWD}/.build" mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
BUILD_DIR=.build
BOTTLE_DIR="${BUILD_DIR}/bottles" BOTTLE_DIR="${BUILD_DIR}/bottles"
CORE_TAP_PATH="$(brew --repo homebrew/core)" CORE_TAP_PATH="$(brew --repo homebrew/core)"
MAS_VERSION="$(script/version)" MAS_VERSION="$(script/version)"

View file

@ -6,6 +6,13 @@
# https://docs.brew.sh/Formula-Cookbook#check-the-build-system # https://docs.brew.sh/Formula-Cookbook#check-the-build-system
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
HOMEBREW_NO_INSTALL_FROM_API=1 \ HOMEBREW_NO_INSTALL_FROM_API=1 \
brew reinstall \ brew reinstall \
--interactive mas --interactive mas

View file

@ -9,11 +9,17 @@
# brew bump-formula-pr --help # brew bump-formula-pr --help
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
CORE_TAP_PATH="$(brew --repo homebrew/core)" CORE_TAP_PATH="$(brew --repo homebrew/core)"
CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb" CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb"
PROJECT_PATH="$(git rev-parse --show-toplevel)" LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
function usage { function usage {
echo "Usage: brew_core_update [-d] [<version_tag> [<sha1_hash>]]" echo "Usage: brew_core_update [-d] [<version_tag> [<sha1_hash>]]"

View file

@ -7,6 +7,13 @@
# https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-contribute-a-fix-to-the-foo-formula # https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-contribute-a-fix-to-the-foo-formula
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
brew uninstall --force mas brew uninstall --force mas
brew install --build-from-source mas brew install --build-from-source mas
brew test mas brew test mas

View file

@ -7,6 +7,13 @@
# https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb # https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
function usage { function usage {
echo "Usage: brew_tap_update [<version_tag> [<sha1_hash>]]" echo "Usage: brew_tap_update [<version_tag> [<sha1_hash>]]"
echo " version will be inferred using version script if not provided" echo " version will be inferred using version script if not provided"

View file

@ -6,6 +6,13 @@
# Runs all related scripts for generating all artifacts. # Runs all related scripts for generating all artifacts.
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
MAS_VERSION="$(script/version)" MAS_VERSION="$(script/version)"
echo "Building mas ${MAS_VERSION} artifacts" echo "Building mas ${MAS_VERSION} artifacts"

View file

@ -6,5 +6,12 @@
# Deletes the build directory. # Deletes the build directory.
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
swift package clean swift package clean
swift package reset swift package reset

View file

@ -10,6 +10,13 @@
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb # https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
ARCH="$(uname -m)" ARCH="$(uname -m)"
RELEASE=".build/${ARCH}-apple-macosx/release" RELEASE=".build/${ARCH}-apple-macosx/release"
MAS_VERSION="$(script/version)" MAS_VERSION="$(script/version)"

View file

@ -6,7 +6,14 @@
# Builds macOS installer component and distribution packages. # Builds macOS installer component and distribution packages.
# #
BUILD_DIR="${PWD}/.build" mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
BUILD_DIR=.build
COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg" COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg"
DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg" DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg"
@ -17,7 +24,7 @@ IDENTIFIER="com.mphys.mas-cli"
DISTRIBUTION_PLIST="Package/Distribution.plist" DISTRIBUTION_PLIST="Package/Distribution.plist"
# Destination for install root # Destination for install root
DSTROOT=.build/distributions DSTROOT="${BUILD_DIR}/distributions"
script/install "${DSTROOT}/usr/local" --universal script/install "${DSTROOT}/usr/local" --universal
MAS_VERSION="$(script/version)" MAS_VERSION="$(script/version)"

View file

@ -6,6 +6,13 @@
# Installs the mas distribution package. Requires sudo access. # Installs the mas distribution package. Requires sudo access.
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
IDENTIFIER=com.mphys.mas-cli IDENTIFIER=com.mphys.mas-cli
echo "==> 📲 Installing mas" echo "==> 📲 Installing mas"

View file

@ -6,6 +6,13 @@
# Removes mas from PREFIX. # Removes mas from PREFIX.
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
# Override default prefix path with optional 1st arg # Override default prefix path with optional 1st arg
PREFIX="${1:-"$(brew --prefix)"}" PREFIX="${1:-"$(brew --prefix)"}"

View file

@ -6,6 +6,13 @@
# Runs class-dump to generate headers for Apple private frameworks. # Runs class-dump to generate headers for Apple private frameworks.
# #
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
main() { main() {
check_class_dump check_class_dump
extract_private_framework_headers "CommerceKit" extract_private_framework_headers "CommerceKit"