Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow the XDG Base Directory specification for caching on Linux #2934

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,32 @@ then
then
HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl"
fi

if [[ -z "$HOMEBREW_CACHE" ]]
then
HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew"
fi
else
HOMEBREW_PROCESSOR="$(uname -m)"
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
[[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)"
: "${HOMEBREW_OS_VERSION:=$(uname -r)}"
HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION"

if [[ -z "$HOMEBREW_CACHE" ]]
then
if [[ -n "$XDG_CACHE_HOME" ]]
then
HOMEBREW_CACHE="$XDG_CACHE_HOME/Homebrew"
else
HOMEBREW_CACHE="$HOME/.cache/Homebrew"
fi
fi
fi
HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_USER_AGENT_VERSION)"
HOMEBREW_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | /usr/bin/awk '{print $1"/"$2}')"
HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION"

if [[ -z "$HOMEBREW_CACHE" ]]
then
HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew"
fi

# Declared in bin/brew
export HOMEBREW_BREW_FILE
export HOMEBREW_PREFIX
Expand Down